|
1 | 1 | name: Release |
| 2 | + |
2 | 3 | on: |
3 | 4 | push: |
4 | 5 | branches: [main] |
5 | | - workflow_dispatch: |
| 6 | + workflow_dispatch: # Manual trigger |
| 7 | + |
| 8 | +env: |
| 9 | + HUSKY_SKIP: true |
| 10 | + |
| 11 | +# Skip when the head commit is the workflow's own version-bump commit, to avoid loops. |
| 12 | +concurrency: |
| 13 | + group: release-${{ github.ref }} |
| 14 | + cancel-in-progress: false |
6 | 15 |
|
7 | 16 | permissions: |
8 | | - contents: read |
9 | | - id-token: write |
| 17 | + contents: write # create the "Version Packages" PR and tags |
| 18 | + pull-requests: write # open/update the version PR |
| 19 | + id-token: write # REQUIRED for npm OIDC trusted publishing |
10 | 20 |
|
11 | 21 | jobs: |
12 | 22 | release: |
13 | 23 | runs-on: ubuntu-latest |
14 | | - # Only gate push events by commit message; allow workflow_dispatch always |
15 | | - if: > |
16 | | - github.event_name == 'workflow_dispatch' || |
17 | | - (github.event_name == 'push' && contains(github.event.head_commit.message, 'chore(release): publish')) |
| 24 | + if: github.event_name != 'push' || !contains(github.event.head_commit.message, 'skip ci') |
18 | 25 | steps: |
19 | | - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 |
20 | 28 | with: |
21 | 29 | fetch-depth: 0 |
22 | 30 |
|
23 | | - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 31 | + - name: Setup node |
| 32 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
24 | 33 | with: |
25 | 34 | node-version: 24.15.0 |
| 35 | + registry-url: https://registry.npmjs.org |
26 | 36 |
|
27 | 37 | - name: Install dependencies |
28 | | - run: yarn |
| 38 | + run: yarn --frozen-lockfile |
29 | 39 |
|
30 | 40 | - name: Build |
31 | 41 | run: yarn build |
32 | 42 |
|
33 | | - # Choose publish command based on the event type |
34 | | - - name: Publish to NPM (push) |
35 | | - if: github.event_name == 'push' |
36 | | - run: npm run release:publish |
| 43 | + - name: Detect auth mode (OIDC vs token) |
| 44 | + env: |
| 45 | + NPM_BOOTSTRAP_TOKEN: ${{ secrets.NPM_BOOTSTRAP_TOKEN }} |
| 46 | + run: | |
| 47 | + if [ -n "$NPM_BOOTSTRAP_TOKEN" ]; then |
| 48 | + echo "::warning::NPM bootstrap token is configured; token-based auth will be used (OIDC will not be exercised)." |
| 49 | + else |
| 50 | + echo "No NPM bootstrap token configured; using OIDC trusted publishing." |
| 51 | + fi |
37 | 52 |
|
38 | | - - name: Publish to NPM (manual) |
39 | | - if: github.event_name == 'workflow_dispatch' |
40 | | - run: npm run release:publish-manual |
| 53 | + - name: Configure NPM bootstrap token (non OIDC flow) |
| 54 | + env: |
| 55 | + NPM_BOOTSTRAP_TOKEN: ${{ secrets.NPM_BOOTSTRAP_TOKEN }} |
| 56 | + if: ${{ env.NPM_BOOTSTRAP_TOKEN != '' }} |
| 57 | + run: | |
| 58 | + echo "//registry.npmjs.org/:_authToken=${NPM_BOOTSTRAP_TOKEN}" >> ~/.npmrc |
| 59 | +
|
| 60 | + - name: Create Release Pull Request or Publish |
| 61 | + id: changesets |
| 62 | + uses: changesets/action@63a615b9cd06ba9a3e6d13796c7fbcb080a60a0b # v1.8.0 |
| 63 | + with: |
| 64 | + version: yarn run version-packages |
| 65 | + publish: yarn run release-publish |
| 66 | + commit: "chore(release): publish" |
| 67 | + title: "chore(release): publish" |
| 68 | + env: |
| 69 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_BOOTSTRAP_TOKEN }} |
| 71 | + NPM_CONFIG_PROVENANCE: "true" |
0 commit comments