Files
testing-tool/.github/workflows/release.yml
T
2026-05-21 19:52:44 +08:00

82 lines
2.5 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
# ── Phase 1: 复用 CI 全量检查 ────────────────────────────────
ci:
uses: ./.github/workflows/ci.yml
# ── Phase 2: 打包 & 发布 ─────────────────────────────────────
release:
name: Package & Release
runs-on: ubuntu-latest
needs: [ci]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Package Chrome extension
run: npm run zip
- name: Package Firefox extension
run: npm run zip:firefox
- name: Find zip artifacts
id: find_zips
run: |
CHROME_ZIP=$(find .output -name "*.zip" | grep -v firefox | head -1)
FIREFOX_ZIP=$(find .output -name "*.zip" | grep firefox | head -1)
echo "chrome_zip=$CHROME_ZIP" >> "$GITHUB_OUTPUT"
echo "firefox_zip=$FIREFOX_ZIP" >> "$GITHUB_OUTPUT"
echo "Found Chrome zip: $CHROME_ZIP"
echo "Found Firefox zip: $FIREFOX_ZIP"
- name: Verify zip artifacts
run: |
if [ -z "$CHROME_ZIP" ] || [ ! -f "$CHROME_ZIP" ]; then
echo "❌ Chrome zip not found"
exit 1
fi
echo "✅ Chrome zip: $(ls -lh "$CHROME_ZIP" | awk '{print $5}')"
if [ -z "$FIREFOX_ZIP" ] || [ ! -f "$FIREFOX_ZIP" ]; then
echo "❌ Firefox zip not found"
exit 1
fi
echo "✅ Firefox zip: $(ls -lh "$FIREFOX_ZIP" | awk '{print $5}')"
env:
CHROME_ZIP: ${{ steps.find_zips.outputs.chrome_zip }}
FIREFOX_ZIP: ${{ steps.find_zips.outputs.firefox_zip }}
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: "v${{ steps.version.outputs.version }}"
tag_name: ${{ github.ref_name }}
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
generate_release_notes: true
files: |
${{ steps.find_zips.outputs.chrome_zip }}
${{ steps.find_zips.outputs.firefox_zip }}