v0.2.0 #11
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |