Skip to content

Publish latest release to NPM #2

Publish latest release to NPM

Publish latest release to NPM #2

name: Publish latest release to NPM
env:
node_version: 20.x
package_manager: yarn # or npm
install_command: yarn install # or npm ci
script_command: yarn # or npm run
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
NODE_REGISTRY: 'https://registry.npmjs.org' # setup credentials
on:
workflow_dispatch: # manual trigger
permissions:
contents: read
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}
cache: ${{ env.package_manager }}
registry-url: ${{ env.NODE_REGISTRY }}
- name: Install dependencies
run: ${{ env.install_command }}
- name: Validate package
run: ${{ env.script_command }} validate
- name: Build package
run: ${{ env.script_command }} prepack
- name: Publish package
run: |
${{ env.script_command }} changelogen --publish