|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: Version bump type |
| 8 | + required: true |
| 9 | + default: patch |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - patch |
| 13 | + - minor |
| 14 | + - major |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: write |
| 18 | + id-token: write |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: release |
| 22 | + cancel-in-progress: false |
| 23 | + |
| 24 | +jobs: |
| 25 | + release: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout |
| 30 | + uses: actions/checkout@v6 |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
| 33 | + |
| 34 | + - name: Validate release ref |
| 35 | + run: | |
| 36 | + if [ "${GITHUB_REF_TYPE}" != "branch" ]; then |
| 37 | + echo "Release workflow must run from a branch." |
| 38 | + exit 1 |
| 39 | + fi |
| 40 | +
|
| 41 | + - name: Setup Node.js |
| 42 | + uses: actions/setup-node@v6 |
| 43 | + with: |
| 44 | + node-version: 24 |
| 45 | + registry-url: https://registry.npmjs.org |
| 46 | + package-manager-cache: false |
| 47 | + |
| 48 | + - name: Enable Corepack |
| 49 | + run: corepack enable |
| 50 | + |
| 51 | + - name: Install dependencies |
| 52 | + run: yarn install --frozen-lockfile |
| 53 | + |
| 54 | + - name: Run tests |
| 55 | + run: yarn test --run |
| 56 | + |
| 57 | + - name: Check types |
| 58 | + run: yarn typecheck |
| 59 | + |
| 60 | + - name: Build package |
| 61 | + run: yarn build |
| 62 | + |
| 63 | + - name: Configure Git |
| 64 | + run: | |
| 65 | + git config user.name "github-actions[bot]" |
| 66 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 67 | +
|
| 68 | + - name: Bump version |
| 69 | + id: version |
| 70 | + run: | |
| 71 | + npm version "${{ inputs.version }}" --no-git-tag-version |
| 72 | + version="$(node -p "require('./package.json').version")" |
| 73 | + echo "version=${version}" >> "${GITHUB_OUTPUT}" |
| 74 | + echo "tag=v${version}" >> "${GITHUB_OUTPUT}" |
| 75 | +
|
| 76 | + - name: Commit version and tag |
| 77 | + run: | |
| 78 | + git add package.json |
| 79 | + git commit -m "${{ steps.version.outputs.version }}" |
| 80 | + git tag -a "${{ steps.version.outputs.tag }}" -m "${{ steps.version.outputs.tag }}" |
| 81 | +
|
| 82 | + - name: Push version commit and tag |
| 83 | + run: git push origin "HEAD:${{ github.ref_name }}" --follow-tags |
| 84 | + |
| 85 | + - name: Publish to npm |
| 86 | + run: npm publish --provenance --access public |
| 87 | + |
| 88 | + - name: Create GitHub release |
| 89 | + env: |
| 90 | + GH_TOKEN: ${{ github.token }} |
| 91 | + run: | |
| 92 | + gh release create "${{ steps.version.outputs.tag }}" \ |
| 93 | + --verify-tag \ |
| 94 | + --title "${{ steps.version.outputs.tag }}" \ |
| 95 | + --generate-notes |
0 commit comments