.github/workflows/release.yml - GitHub Actions(多平台) .gitea/workflows/release.yml - Gitea(仅 Linux)
76 lines
2.4 KiB
YAML
76 lines
2.4 KiB
YAML
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"
|
|
|
|
- name: Setup cargo mirror
|
|
run: |
|
|
mkdir -p ~/.cargo
|
|
cat > ~/.cargo/config.toml << 'EOF'
|
|
[source.crates-io]
|
|
replace-with = "ustc"
|
|
|
|
[source.ustc]
|
|
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io/index/"
|
|
EOF
|
|
|
|
- name: Checkout code
|
|
run: git clone https://hub.gaomia.site/titor/haibao-tts-cli.git /workspace/mimo-tts
|
|
|
|
- name: Build binary
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
cd /workspace/mimo-tts
|
|
cargo build --release -p mimo-tts
|
|
mv target/release/mimo-tts mimo-tts-linux-amd64
|
|
|
|
- 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 |