Skip to content

Commit

Permalink
✨ feat: Fix publishing for private packages without .npmrc
Browse files Browse the repository at this point in the history
  • Loading branch information
honzabubenik committed Sep 30, 2024
1 parent aae9a87 commit 0631091
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,16 @@ runs:
- if: inputs.npm-publish == 'private'
run: |
NPM_TOKEN=${{ inputs.npm-token }}
NODE_VERSION=${{ inputs.node-version }}
NPMRC_AUTH_EXISTS=$(grep -c _auth .npmrc)
if [ ${NPMRC_AUTH_EXISTS:-0} == 0 ] && [ $NPM_TOKEN != '' ]; then npm config set _auth=$NPM_TOKEN --location=project; fi
if [ $NODE_VERSION == '20' ]
then
if [ ${NPMRC_AUTH_EXISTS:-0} == 0 ] && [ $NPM_TOKEN != '' ]; then npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN --location=project; fi
else
if [ ${NPMRC_AUTH_EXISTS:-0} == 0 ] && [ $NPM_TOKEN != '' ]; then npm config set _auth=$NPM_TOKEN --location=project; fi
fi
npm publish --registry=${{ inputs.npm-private-registry }}
rm .npmrc 2> /dev/null || true
git checkout .npmrc 2> /dev/null || true
Expand Down

0 comments on commit 0631091

Please sign in to comment.