|
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - master |
| 7 | + pull_request: |
| 8 | + types: [closed] |
| 9 | + branches: |
| 10 | + - master |
7 | 11 |
|
8 | 12 | concurrency: ${{ github.workflow }}-${{ github.ref }} |
9 | 13 |
|
10 | 14 | jobs: |
11 | | - release: |
12 | | - name: Release |
| 15 | + # Job 1: Create/update Version PR (on push to master) |
| 16 | + version: |
| 17 | + if: github.event_name == 'push' |
| 18 | + name: Create Version PR |
13 | 19 | runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + contents: write |
| 22 | + pull-requests: write |
14 | 23 | steps: |
15 | 24 | - name: Checkout Repo |
16 | 25 | uses: actions/checkout@v4 |
17 | 26 | with: |
18 | 27 | # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits |
19 | 28 | fetch-depth: 0 |
20 | 29 |
|
21 | | - # v18 node |
22 | | - - name: Setup Node.js lts/hydrogen |
23 | | - uses: actions/setup-node@v2 |
| 30 | + - name: Setup Node.js |
| 31 | + uses: actions/setup-node@v4 |
24 | 32 | with: |
25 | | - node-version: lts/hydrogen |
| 33 | + node-version: 22 |
26 | 34 |
|
27 | 35 | - name: Install Dependencies |
28 | 36 | run: npm i |
29 | 37 |
|
30 | | - - name: Create Release Pull Request or Publish to npm |
31 | | - id: changesets |
| 38 | + - name: Create Release Pull Request |
| 39 | + uses: changesets/action@v1 |
| 40 | + with: |
| 41 | + title: "Version Packages" |
| 42 | + commit: "Version Packages" |
| 43 | + env: |
| 44 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + |
| 46 | + # Job 2: Publish to npm (when Version PR is merged) |
| 47 | + publish: |
| 48 | + if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'Version Packages') |
| 49 | + name: Publish to npm |
| 50 | + runs-on: ubuntu-latest |
| 51 | + permissions: |
| 52 | + id-token: write |
| 53 | + contents: write |
| 54 | + steps: |
| 55 | + - name: Checkout Repo |
| 56 | + uses: actions/checkout@v4 |
| 57 | + with: |
| 58 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + fetch-depth: 0 |
| 60 | + |
| 61 | + - name: Setup Node.js |
| 62 | + uses: actions/setup-node@v4 |
| 63 | + with: |
| 64 | + node-version: 22 |
| 65 | + registry-url: "https://registry.npmjs.org" |
| 66 | + |
| 67 | + - name: Upgrade npm for OIDC support |
| 68 | + run: npm install -g npm@latest |
| 69 | + |
| 70 | + - name: Install Dependencies |
| 71 | + run: npm i |
| 72 | + |
| 73 | + - name: Build packages |
| 74 | + run: npm run build |
| 75 | + |
| 76 | + - name: Publish to npm |
32 | 77 | uses: changesets/action@v1 |
33 | 78 | with: |
34 | | - # This expects you to have a script called release which does a build for your packages and calls changeset publish |
35 | | - publish: npm run release |
| 79 | + publish: npx changeset publish |
36 | 80 | env: |
37 | 81 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
38 | | - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 82 | + # Clear tokens to allow OIDC authentication |
| 83 | + # https://github.com/orgs/community/discussions/176761 |
| 84 | + # https://github.com/changesets/changesets/issues/1152 |
| 85 | + NODE_AUTH_TOKEN: "" |
| 86 | + NPM_TOKEN: "" |
0 commit comments