Skip to content

Release NPM packages #551

Release NPM packages

Release NPM packages #551

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: '22'
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]@users.noreply@github.com"
git config --global user.name "github-actions[bot]"
- name: Install lerna v4
run: |
rm -rf /usr/local/bin/lerna
npm install -g lerna@4.0.0
- 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 }}