Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish action fails since version 0.3.0 #19

Open
tumbichi opened this issue Oct 24, 2024 · 0 comments
Open

Publish action fails since version 0.3.0 #19

tumbichi opened this issue Oct 24, 2024 · 0 comments

Comments

@tumbichi
Copy link

tumbichi commented Oct 24, 2024

I suspect that NPM_TOKEN has expired or there are some problem autheticating, here in gh action (https://github.com/Twirelab/nestjs-auth0/actions/runs/11192438265/job/31116600762) log a code ENEEDAUTH. Maybe adding two lines in .github/workflows/publish.yml works:

name: "Publish package"

on:
  release:
    types:
      - "published"

jobs:
  test:
    runs-on: ubuntu-latest
    env: # load token from secrets
      NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 
    steps:
      - name: "Checkout"
        uses: actions/checkout@v3
      - name: "Use Node.js"
        uses: actions/setup-node@v3
        with:
          node-version: 20
          cache: "npm"
      - name: "Setup NPM_TOKEN" 
        run: echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> .npmrc # add this line in .npmro to authenticate when publish
      - name: "Install packages"
        run: npm install
      - name: "Build package"
        run: npm run build
      - name: "Publish package"
        run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

(I have added the step before of "Install packages" step but it can go after the "Build package" step as well)

In the package.json i saw the publishConfig that replace the .npmrc but i don't see a config to load the token, in the offical documentation is using setup-node@v4. In this step, looks that .npmrc is setuped automatically and in the with atribute set the npm registry url.

And a third posible solution can be set de NPM_TOKEN for the npm registry using npm config as in this article (npm publish ci/cd pipeline)

Publish node package with CI documentation
Using private packages in a CI/CD workflow

If you need help to fix it, I'll be happy to help you.

UPDATE: I made a PR here #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant