Publish stable version to NPM #18
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 stable version to NPM | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
version_bump_type: | |
description: 'Version Bump Type (major, minor, patch)' | |
required: true | |
default: 'patch' | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token | |
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | |
- name: Read .nvmrc | |
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)" | |
id: nvm | |
- name: Use Node.js ${{ steps.nvm.outputs.NVMRC }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "${{ steps.nvm.outputs.NVMRC }}" | |
registry-url: 'https://registry.npmjs.org' | |
- name: NPM Install | |
run: npm ci | |
- name: Build | |
run: npm run build | |
- name: Setup git credentials | |
run: | | |
git config --local user.email "github-actions[bot]@noreply.amsterdam.nl" | |
git config --local user.name "github-actions[bot]" | |
- name: Prepare stable release | |
if: github.ref == 'refs/heads/main' | |
run: npm run release -- --release-as ${{ github.event.inputs.version_bump_type }} --no-verify | |
- name: Status | |
run: | | |
git remote -v | |
git status | |
git show --summary | |
- name: Push release commit + tag | |
uses: ad-m/github-push-action@master | |
with: | |
tags: true | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
- name: Publish production release to NPM | |
uses: JS-DevTools/npm-publish@v1 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
access: public | |