Some checks failed
Release / build (push) Has been cancelled
- 移除 matrix strategy(单 job 构建) - 移除 artifacts(直接上传) - 所有平台在一个 step 中构建
61 lines
1.9 KiB
YAML
61 lines
1.9 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu24.04
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
run: |
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
. ~/.cargo/env
|
|
|
|
- name: Build
|
|
run: |
|
|
. ~/.cargo/env
|
|
|
|
for target in linux-amd64 linux-arm64 darwin-amd64 darwin-arm64 windows-amd64; do
|
|
os=${target%-*}
|
|
arch=${target#*-}
|
|
ext=""
|
|
[ "$os" = "windows" ] && ext=".exe"
|
|
GOOS=$os GOARCH=$arch cargo build --release -p mimo-tts
|
|
mv target/release/mimo-tts "mimo-tts-${os}-${arch}${ext}"
|
|
done
|
|
|
|
- name: Checksums
|
|
run: |
|
|
sha256sum mimo-tts-* > checksums.txt
|
|
|
|
- name: Upload release
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
run: |
|
|
GITEA_URL="https://hub.gaomia.site"
|
|
REPO="titor/haibao-tts-cli"
|
|
|
|
COMMIT_MSG=$(git log -1 --format="%s" HEAD)
|
|
COMMIT_BODY=$(git log -1 --format="%b" HEAD)
|
|
|
|
TAG_NAME="latest"
|
|
RELEASE_BODY="${COMMIT_MSG}\n\n${COMMIT_BODY}"
|
|
|
|
RELEASE_RESPONSE=$(curl -s -X POST "${GITEA_URL}/api/v1/repos/${REPO}/releases" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":\"${RELEASE_BODY}\",\"draft\":false}")
|
|
|
|
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
|
|
|
for f in mimo-tts-* checksums.txt; do
|
|
[ -f "$f" ] && curl -s -X POST "${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-F "attachment=@$f"
|
|
done |