Skip to content

Merge pull request #19 from ykiu/bug #17

Merge pull request #19 from ykiu/bug

Merge pull request #19 from ykiu/bug #17

Workflow file for this run

# Publishes a new version to npm and GitHub releases.
# Only runs when `version` in package.json has changed in the main branch.
name: Publish
on:
push:
branches:
- 'main'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- uses: actions/[email protected]
with:
node-version: 18
# 'registry-url' is required for 'npm publish'
registry-url: 'https://registry.npmjs.org'
- id: versions
run: |
git show HEAD:package.json | node -e "console.log('current_version=' + JSON.parse(require('fs').readFileSync(0)).version)" >> $GITHUB_OUTPUT
git show HEAD^1:package.json | node -e "console.log('prev_version=' + JSON.parse(require('fs').readFileSync(0)).version)" >> $GITHUB_OUTPUT
- if: steps.versions.outputs.prev_version != steps.versions.outputs.current_version
run: |
echo "${{ steps.versions.outputs.prev_version }} --> ${{ steps.versions.outputs.current_version }}"
npm ci
npm run build
npm pack
- if: steps.versions.outputs.prev_version != steps.versions.outputs.current_version
run: |
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- if: steps.versions.outputs.prev_version != steps.versions.outputs.current_version
run: |
git tag v${{ steps.versions.outputs.current_version }} && git push origin v${{ steps.versions.outputs.current_version }}
- if: steps.versions.outputs.prev_version != steps.versions.outputs.current_version
uses: ncipollo/[email protected]
with:
artifacts: '*.tgz'
token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ steps.versions.outputs.current_version }}