Files
haibao-tts-cli/.github/workflows/release.yml
titor b0d6718212
Some checks failed
Release / build (push) Has been cancelled
fix: 重写 workflow - 适配 Gitea Actions
- 不使用 actions/ 生态
- 直接 clone 代码构建
- 构建完成后删除旧 release 再创建新的
- 支持 windows .exe 后缀
2026-04-24 03:41:38 +08:00

70 lines
2.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Release
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu24.04
steps:
- name: Checkout code
run: git clone https://hub.gaomia.site/titor/haibao-tts-cli.git /workspace/mimo-tts
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
- name: Build binaries
run: |
. "$HOME/.cargo/env"
cd /workspace/mimo-tts
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: Generate checksums
run: |
cd /workspace/mimo-tts
sha256sum mimo-tts-* > checksums.txt
- name: Create release
env:
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
GITEA_URL="https://hub.gaomia.site"
REPO="titor/haibao-tts-cli"
WORKDIR="/workspace/mimo-tts"
cd "$WORKDIR"
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如果存在
curl -s -X DELETE "${GITEA_URL}/api/v1/repos/${REPO}/releases/tags/${TAG_NAME}" \
-H "Authorization: token ${GITEA_TOKEN}"
# 创建新 release
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