56 lines
1.7 KiB
YAML
56 lines
1.7 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
env:
|
|
GOPROXY: "https://mirrors.aliyun.com/goproxy/,direct"
|
|
GOSUMDB: "off"
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.26'
|
|
|
|
- name: Build
|
|
run: |
|
|
platforms=("linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64" "windows/amd64")
|
|
for p in "${platforms[@]}"; do
|
|
os=${p%/*}
|
|
arch=${p#*/}
|
|
ext=""
|
|
[ "$os" = "windows" ] && ext=".exe"
|
|
output="yoo-${os}-${arch}${ext}"
|
|
GOOS=$os GOARCH=$arch go build -o "$output" ./cmd/yoyo/main.go
|
|
done
|
|
|
|
- name: Checksums
|
|
run: sha256sum yoo-* > checksums.txt
|
|
|
|
- name: Release
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.release_token }}
|
|
GITEA_REPO: ${{ github.repository }}
|
|
TAG_NAME: ${{ github.ref_name }}
|
|
run: |
|
|
# 创建 Release
|
|
curl -s -X POST "https://hub.gaomia.site/api/v1/repos/${GITEA_REPO}/releases" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"${TAG_NAME#refs/tags/}\",\"name\":\"${TAG_NAME#refs/tags/}\",\"body\":\"Automated release\"}"
|
|
|
|
# 上传产物
|
|
for f in yoo-* checksums.txt; do
|
|
[ -f "$f" ] && curl -s -X POST "https://hub.gaomia.site/api/v1/repos/${GITEA_REPO}/releases/upload?name=${TAG_NAME#refs/tags/}" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-F "attachment=@$f"
|
|
done |