Release NPM packages #530
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: Release NPM packages | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "Version to publish, by explicit version or semver keyword." | |
required: true | |
default: patch | |
jobs: | |
release-packages: | |
name: 'build, test, release' | |
runs-on: ubuntu-latest | |
env: | |
# NPM automation token (skips 2FA) | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
steps: | |
- name: Master-branch check | |
run: | | |
echo "Must be on master branch to publish packages." | |
exit 1 | |
if: github.ref != 'refs/heads/master' | |
# 1. provide Personal Access Token for checkout@v2 | |
# GITHUB_TOKEN (personal access token) always exists in repositories, does not have to be explicitly added | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# 2. setup .npmrc which uses NODE_AUTH_TOKEN | |
- name: Setup .npmrc file for publish | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
registry-url: 'https://registry.npmjs.org' | |
# 3. configure git user used to push tag | |
- name: Configure Git User | |
run: | | |
git config --global user.email "github-actions[bot]@[email protected]" | |
git config --global user.name "github-actions[bot]" | |
- name: Install lerna v4 | |
run: | | |
rm -rf /usr/local/bin/lerna | |
npm install -g [email protected] | |
- name: Install dependencies | |
run: | | |
npm ci | |
lerna bootstrap | |
- name: Build packages | |
run: lerna run build | |
- name: Publish | |
run: | | |
lerna publish --yes --no-verify-access ${{ github.event.inputs.version }} |