setup-node: Unable to publish to GitHub Package Registry
I use the workflow you suggest, but the npm publish
action on GitHub Package Registry doesn’t work. On npmjs it works.
Workflow
name: publish
on: release
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
- run: npm test
# works
publish-npm:
name: Publish NPM
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
# doesn't work: tries to publish on https://registry.npmjs.org
publish-gpr:
name: Publish GitHub Packages
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
registry-url: 'https://npm.pkg.github.com'
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
npm publish on npmjs works. On gpr doesn’t. Follows the GitHub Action output of the publish-gpr job.
Run actions/setup-node@v1
with:
registry-url: https://npm.pkg.github.com
node-version: 10.x
in/tar xzC /home/runner/work/_temp/bc5bc42b-b229-41ac-b8a0-e554467f0c90 -f /home/runner/work/_temp/5cda4e3f-6051-4aaa-b41f-c4761c6cac12
##[add-path]/opt/hostedtoolcache/node/10.16.3/x64/bin
##[set-env name=NPM_CONFIG_USERCONFIG;]/home/runner/work/_temp/.npmrc
##[set-env name=NODE_AUTH_TOKEN;]XXXXX-XXXXX-XXXXX-XXXXX
Added matchers: 'tsc'. Problem matchers scan action output for known warning or error strings and report these inline.
##[add-matcher]/home/runner/work/_actions/actions/setup-node/v1/.github/tsc.json
Added matchers: 'eslint-stylish'. Problem matchers scan action output for known warning or error strings and report these inline.
##[add-matcher]/home/runner/work/_actions/actions/setup-node/v1/.github/eslint-stylish.json
Added matchers: 'eslint-compact'. Problem matchers scan action output for known warning or error strings and report these inline.
##[add-matcher]/home/runner/work/_actions/actions/setup-node/v1/.github/eslint-compact.json
Run npm publish
npm publish
shell: /bin/bash -e {0}
env:
NPM_CONFIG_USERCONFIG: /home/runner/work/_temp/.npmrc
NODE_AUTH_TOKEN: ***
npm notice [...]
npm notice total files: 18
npm notice
npm ERR! code E401
npm ERR! 401 Unauthorized - PUT https://registry.npmjs.org/https-localhost - You must be logged in to publish packages.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2019-09-04T13_02_57_793Z-debug.log
##[error]Process completed with exit code 1.
As you can see in Run actions/setup-node@v1 the registry-url is right, in Run npm publish is not.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 15
- Comments: 30 (2 by maintainers)
Commits related to this issue
- added registry https://github.com/actions/setup-node/issues/53 — committed to crawfordsolutions/mousetrap by crawfordsolutions 4 years ago
- added package https://github.com/actions/setup-node/issues/53 — committed to crawfordsolutions/mousetrap by crawfordsolutions 4 years ago
- testing reg change https://github.com/actions/setup-node/issues/53 — committed to crawfordsolutions/mousetrap by crawfordsolutions 4 years ago
- trying fix https://github.com/actions/setup-node/issues/53 — committed to crawfordsolutions/mousetrap by crawfordsolutions 4 years ago
- gpr fix https://github.com/actions/setup-node/issues/53#issuecomment-530840137 — committed to crawfordsolutions/mousetrap by crawfordsolutions 4 years ago
- config for git username https://github.com/actions/setup-node/issues/53#issuecomment-530566324 — committed to crawfordsolutions/mousetrap by crawfordsolutions 4 years ago
- chore(npm): Set project as private As a way to prevent accidental publication of private repositories. More: - https://github.com/actions/setup-node/issues/53 - https://docs.npmjs.com/files/package.... — committed to roalcantara/typescript-cli-boilerplate by roalcantara 4 years ago
- chore(npm): Set project as private As a way to prevent accidental publication of private repositories. More: - https://github.com/actions/setup-node/issues/53 - https://docs.npmjs.com/files/package.... — committed to roalcantara/typescript-cli-boilerplate by roalcantara 4 years ago
- chore(npm): Set project as private As a way to prevent accidental publication of private repositories. More: - https://github.com/actions/setup-node/issues/53 - https://docs.npmjs.com/files/package.... — committed to roalcantara/typescript-cli-boilerplate by roalcantara 4 years ago
- Don't attempt to publish to GitHub Packages (it doesn't work) Publishing to GPR always fails. According to https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/confi... — committed to ether/ep_adminpads2 by rhansen 4 years ago
- Change package name to scoped format; correct repository url format Thanks to this comment https://github.com/actions/setup-node/issues/53#issuecomment-556958898 — committed to qr-merger/merger by hifocus 4 years ago
- Merge pull request #53 from akamai/versionBumpCli update cli.json — committed to krzyk/setup-node by bradforj287 5 years ago
Github Package doc
Regarding occurs 500 error on publishing, I have been bumped the same error on my repo for a while, but I have confirmed it resolved on my repo today.
It works well with the following workflow:
Also, the following settings are not required:
.npmrc
file is not requiredpublishConfig
in thepackage.json
file is not requiredYou might want to try publishing to GPR again.
@shaodahong Try this change:
Just to keep you all informed we are investigating this on both the Actions and Package Registry side of things - and although I don’t have an update that we can share yet, we are working on it! ❤️
If we change a package name to a scoped package name to conform to the GPR constraints, does this change our npm package name when the package gets published to the npm registry too?
Hey folks!
I found that I had to separate registry setup and registry publishing into separate steps when configuring this: https://gist.github.com/Mattamorphic/792c2f1975c7f96065b9f9fc94311218
Here’s a repository where I applied that: https://github.com/Mattamorphic/github-actions-package-registry-example
Here’s an example of my action being executed: https://github.com/Mattamorphic/github-actions-package-registry-example/commit/5d2e3234123ba83ca8841d498f6e3ebc4ddb9301/checks
Notice that the step I have to configure the registry is an entirely separate step to when I am publishing my package. Also that I’m providing the GITHUB_TOKEN at the setup step as well as at the publishing step.
If you are still seeing a 500 error here, then please do reach out to https://github.com/support and we’ll gladly dive into this further :octocat:
@okuryu I also confirm that my previously non functional YML scripts now work fine regarding publishing to GPR with GITHUB_TOKEN