|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + type: string |
| 8 | + description: 'Release version (e.g., 1.0.0)' |
| 9 | + required: true |
| 10 | + prerelease: |
| 11 | + type: boolean |
| 12 | + default: false |
| 13 | + description: 'Mark as prerelease' |
| 14 | + dryRun: |
| 15 | + type: boolean |
| 16 | + default: false |
| 17 | + description: 'Build and zip only, skip release and git push' |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: write |
| 21 | + |
| 22 | +jobs: |
| 23 | + release: |
| 24 | + name: Build & Release |
| 25 | + runs-on: ubuntu-24.04 |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - name: Setup Node.js |
| 33 | + uses: actions/setup-node@v4 |
| 34 | + with: |
| 35 | + node-version: 24 |
| 36 | + cache: 'pnpm' |
| 37 | + |
| 38 | + - name: Enable Corepack |
| 39 | + run: corepack enable |
| 40 | + |
| 41 | + - name: Validate version |
| 42 | + run: | |
| 43 | + if ! echo "${{ inputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then |
| 44 | + echo "Error: Version must be in semver format (e.g., 1.0.0)" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | +
|
| 48 | + - name: Configure Git |
| 49 | + run: | |
| 50 | + git config user.email "github-actions@users.noreply.github.com" |
| 51 | + git config user.name "GitHub Actions" |
| 52 | +
|
| 53 | + - name: Install dependencies |
| 54 | + run: pnpm install --frozen-lockfile |
| 55 | + |
| 56 | + - name: Update version |
| 57 | + run: pnpm version ${{ inputs.version }} --no-git-tag-version |
| 58 | + |
| 59 | + - name: Type check |
| 60 | + run: pnpm compile |
| 61 | + |
| 62 | + - name: Check formatting |
| 63 | + run: pnpm fmt:check |
| 64 | + |
| 65 | + - name: Zip extensions |
| 66 | + run: | |
| 67 | + pnpm zip |
| 68 | + pnpm zip:firefox |
| 69 | +
|
| 70 | + - name: Generate changelog |
| 71 | + run: pnpm dlx changelogen@latest > CHANGELOG.md |
| 72 | + |
| 73 | + - name: Verify zip files |
| 74 | + run: ls -la .output/*-chrome.zip .output/*-firefox.zip |
| 75 | + |
| 76 | + - name: Commit and tag |
| 77 | + if: ${{ !inputs.dryRun }} |
| 78 | + run: | |
| 79 | + git add package.json CHANGELOG.md |
| 80 | + git commit -m "chore(release): v${{ inputs.version }}" |
| 81 | + git tag v${{ inputs.version }} |
| 82 | + git push |
| 83 | + git push --tags |
| 84 | +
|
| 85 | + - name: Create GitHub Release |
| 86 | + if: ${{ !inputs.dryRun }} |
| 87 | + run: | |
| 88 | + gh release create v${{ inputs.version }} \ |
| 89 | + .output/*-chrome.zip \ |
| 90 | + .output/*-firefox.zip \ |
| 91 | + --title "v${{ inputs.version }}" \ |
| 92 | + --notes-file CHANGELOG.md \ |
| 93 | + ${{ inputs.prerelease && '--prerelease' || '' }} |
| 94 | + env: |
| 95 | + GH_TOKEN: ${{ github.token }} |
0 commit comments