57 lines
1.7 KiB
YAML
57 lines
1.7 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: golang:1.26-alpine
|
|
env:
|
|
GOPROXY: "https://mirrors.aliyun.com/goproxy/,direct"
|
|
steps:
|
|
- name: Checkout
|
|
run: |
|
|
apk add git
|
|
git clone -b dev https://hub.gaomia.site/titor/yoyo.git repo
|
|
mv repo/* .
|
|
mv repo/.* . 2>/dev/null || true
|
|
rmdir repo
|
|
|
|
- name: Download dependencies
|
|
run: go mod download
|
|
|
|
- name: Build
|
|
run: |
|
|
for p in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64; do
|
|
os=${p%/*}
|
|
arch=${p#*/}
|
|
ext=""
|
|
[ "$os" = "windows" ] && ext=".exe"
|
|
GOOS=$os GOARCH=$arch go build -o "yoo-${os}-${arch}${ext}" ./cmd/yoyo
|
|
done
|
|
|
|
- name: Checksums
|
|
run: sha256sum yoo-* > checksums.txt
|
|
|
|
- name: Release
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.release_token }}
|
|
run: |
|
|
TAG_NAME="${GITHUB_REF#refs/tags/}"
|
|
|
|
# 创建 Release
|
|
curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/yoyo/releases" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":\"Automated release\"}"
|
|
|
|
# 上传产物
|
|
for f in yoo-* checksums.txt; do
|
|
[ -f "$f" ] && curl -s -X POST "https://hub.gaomia.site/api/v1/repos/titor/yoyo/releases/upload?name=${TAG_NAME}" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-F "attachment=@$f"
|
|
done |