Trying out github actions to auto publish an npm package but its showing these errors I don't know what's wrong. I have used my own name
and email
in the code instead of this dummy data shown in the attached screenshot. And yes I have already set the secret value NPM_PUBLISH_TOKEN
.
#.github/workflows/auto-publish.yml
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Bump version & push
run: |
git config --global user.name 'Automated publish'
git config --global user.email 'naeem-gg@users.noreply.github.com'
# Update the version in package.json, and commit & tag the change:
npm version patch # YMMV - you might want the semver level as a workflow input
git push && git push --tags
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
The workflow definition is missing a few required elements. Please see below.
I did not edit the shell script as I am not sure what specific files you want to add before you commit and push.
#.github/workflows/auto-publish.yml
name: auto-publish
on:
push:
branches:
- main
- master
permissions:
contents: write
jobs:
auto-puplish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Bump version & push
run: |
git config --global user.name 'Automated publish'
git config --global user.email 'naeem-gg@users.noreply.github.com'
# Update the version in package.json, and commit & tag the change:
npm version patch # YMMV - you might want the semver level as a workflow input
git push && git push --tags
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}