Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 2

Publish NPM package

Solved! Go to Solution.

Hi! I have Node.js project and I want to publish it to npm registry when I create a new release on GitHub.

But when I try to do it with yarn, I've got this error:

 

No token found and can't prompt for login when running with --non-interactive.

 

So I tried to do it with npm, but again error: "Unauthorized".

 

And another thing: how can it now the next version? Can I somehow get it from GitHub release? I know I can updated it to next fix version, but what if I want to do minor / major update?

1 Reply
Solution
Copilot Lvl 2
Message 2 of 2

Re: Publish NPM package

If anyone would ancounter the same problem, here is the solution:

 

In $GITHUB_REF env variable is reference to the release version in format "refs/tags/<tag>". You can remove the prefix and pass the version to publish command:

 

run: yarn publish --new-version ${GITHUB_REF#"refs/tags/"}

 

It will publish the new version, but still ends with error. It is because it tries to also create a commit, but git needs your name and email to do it.

 

Exit code: 128
Command: git
Arguments: commit -m v2.3.16
Directory: /home/runner/work/pentest-tool-lite/pentest-tool-lite
Output:
*** Please tell me who you are.

Run
  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <id>) not allowed

You can either set the user email and name before the command or you can add --no-git-tag-version parameter for yarn publish command. The final publish command then looks like this:

 

run: yarn publish --new-version ${GITHUB_REF#"refs/tags/"} --no-git-tag-version