GitHub action to publish a NodeJS package to NPM and GitHub Packages.
See action.yml. Make sure you've stored a NPM classic token (an "Automation" token) as a secret in your repository. You can generate one at https://www.npmjs.com/settings/your-username/tokens.
name: Publish my node package
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Publish
uses: colinparsonsme/publish-node-package@v1
with:
# you can store your NPM token with any name in your repository secrets
# assuming it's stored as NPM_TOKEN here
npm-token: ${{ secrets.NPM_TOKEN }} # optional
# your github token is always accessed by ${{ secrets.GITHUB_TOKEN}}
# since it's autogenerated by GitHub on each job
github-token: ${{ secrets.GITHUB_TOKEN }} # optional; must be used with scope
scope: '@my-username-or-organization' # optional; must be used with github-token
See the License.
See the Contributing Guidelines.
See the Code of Conduct.
If you're interested in getting in touch outside of this project, check out colinparsons.com.