Skip to content

Cannot run npm version before publishing #215

Closed
@strongishllama

Description

@strongishllama

Hi all,

I've got this action that is triggered when a new tag is pushed to the repository. It works fine until I try and change the npm version based on the pushed tag before publishing.

name: CD

on:
  push:
    tags:
      - v*

jobs:
  publish:
    name: Publish package
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
          registry-url: https://npm.pkg.github.com/
          scope: '@strongishllama'
      - run: npm ci
      - run: npm config set git-tag-version=false # Works without these two lines.
      - run: npm version $(git describe --tags)   # Works without these two lines.
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Then the action fails with the following error.

npm notice 
npm ERR! code E401
npm ERR! 401 Unauthorized - PUT https://npm.pkg.github.com/@strongishllama%2faws-email-service - 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 a feeling it might be something to do with the encoding of the forward slash (%2f) between the scope and package name but I'm quite new to npm and actions so I can't really be sure.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions