Skip to content

v0.1.0

v0.1.0 #7

Workflow file for this run

name: 'Publish to npm'
on:
release:
types: [created, published]
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v1
- name: Use Node.js v18
uses: actions/setup-node@v1
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
- name: Check if package.json Version matches tag
uses: actions/github-script@v6
env:
TAG: ${{ github.ref_name }}
with:
script: |
const fs = require('fs')
const packageJson = JSON.parse(fs.readFileSync('${{ github.workspace }}/package.json'))
const pjv = packageJson.version.split('.')[0]
const tagVersion = process.env.TAG.replace('v', '').split('.')[0]
if (pjv !== tagVersion) {
throw new Error('The tagged release doesn\'t match the package.json version, please update, delete the tag & release and try again.')
}
- name: Install Packages
run: npm ci
- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH }}