Publish to NPM #133
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: | |
workflow_run: | |
workflows: ['Node.js CI'] | |
types: [completed] | |
branches: [master,main] | |
jobs: | |
publish-new-version: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: '0' | |
- name: git setup | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
- name: setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
registry-url: 'https://registry.npmjs.org' | |
- name: npm install | |
run: npm ci | |
- name: Should release | |
id: should_release | |
continue-on-error: true | |
run: npm run should-release -- -v | |
- name: No release | |
if: steps.should_release.outcome != 'success' | |
run: echo "No release required. Skipping publishing." | |
- name: Version bump | |
if: steps.should_release.outcome == 'success' | |
run: npm run release | |
- name: Publish to NPM | |
if: steps.should_release.outcome == 'success' | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Push commits to GitHub | |
if: steps.should_release.outcome == 'success' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
tags: true |