Skip to content

Commit 901a0b7

Browse files
committed
ci(npm-publish): rework auth using actions/setup-node
1 parent 5f0c6d4 commit 901a0b7

File tree

1 file changed

+10
-5
lines changed
  • .github/workflows/actions/publish-npm-package

1 file changed

+10
-5
lines changed

.github/workflows/actions/publish-npm-package/action.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ inputs:
2323
runs:
2424
using: "composite"
2525
steps:
26+
- uses: actions/setup-node@v6
27+
with:
28+
node-version: 'lts/*'
29+
package-manager-cache: 'false'
30+
# Note: setting up the registry allows auth to be passed via env.NODE_AUTH_TOKEN
31+
registry-url: https://registry.npmjs.org
32+
2633
- name: Prepare
2734
id: prepare
2835
run: |
@@ -99,11 +106,10 @@ runs:
99106
shell: bash
100107
working-directory: ${{ inputs.package_dir }}
101108
env:
102-
NPM_TOKEN: ${{ inputs.api_token }}
109+
NODE_AUTH_TOKEN: ${{ inputs.api_token }}
103110
run: |
104111
echo "Publish '${{ steps.prepare.outputs.package_name }}"' package"
105-
npm set "//registry.npmjs.org/:_authToken=${NPM_TOKEN}"
106-
if [ -z "${NPM_TOKEN}" -a "${{ inputs.dry_run }}" == "true" ]; then
112+
if [ -z "${NODE_AUTH_TOKEN}" -a "${{ inputs.dry_run }}" == "true" ]; then
107113
echo "Warning: An NPM access token is required for authentication and has not been provided."
108114
else
109115
npm whoami
@@ -121,10 +127,9 @@ runs:
121127
shell: bash
122128
working-directory: ${{ inputs.package_dir }}
123129
env:
124-
NPM_TOKEN: ${{ inputs.api_token }}
130+
NODE_AUTH_TOKEN: ${{ inputs.api_token }}
125131
run: |
126132
echo "Promote '${{ steps.prepare.outputs.package_name }}' package version '${{ steps.prepare.outputs.package_local_version }}' from 'next' to 'latest'"
127-
npm set "//registry.npmjs.org/:_authToken=${NPM_TOKEN}"
128133
npm whoami
129134
npm dist-tag add ${{ steps.prepare.outputs.package_name }}"@${{ steps.prepare.outputs.package_local_version }} latest
130135
npm dist-tag rm ${{ steps.prepare.outputs.package_name }}"@${{ steps.prepare.outputs.package_local_version }} next

0 commit comments

Comments
 (0)