name: Release on: push: branches: - main jobs: build: runs-on: ubuntu24.04 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: ubuntu24.04 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