Skip to content

Commit f81de5d

Browse files
committed
ci(publish): enhance npm Trusted Publishers workflow with provenance and config cleanup
Add provenance flag for npm publish to enable package attestation and remove conflicting .npmrc files that may interfere with OIDC authentication. Includes debug logging for npm configuration and version information to aid troubleshooting. 这个提交增强了 npm Trusted Publishers 工作流程,添加了来源证明功能并清理了配置文件。 为 npm publish 添加了 provenance 标志以启用包证明,并删除了可能干扰 OIDC 身份验证的 冲突 .npmrc 文件。包含了 npm 配置和版本信息的调试日志以帮助故障排除。 Change-Id: I9ffba9ff52e5c025441df0a90a45386876bb3e7b Signed-off-by: OhYee <[email protected]>
1 parent ca0666e commit f81de5d

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

.github/workflows/publish.yaml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,20 @@ jobs:
124124
PACKAGE_NAME="${{ steps.version.outputs.PACKAGE_NAME }}"
125125
VERSION="${{ steps.version.outputs.VERSION }}"
126126
echo "Publishing ${PACKAGE_NAME}@${VERSION} with tag=test"
127-
npm publish --tag test --access public
128-
env:
129-
# Unset NODE_AUTH_TOKEN to force npm to use OIDC authentication
130-
# Organization may have NPM_TOKEN configured, but we want Trusted Publishers
131-
NODE_AUTH_TOKEN: ''
127+
128+
# Remove any .npmrc that might interfere with OIDC
129+
rm -f ~/.npmrc
130+
rm -f .npmrc
131+
rm -f /home/runner/work/_temp/.npmrc
132+
133+
# Debug: show npm config
134+
echo "=== npm config ==="
135+
npm config list
136+
echo "=== npm version ==="
137+
npm --version
138+
139+
# Publish using Trusted Publishers (OIDC)
140+
npm publish --tag test --access public --provenance
132141
133142
- name: Summary
134143
run: |
@@ -266,11 +275,14 @@ jobs:
266275
PACKAGE_NAME="${{ steps.config.outputs.PACKAGE_NAME }}"
267276
VERSION="${{ steps.config.outputs.VERSION }}"
268277
echo "Publishing ${PACKAGE_NAME}@${VERSION} with tag=latest"
269-
npm publish --tag latest --access public
270-
env:
271-
# Unset NODE_AUTH_TOKEN to force npm to use OIDC authentication
272-
# Organization may have NPM_TOKEN configured, but we want Trusted Publishers
273-
NODE_AUTH_TOKEN: ''
278+
279+
# Remove any .npmrc that might interfere with OIDC
280+
rm -f ~/.npmrc
281+
rm -f .npmrc
282+
rm -f /home/runner/work/_temp/.npmrc
283+
284+
# Publish using Trusted Publishers (OIDC)
285+
npm publish --tag latest --access public --provenance
274286
275287
- name: Summary
276288
run: |
@@ -356,11 +368,14 @@ jobs:
356368
PACKAGE_NAME="${{ steps.version.outputs.PACKAGE_NAME }}"
357369
VERSION="${{ steps.version.outputs.VERSION }}"
358370
echo "Publishing ${PACKAGE_NAME}@${VERSION} with tag=test"
359-
npm publish --tag test --access public
360-
env:
361-
# Unset NODE_AUTH_TOKEN to force npm to use OIDC authentication
362-
# Organization may have NPM_TOKEN configured, but we want Trusted Publishers
363-
NODE_AUTH_TOKEN: ''
371+
372+
# Remove any .npmrc that might interfere with OIDC
373+
rm -f ~/.npmrc
374+
rm -f .npmrc
375+
rm -f /home/runner/work/_temp/.npmrc
376+
377+
# Publish using Trusted Publishers (OIDC)
378+
npm publish --tag test --access public --provenance
364379
365380
- name: Summary
366381
run: |

0 commit comments

Comments
 (0)