|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ['v[0-9]*', '[0-9]*'] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: release-${{ github.ref }} |
| 12 | + cancel-in-progress: false |
| 13 | + |
| 14 | +jobs: |
| 15 | + package: |
| 16 | + name: Build and verify release package |
| 17 | + runs-on: ubuntu-latest |
| 18 | + timeout-minutes: 15 |
| 19 | + outputs: |
| 20 | + prerelease: ${{ steps.version.outputs.prerelease }} |
| 21 | + filename: ${{ steps.package.outputs.filename }} |
| 22 | + steps: |
| 23 | + - name: Check out the tag |
| 24 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 25 | + with: |
| 26 | + persist-credentials: false |
| 27 | + - name: Set up Node.js |
| 28 | + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 |
| 29 | + with: |
| 30 | + node-version: 22 |
| 31 | + cache: npm |
| 32 | + - name: Install dependencies |
| 33 | + run: npm ci |
| 34 | + - name: Verify package version matches tag |
| 35 | + id: version |
| 36 | + env: |
| 37 | + RELEASE_TAG: ${{ github.ref_name }} |
| 38 | + run: node scripts/release-version.mjs "$RELEASE_TAG" |
| 39 | + - name: Lint, typecheck, test, and build |
| 40 | + run: npm run check |
| 41 | + - name: Pack and verify installation |
| 42 | + id: package |
| 43 | + run: npm run package:check -- "$RUNNER_TEMP/release" |
| 44 | + - name: Upload verified release files |
| 45 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 46 | + with: |
| 47 | + name: release-package |
| 48 | + path: | |
| 49 | + ${{ runner.temp }}/release/*.tgz |
| 50 | + ${{ runner.temp }}/release/*.sha256 |
| 51 | + if-no-files-found: error |
| 52 | + retention-days: 7 |
| 53 | + |
| 54 | + publish: |
| 55 | + name: Publish GitHub Release |
| 56 | + needs: package |
| 57 | + runs-on: ubuntu-latest |
| 58 | + timeout-minutes: 5 |
| 59 | + permissions: |
| 60 | + contents: write |
| 61 | + steps: |
| 62 | + - name: Download verified release files |
| 63 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 64 | + with: |
| 65 | + name: release-package |
| 66 | + path: release |
| 67 | + - name: Create release with package and checksum |
| 68 | + working-directory: release |
| 69 | + env: |
| 70 | + GH_TOKEN: ${{ github.token }} |
| 71 | + RELEASE_TAG: ${{ github.ref_name }} |
| 72 | + PRERELEASE: ${{ needs.package.outputs.prerelease }} |
| 73 | + PACKAGE_FILE: ${{ needs.package.outputs.filename }} |
| 74 | + run: | |
| 75 | + sha256sum --check "$PACKAGE_FILE.sha256" |
| 76 | + args=(--repo "$GITHUB_REPOSITORY" --verify-tag --title "$RELEASE_TAG" --generate-notes) |
| 77 | + if [[ "$PRERELEASE" == "true" ]]; then |
| 78 | + args+=(--prerelease --latest=false) |
| 79 | + fi |
| 80 | + gh release create "$RELEASE_TAG" "$PACKAGE_FILE" "$PACKAGE_FILE.sha256" "${args[@]}" |
0 commit comments