ci: 添加 Gitea Actions workflow
Some checks failed
Release / build (map[arch:amd64 os:darwin]) (push) Has been cancelled
Release / build (map[arch:amd64 os:linux]) (push) Has been cancelled
Release / build (map[arch:amd64 os:windows]) (push) Has been cancelled
Release / build (map[arch:arm64 os:darwin]) (push) Has been cancelled
Release / build (map[arch:arm64 os:linux]) (push) Has been cancelled
Release / release (push) Has been cancelled
Some checks failed
Release / build (map[arch:amd64 os:darwin]) (push) Has been cancelled
Release / build (map[arch:amd64 os:linux]) (push) Has been cancelled
Release / build (map[arch:amd64 os:windows]) (push) Has been cancelled
Release / build (map[arch:arm64 os:darwin]) (push) Has been cancelled
Release / build (map[arch:arm64 os:linux]) (push) Has been cancelled
Release / release (push) Has been cancelled
- 每次 push 到 main 分支时自动构建 - 支持多平台:linux amd64/arm64, darwin amd64/arm64, windows amd64 - 自动生成 checksums.txt - 自动更新 release 内容(使用 git log)
This commit is contained in:
82
.github/workflows/release.yml
vendored
Normal file
82
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu
|
||||
strategy:
|
||||
matrix:
|
||||
target:
|
||||
- os: linux
|
||||
arch: amd64
|
||||
- os: linux
|
||||
arch: arm64
|
||||
- os: darwin
|
||||
arch: amd64
|
||||
- os: darwin
|
||||
arch: arm64
|
||||
- os: windows
|
||||
arch: amd64
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
ext=""
|
||||
[ "${{ matrix.target.os }}" = "windows" ] && ext=".exe"
|
||||
GOOS=${{ matrix.target.os }} GOARCH=${{ matrix.target.arch }} cargo build --release -p mimo-tts
|
||||
mv target/release/mimo-tts "mimo-tts-${{ matrix.target.os }}-${{ matrix.target.arch }}${ext}"
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mimo-tts-${{ matrix.target.os }}-${{ matrix.target.arch }}
|
||||
path: mimo-tts-*
|
||||
|
||||
release:
|
||||
needs: build
|
||||
runs-on: ubuntu
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Create checksums
|
||||
run: |
|
||||
cd artifacts
|
||||
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"
|
||||
|
||||
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 artifacts/*; 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
|
||||
Reference in New Issue
Block a user