Files
seal-use/.github/workflows/release.yml
T
gitea 7bc98389eb
🧪 CI / 🧪 Test, Type-Check & Build Validation (push) Has been cancelled
🚀 Release / 🚀 Build & Publish Multi-Platform Binaries (push) Has been cancelled
Release v0.9.5: Optimize CI/CD pipelines, enable parallel builds, and add SHA-256 checksums
2026-08-27 16:10:50 +08:00

132 lines
4.8 KiB
YAML

name: 🚀 Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Release tag (e.g. v0.9.5, defaults to current ref)"
required: false
type: string
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
jobs:
build-and-publish:
name: 🚀 Build & Publish Multi-Platform Binaries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Type-check
run: bun run check
- name: Test
run: bun test
- name: Compile multi-target binaries
run: |
mkdir -p dist/bin
node scripts/build-binary.mjs --all
- name: Package release archives & checksums
run: |
sudo apt-get update && sudo apt-get install -y zip
cd dist/bin
tar -czf seal-home-linux-x64.tar.gz seal-home-linux-x64
tar -czf seal-home-linux-arm64.tar.gz seal-home-linux-arm64
tar -czf seal-home-darwin-x64.tar.gz seal-home-darwin-x64
tar -czf seal-home-darwin-arm64.tar.gz seal-home-darwin-arm64
zip -q seal-home-windows-x64.zip seal-home-windows-x64.exe
sha256sum seal-home-* > checksums.txt
echo "Generated checksums:"
cat checksums.txt
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG_NAME="${{ github.event.inputs.tag || github.ref_name }}"
TAG_MSG=$(git tag -l --format='%(contents)' "${TAG_NAME}" | sed '/^$/d')
if [ -n "$TAG_MSG" ]; then
gh release view "${TAG_NAME}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1 || gh release create "${TAG_NAME}" --repo "${GITHUB_REPOSITORY}" --title "${TAG_NAME}" --notes "$TAG_MSG" --generate-notes
else
gh release view "${TAG_NAME}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1 || gh release create "${TAG_NAME}" --repo "${GITHUB_REPOSITORY}" --title "${TAG_NAME}" --generate-notes
fi
gh release upload "${TAG_NAME}" dist/bin/seal-home-* dist/bin/checksums.txt --repo "${GITHUB_REPOSITORY}" --clobber
- name: Publish Gitea Release
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_HOST: "https://git.ying-qing.cn"
GITEA_REPO: "gitea/seal-home"
run: |
if [ -z "$GITEA_TOKEN" ]; then
echo "::notice::GITEA_TOKEN secret not configured, skipping Gitea upload."
exit 0
fi
TAG_NAME="${{ github.event.inputs.tag || github.ref_name }}"
TAG_MSG=$(git tag -l --format='%(contents)' "${TAG_NAME}" | sed '/^$/d')
NOTES="${TAG_MSG:-Automated release for ${TAG_NAME}}"
echo "==> Creating or finding release on Gitea for ${TAG_NAME}..."
RELEASE_ID=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" "${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases/tags/${TAG_NAME}" | jq -r '.id // empty')
if [ -z "$RELEASE_ID" ]; then
RELEASE_RESP=$(curl -s -X POST "${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":$(echo "$NOTES" | jq -Rsa .),\"draft\":false,\"prerelease\":false}")
RELEASE_ID=$(echo "$RELEASE_RESP" | jq -r '.id // empty')
fi
if [ -z "$RELEASE_ID" ]; then
echo "::warning::Failed to create or find Gitea release ID. Proceeding anyway."
exit 0
fi
echo "==> Uploading assets to Gitea release ID ${RELEASE_ID}..."
upload_asset() {
local file="$1"
local filename
filename=$(basename "$file")
echo " [start] Uploading ${filename} to Gitea..."
RESP=$(curl -s -m 120 -w "\nHTTP_STATUS:%{http_code}" -X POST "${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases/${RELEASE_ID}/assets?name=${filename}" \
-H "Authorization: token ${GITEA_TOKEN}" \
-F "attachment=@${file}")
STATUS=$(echo "$RESP" | tail -n 1)
echo " [done] ${filename} -> ${STATUS}"
}
pids=()
for file in dist/bin/seal-home-* dist/bin/checksums.txt; do
[ -f "$file" ] || continue
upload_asset "$file" &
pids+=($!)
done
# Wait for all parallel uploads to complete
for pid in "${pids[@]}"; do
wait "$pid" || true
done
echo "✓ Successfully published release assets to Gitea!"