Skip to content

Commit

Permalink
Use literal ${NPM_TOKEN} in npm auth
Browse files Browse the repository at this point in the history
This is not supposed to be the token, but the literal value that is then
replaced by npm.

Probably does not make a difference, but the docs are clear on *not*
putting a token in this file.

The docs also say to put it in the project root.

Also adding some lines to debug what runs.
  • Loading branch information
code-asher committed Nov 6, 2024
1 parent 344df38 commit a9b2872
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ci/steps/publish-npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ main() {

# This allows us to publish to npm in CI workflows
if [[ ${CI-} ]]; then
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
echo "Adding NPM_TOKEN to .npmrc"
# This is meant to be the literal value of ${NPM_TOKEN}, not the actual
# token itself.
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> .npmrc
fi

## Environment
Expand Down Expand Up @@ -142,6 +145,7 @@ main() {

# Since the dev builds are scoped to @coder
# We pass --access public to ensure npm knows it's not private.
echo "Publishing version $NPM_VERSION with tag $NPM_TAG"
npm publish --non-interactive release --tag "$NPM_TAG" --access public
}

Expand Down

0 comments on commit a9b2872

Please sign in to comment.