Skip to content

pkg: Publish to npm #22

pkg: Publish to npm

pkg: Publish to npm #22

Workflow file for this run

name: 'Publish to npm'
on:
release:
types: [published]
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: 'πŸ›’ Checkout Code'
uses: actions/checkout@v4
- name: 'βœ… Check if package.json Version matches tag'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs')
const packageJson = JSON.parse(fs.readFileSync('${{ github.workspace }}/package.json'))
const pjv = packageJson.version
const tv = "${{ github.ref_name }}".replace('v', '')
if (pjv !== tv) {
throw new Error(`The tagged release, ${tv}, doesn't match the package.json version, ${pjv}. Please fix the issue, delete the tag & release and try again.`)
}
- name: '🟒 Use Node.js'
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- name: '⚑️ Install Packages'
run: yarn install
- name: 'πŸ—οΈ Build'
run: yarn build
- name: '🚒 Publish'
run: yarn npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH }}