Reputation: 5761
I'm trying to publish a new package to npm, public.
I have the following workflow:
# This workflow will run tests using node and then publish a package to GitHub
Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
name: Node.js Package
on:
release:
types: [created]
jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm login
- run: npm config set access public
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
But I get the following error:
npm notice
npm notice 📦 @orgname/[email protected]
npm notice === Tarball Contents ===
npm notice 135B Dockerfile
npm notice 135B Dockerfile12
npm notice 1.1kB LICENSE
npm notice 6.8kB index.js
npm notice 5.9kB tests/test-main.js
npm notice 530B package.json
npm notice 2.1kB README.md
npm notice 325.2kB tests/test.pdf
npm notice 1.1kB .github/workflows/node.js.yml
npm notice 664B .github/workflows/npm-publish.yml
npm notice === Tarball Details ===
npm notice name: @orgname/pdf-image
npm notice version: 1.2.2
npm notice package size: 322.6 kB
npm notice unpacked size: 343.6 kB
npm notice shasum: d362e3a6c95d12b2329ed608495c45580bb8de15
npm notice integrity: sha512-OpurprtbmR7By[...]V553ykjYtaOrA==
npm notice total files: 10
npm notice
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/@orgname%2fpdf-image - Not found
npm ERR! 404
npm ERR! 404 '@orgname/[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
Please advise how can I resolve this issue.
Upvotes: 1
Views: 1159
Reputation: 1573
npm login
is unnecessary here.
You need to do 3 steps to make it work:
Config the job on your yml
file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Define NPM_TOKEN
access token in your npmjs
account under access tokens, make sure it's an automation token:
Upvotes: 1