Skip to content

Unable to publish to GitHub Package Registry #53

@daquinoaldo

Description

@daquinoaldo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions