Skip to content

Commit 2c37106

Browse files
committed
fix: npm publishing and package binary path
- Restore NPM_TOKEN secret support in the release workflow to enable traditional automated publishing. - Correct the bin path in package.json by removing the leading relative prefix for better environment compatibility. - Update CI publish logic to manually configure registry and auth tokens, providing a more robust fallback for Trusted Publishing.
1 parent 3c11320 commit 2c37106

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
permissions:
99
contents: read
10-
id-token: write # Required for NPM Trusted Publishing
10+
id-token: write # Required for provenance / (optional) NPM Trusted Publishing
1111

1212
jobs:
1313
publish:
@@ -19,21 +19,25 @@ jobs:
1919
uses: actions/setup-node@v4
2020
with:
2121
node-version: '20'
22-
registry-url: 'https://registry.npmjs.org'
2322

2423
- name: Install dependencies
2524
run: yarn install
2625

2726
- name: Build project
2827
run: yarn build
2928

30-
- name: Publish to NPM (Trusted Publishing)
31-
# It will only publish if the version in package.json is new
32-
# Note: Trusted Publishing requires permissions: id-token: write
29+
- name: Publish to NPM
30+
# It will only publish if the version in package.json is new.
31+
# Publish auth:
32+
# - Recommended: set repo secret NPM_TOKEN (an npm "Automation" token with publish access).
33+
# - Optional: if you've configured NPM Trusted Publishing for this package, it can publish without NPM_TOKEN.
34+
env:
35+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3336
run: |
34-
# modifying the .npmrc created by setup-node to remove the invalid auth token
35-
# but keeping the registry configuration
36-
sed -i '/_authToken/d' "$NPM_CONFIG_USERCONFIG"
37+
npm config set registry "https://registry.npmjs.org/"
38+
if [ -n "${NODE_AUTH_TOKEN:-}" ]; then
39+
npm config set //registry.npmjs.org/:_authToken "$NODE_AUTH_TOKEN"
40+
fi
3741
3842
PACKAGE_NAME=$(node -p "require('./package.json').name")
3943
PACKAGE_VERSION=$(node -p "require('./package.json').version")

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dist"
88
],
99
"bin": {
10-
"docusaurus-docs-to-pdf": "./dist/main.js"
10+
"docusaurus-docs-to-pdf": "dist/main.js"
1111
},
1212
"repository": {
1313
"type": "git",

0 commit comments

Comments
 (0)