v3.1.1 #6
Workflow file for this run
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
# ./github/workflows/publish-npm | |
# | |
# Per manual GitHub release, auto publish the package to npm. | |
name: Publish NPM | |
on: | |
release: | |
types: | |
- published | |
jobs: | |
publish-npm: | |
name : Publish to NPM | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
# Restrict only one publishing job per workflow run. | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
steps: | |
- name: Checkout code | |
uses: 'actions/checkout@v4' | |
with: | |
fetch-depth: 0 | |
# Attach HEAD to main to avoid detached HEAD state. | |
# And to ensure publishing from main branch only. | |
# Added hard reset to ensure the branch is clean. | |
- name: Attach HEAD to main branch | |
run: | | |
set -e; | |
git checkout main; | |
git reset --hard; | |
- name: Install pnpm | |
uses: 'pnpm/action-setup@v4' | |
- name: Install dependencies | |
run : pnpm install --frozen-lockfile | |
- name: Set up Node.js ${{ vars.DEFAULT_NODE_MAJOR_VERSION }} | |
uses: 'actions/setup-node@v4' | |
with: | |
node-version: ${{ vars.DEFAULT_NODE_MAJOR_VERSION }}.x | |
cache : pnpm | |
- name: Pre-publish final testing. | |
run : pnpm test:coverage | |
- name: Pre-publish final build. | |
run : pnpm build | |
# IMPORTANT!! | |
# Use `npm set ...` with classic automation token to auth to NPM. | |
- name: Publish to NPM | |
run : | | |
set -e; | |
npm set "//registry.npmjs.org/:_authToken" ${{ secrets.NPM_PUBLISH_TOKEN }}; | |
npm publish --access public; | |