|
3 | 3 | # FontManager.xcframework release. |
4 | 4 | # |
5 | 5 | # Triggered automatically at the end of the SPM Release workflow, or manually |
6 | | -# via workflow_dispatch. Requires an NPM_TOKEN secret with publish rights to |
7 | | -# @nativescript/font-manager. |
| 6 | +# via workflow_dispatch. |
| 7 | +# |
| 8 | +# Authentication uses npm Trusted Publishing (OIDC) — no NPM_TOKEN required. |
| 9 | +# The `id-token: write` permission below lets the npm CLI (>= 11.5.1) exchange a |
| 10 | +# short-lived GitHub OIDC token for publish rights. The Trusted Publisher must be |
| 11 | +# configured on npmjs.com for this repo + workflow file (npm_release.yml). |
8 | 12 | name: npm Release |
9 | 13 |
|
10 | 14 | on: |
|
17 | 21 |
|
18 | 22 | permissions: |
19 | 23 | contents: read |
20 | | - id-token: write # npm provenance |
| 24 | + id-token: write # required for npm Trusted Publishing (OIDC) + provenance |
21 | 25 |
|
22 | 26 | concurrency: |
23 | 27 | group: npm-release |
@@ -52,14 +56,34 @@ jobs: |
52 | 56 | node-version: 22 |
53 | 57 | registry-url: 'https://registry.npmjs.org' |
54 | 58 |
|
| 59 | + # Node 22 ships npm ~10.x; Trusted Publishing requires npm >= 11.5.1. |
| 60 | + - name: Upgrade npm for Trusted Publishing |
| 61 | + run: npm install -g npm@latest |
| 62 | + |
55 | 63 | - name: Install dependencies |
56 | 64 | run: npm ci |
57 | 65 |
|
58 | | - - name: Build and publish @nativescript/font-manager |
59 | | - env: |
60 | | - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
61 | | - NPM_CONFIG_PROVENANCE: true |
62 | | - run: npx nx g @nativescript/plugin-tools:publish font-manager --version="${{ steps.version.outputs.version }}" --verify --no-interactive |
| 66 | + - name: Verify package.json matches release version |
| 67 | + run: | |
| 68 | + VERSION="${{ steps.version.outputs.version }}" |
| 69 | + PKG_VERSION="$(node -p "require('./packages/font-manager/package.json').version")" |
| 70 | + if [ "$PKG_VERSION" != "$VERSION" ]; then |
| 71 | + echo "error: packages/font-manager/package.json is $PKG_VERSION but expected $VERSION" >&2 |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | +
|
| 75 | + # build.all runs tools/scripts/build-finish.ts, which produces a |
| 76 | + # ready-to-publish dist/packages/font-manager (cleaned package.json, |
| 77 | + # publishing assets copied in). |
| 78 | + - name: Build @nativescript/font-manager |
| 79 | + run: npx nx run font-manager:build.all |
| 80 | + |
| 81 | + # Publish the exact version from the release tag. No token env is set — |
| 82 | + # the npm CLI authenticates via OIDC (Trusted Publishing) and generates |
| 83 | + # provenance automatically. |
| 84 | + - name: Publish @nativescript/font-manager |
| 85 | + working-directory: dist/packages/font-manager |
| 86 | + run: npm publish --access public --provenance |
63 | 87 |
|
64 | 88 | - name: Verify npm publish |
65 | 89 | run: | |
|
0 commit comments