|
1 | 1 | name: Publish Package |
2 | 2 |
|
3 | 3 | on: |
4 | | - release: |
5 | | - types: |
6 | | - - published |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
7 | 7 |
|
8 | 8 | permissions: |
| 9 | + id-token: write # Required for OIDC |
9 | 10 | contents: read |
10 | | - id-token: write |
11 | 11 |
|
12 | 12 | jobs: |
13 | 13 | publish: |
14 | | - if: ${{ github.event.release.prerelease == false }} |
15 | 14 | runs-on: ubuntu-latest |
16 | 15 | steps: |
17 | | - - name: Checkout repository |
18 | | - uses: actions/checkout@v4 |
19 | | - with: |
20 | | - fetch-depth: 0 |
| 16 | + - uses: actions/checkout@v4 |
21 | 17 |
|
22 | | - - name: Set up Node.js |
23 | | - uses: actions/setup-node@v4 |
| 18 | + - uses: actions/setup-node@v4 |
24 | 19 | with: |
25 | 20 | node-version: "20" |
26 | 21 | registry-url: "https://registry.npmjs.org" |
27 | | - scope: "@willwade" |
28 | | - |
29 | | - - name: Install dependencies |
30 | | - run: npm ci |
31 | | - |
32 | | - - name: Build |
33 | | - run: npm run build |
34 | | - |
35 | | - - name: Derive release version |
36 | | - id: release_version |
37 | | - env: |
38 | | - RELEASE_TAG: ${{ github.event.release.tag_name }} |
39 | | - run: | |
40 | | - VERSION="${RELEASE_TAG#refs/tags/}" |
41 | | - VERSION="${VERSION#v}" |
42 | | - if [[ -z "$VERSION" ]]; then |
43 | | - echo "Unable to determine version from release tag '${RELEASE_TAG}'" >&2 |
44 | | - exit 1 |
45 | | - fi |
46 | | - echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
47 | | -
|
48 | | - - name: Sync package metadata |
49 | | - run: | |
50 | | - npm version "${{ steps.release_version.outputs.version }}" --no-git-tag-version |
51 | | -
|
52 | | - - name: Get OIDC token |
53 | | - id: oidc |
54 | | - uses: actions/github-script@v7 |
55 | | - with: |
56 | | - script: | |
57 | | - const token = await core.getIDToken('https://registry.npmjs.org'); |
58 | | - core.setOutput('token', token); |
59 | | -
|
60 | | - - name: Configure npm with OIDC token |
61 | | - run: | |
62 | | - npm config set //registry.npmjs.org/:_authToken "${{ steps.oidc.outputs.token }}" |
63 | | - npm config set @willwade:registry https://registry.npmjs.org/ |
64 | 22 |
|
65 | | - - name: Publish to npm (Trusted Publishing) |
66 | | - run: npm publish --access public --provenance |
| 23 | + # Ensure npm 11.5.1 or later is installed for proper OIDC support |
| 24 | + - name: Update npm |
| 25 | + run: npm install -g npm@latest |
67 | 26 |
|
68 | | - - name: Show npm debug log on failure |
69 | | - if: failure() |
70 | | - run: cat ~/.npm/_logs/*-debug-0.log | tail -100 |
| 27 | + - run: npm ci |
| 28 | + - run: npm run build --if-present |
| 29 | + - run: npm publish --access public |
0 commit comments