Files
haibao-tts-cli/.github/workflows/release.yml
Workflow config file is invalid. Please check your config file: yaml: line 32: could not find expected ':'
titor d3c7243d33 ci: 多平台构建 支持 matrix 和交叉编译
- 使用 Ubuntu 24.04 runner
- 添加 cargo 镜像源
- 在一个 job 中顺序构建所有平台
- 支持:linux-amd64, linux-arm64, darwin-amd64, darwin-arm64, windows-amd64
- 每次 push 到 main 自动更新 release
2026-04-24 03:44:37 +08:00

100 lines
3.5 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: Setup mirrors
run: |
echo 'deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse' | tee /etc/apt/sources.list
apt-get update -qq
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
# 安装交叉编译目标
rustup target add aarch64-unknown-linux-gnu || true
rustup target add x86_64-apple-darwin || true
rustup target add aarch64-apple-darwin || true
rustup target add x86_64-pc-windows-gnu || true
- name: Setup cargo mirror
run: |
mkdir -p ~/.cargo
cat > ~/.cargo/config.toml << 'CARGO_EOF'
[source.crates-io]
replace-with = "ustc"
[source.ustc]
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io/index/"
CARGO_EOF
- name: Checkout code
run: git clone https://hub.gaomia.site/titor/haibao-tts-cli.git /workspace/mimo-tts
- name: Build all binaries
run: |
. "$HOME/.cargo/env"
cd /workspace/mimo-tts
# Linux x86_64
cargo build --release -p mimo-tts
mv target/release/mimo-tts mimo-tts-linux-amd64
# Linux ARM64
GOOS=linux GOARCH=arm64 cargo build --release -p mimo-tts --target aarch64-unknown-linux-gnu
mv target/release/mimo-tts mimo-tts-linux-arm64
# macOS x86_64
GOOS=darwin GOARCH=amd64 cargo build --release -p mimo-tts --target x86_64-apple-darwin
mv target/release/mimo-tts mimo-tts-darwin-amd64
# macOS ARM64
GOOS=darwin GOARCH=arm64 cargo build --release -p mimo-tts --target aarch64-apple-darwin
mv target/release/mimo-tts mimo-tts-darwin-arm64
# Windows x86_64
GOOS=windows GOARCH=amd64 cargo build --release -p mimo-tts --target x86_64-pc-windows-gnu
mv target/release/mimo-tts.exe mimo-tts-windows-amd64.exe
- 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"
cd /workspace/mimo-tts
COMMIT_MSG=$(git log -1 --format="%s" HEAD)
TAG_NAME="latest"
# 删除已存在的 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\":\"Release ${TAG_NAME}\",\"body\":\"${COMMIT_MSG}\",\"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