Skip to content

Support GPR in .npmrc #178

Description

@meleksomai

I am trying to publish monorepo packages to a private Github registry using changesets/action.

Whenever I push to main, I get the following error:

npm notice 📦 @inception-health/utils@0.0.1
npm notice === Tarball Contents === npm notice 1.3kB dist/index.js npm notice 960B package.json npm notice 284B dist/index.mjs npm notice 209B dist/index.d.ts
npm notice === Tarball Details === npm notice name: @inception-health/utils npm notice version: 0.0.1 npm notice package size: 1.2 kB npm notice unpacked size: 2.7 kB npm notice shasum: 12d6dc8e84110XXXXXX
npm notice integrity: sha512-tGyxr7tYjFXh2[...]XXXXXXXXXX
npm notice total files: 4 npm notice npm ERR! code E401
npm ERR! 401 Unauthorized - PUT https://npm.pkg.github.com/@inception-health%2futils - Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.

I have the following configuration:

.npmrc

@inception-health:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN

Note: I also tried to dynamically add the .npmrc during the workflow build

 - name: Creating .npmrcrun: | cat << EOF > "$HOME/.npmrc" @inception-health:registry=https://npm.pkg.github.com/ //npm.pkg.github.com/:_authToken=$GITHUB_TOKEN EOFenv:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Github Workflow

name: Changesetson:
push:
branches:
- mainenv:
CI: truePNPM_CACHE_FOLDER: .pnpm-storejobs:
version:
timeout-minutes: 15runs-on: ubuntu-latestpermissions: write-allsteps:
- name: checkout code repositoryuses: actions/checkout@v2with:
fetch-depth: 0
- name: setup node.jsuses: actions/setup-node@v2with:
node-version: 14registry-url: https://npm.pkg.github.com/scope: "@inception-health"
- name: install pnpmrun: npm i pnpm@latest -g
- name: setup pnpm configrun: pnpm config set store-dir $PNPM_CACHE_FOLDER
- name: install dependenciesrun: pnpm install
- name: create and publish versionsuses: changesets/action@v1with:
version: pnpm ci:versioncommit: "chore: update versions"title: "chore: update versions"publish: pnpm ci:publishsetupGitUser: falseenv:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Note: I also tried to replace the GITHUB_TOKEN with a custom PAT. Same error.

Package.json

For all the packages I wanted to publish, I included the following config

{
..."publishConfig": {
"access": "restricted",
"registry": "https://npm.pkg.github.com/inception-health/"
}
}

CI Action

This is the pnpm script for ci:publish that are included in the root package.json.

{
..."scripts": {
"ci:publish": "pnpm build && pnpm recursive publish",
"ci:version": "pnpm changeset version"
},
...
}

I don't know what is missing? I appreciate any guidance.

Version

  • pnpm: 7.0.0-rc.9
  • @changesets/cli: "^2.22.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions