-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Unable to publish to the GitHub Registry #130
Comments
Same issue:
with following workflow :
I think it's a bug (or their docs are wrong). |
Interesting, npmjs seems to pass for me when specifying |
@jasonkarns Were you able to get this to work for yourself? |
@JamesIves I needed to explicitly provide the |
Interesting, I can't seem to get it to work for the life of me. Tried in several repositories now, the first publish to # Setup .npmrc file to publish to npm
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- name: Configure git
run: |
git config user.email "[email protected]"
git config user.name "James Ives"
- run: npm install
- run: npm run-script build
- run: npm version patch -m "Release %s 📣"
- run: git push
- run: npm ci
# Publish to npm
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: 'https://npm.pkg.github.com'
scope: '@JamesIves'
# Publish to GitHub Packages
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} However it still doesn't seem to be correctly overwriting the
|
I've got it working by setting - name: Setup Node
uses: actions/setup-node@v1
with:
node-version: "13.x"
- name: Install dependencies
run: |
echo "//npm.pkg.github.com/:_authToken=$NODE_AUTH_TOKEN" > ~/.npmrc
npm ci
env:
NODE_AUTH_TOKEN: ${{ github.token }} I also have
|
Can you provide more context to this? Do you have two name: publish-to-npm
on:
release:
types: [created]
push:
branches:
- publish-test
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: dev
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v1
with:
node-version: '13.x'
- run: echo "//npm.pkg.github.com/:_authToken=$NODE_AUTH_TOKEN" > .npmrc
env:
NODE_AUTH_TOKEN: ${{ github.token }}
- run: ls -a
- name: Configure git
run: |
git config user.email "[email protected]"
git config user.name "James Ives"
- run: npm install
- run: npm run-script build
- run: npm ci
# Publish to GitHub Packages
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ github.token }} Running |
I also ran into similar issue. But after a bit of debugging, it looks like the
to see if it’s the same for you. So not sure if it’s even possible to publish non-scoped packages in Github, if not, then it sort of conflicts with the NPM and can’t publish to both places with the same |
By scoping do you mean adding |
Yes exactly. Just tried it and it started to work. You can then publish the same thing in NPM as well, as long as you add |
So, I don't know if this applies to your situation or not, but I was having the exact same issue. I came across this doc I added this to my repo and it worked. "publishConfig": { "registry": "https://npm.pkg.github.com/" }, Good luck |
Thanks @chriskacerguis for the info. But as for me (and it looks like it’s similar to @JamesIves ), I was trying to publish to both NPM and Github.. But I wonder if with the Either way I renamed my package in NPM with the scope, so that it matches Github, and it started to work. |
I've added the scope to the package name, and it doesn't seem to run correctly for me. For simplicity I even removed the npm publish part from the action file yet it still tries to go straight to npm.
|
So I was having the same issue. I managed to get my private package published by using below workflow: jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@master
- name: Setup Node 12
uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@owner'
- name: Authenticate with GitHub package registry
run:
echo "//npm.pkg.github.com:_authToken=${{ secrets.PAT }}" >
~/.npmrc
- name: Build and Test
shell: bash
run: npm run setup
- name: Publish
shell: bash
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.PAT }} What I did was to generate the .npmrc file manually at On top of that, I also used scoped package name in {
...
"name": "@owner/package-name",
...
} |
We're having the same problem. Locally, it publishes to the correct registry (GPR) but when using Github Actions, it tries to publish to NPM Here's our config https://github.com/ApollosProject/apollos-apps/blob/master/.github/workflows/publish.yml |
I did two things. One of them fixed it, not sure which one it was and I'm not going to touch anything 😂
- name: Use Node 10.19.x
uses: actions/setup-node@v1
with:
node-version: 10.19.x
registry-url: 'https://npm.pkg.github.com'
scope: '@apollosproject'
{
"packages": ["packages/*"],
"version": "1.5.0",
"npmClient": "yarn",
"useWorkspaces": true,
"command": { "publish": { "registry": "https://npm.pkg.github.com" } }
} |
I've managed to resolve this with my actions with the following workflow file: I also added the scope to the package.json file here: https://github.com/JamesIves/github-pages-deploy-action/blob/dev/package.json#L2 It now cross publishes between npm and GitHub correctly. Thanks to everyone for their help resolving this. I'll leave this open as I still believe this is an issue with setup-node. |
* Suspect it needs scoped packages. See actions/setup-node#130
Package publication fails with `'@keep-network/[email protected]' is not in the npm registry` error. Here we try to workaround the problem by explicitly adding registry and scope, which was suggested in actions/setup-node#130
Package publication fails with `'@keep-network/[email protected]' is not in the npm registry` error. Here we try to workaround the problem by explicitly adding registry and scope, which was suggested in actions/setup-node#130
Amazing that this hasn't been patched yet. Very misleading that the published actions is broken(for this particular use case) by default. Please see @JamesIves post for remedy |
My repo was having a similar issue to this one. Replacing the package name in package.json by adding the scope to it solved it for Github Package Registry. // original
{
"name": "traefikjam",
}
// fix for GPR publish
{
"name": "@jojobyte/traefikjam",
} My fix: https://github.com/jojobyte/traefikjam/blob/master/.github/workflows/node-build.yml#L40 jobs:
npm-build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@scope'
- run: npm ci
- name: Publish to GitHub Package Registry
run: |
sed -i 's+"name": ".*+"name": "@${{ github.repository }}",+gI' ./package.json
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} This lets you publish to NPM with an unscoped package name and GPR with a scoped package name. |
get off of node v16 and goto v18 for the latest npm node v18... use the latest npm it will accept your scoped package name as appropriate prayers for microsoft to revamp all of this and stabilize this ecosystem for good |
Hello @nhhockeyplayer If the package name is not scoped one has to use the workaround like the one suggested by @jojobyte While we are improving the README, please use the snippet as a reference in order to upload the package to both repos
and the package.json must have both scope name and repository url match the github repo:
The corresponding build is here: https://github.com/akv-demo/setup-node-test/runs/7819174590?check_suite_focus=true and as it was already noted one of the reason of "401 Unauthorized - PUT https://registry.npmjs.org/github-pages-deploy-action - You must be logged in to publish packages" might be the package is not initially created with the public access. |
The issue is closed because it is not reproducible in the current version of action. |
Bumps [husky](https://github.com/typicode/husky) from 4.3.6 to 4.3.7. - [Release notes](https://github.com/typicode/husky/releases) - [Commits](typicode/husky@v4.3.6...v4.3.7) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
I am not able to publish it on npmjs via GitHub actions. I tried to debug the code manier times, but I feel there an issue from the development side. I used GitHub configured node js publish package as well, but even that didn't work. Though Note: My name on npmjs account: GitHub workflow file: name: Publish Package to npmjs
on:
push:
branches:
- main
jobs:
npm-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: "20.11.0"
registry-url: "https://registry.npmjs.org"
- name: Publish package on NPM 📦
run: npm publish --access public
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} package.json
|
Thanks for mentioning this! |
I've been following this document (and the README): https://github.community/t5/GitHub-Actions/bd-p/actions, specifically the part about cross publishing between npmjs and the GitHub registry, but I can't seem to get it to work. This is my workflow: https://github.com/JamesIves/github-pages-deploy-action/blob/dev/.github/workflows/publish.yml
The problem I'm having is that every time I publish it says I must authenticate, except it's providing a URL related to the npmjs registry:
401 Unauthorized - PUT https://registry.npmjs.org/github-pages-deploy-action - You must be logged in to publish packages.
This is the full log. Am I missing something here or is this a bug?
The text was updated successfully, but these errors were encountered: