Skip to content

🏷️ Release to NPM #3

🏷️ Release to NPM

🏷️ Release to NPM #3

Workflow file for this run

name: 🏷️ Release to NPM
on:
workflow_dispatch:
inputs:
dryrun:
type: boolean
description: Dry-Run
graduate:
type: boolean
description: Force Conventional Graduate
permissions:
contents: write
id-token: write
jobs:
deploy-npm-latest:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Retrieve current Date Time in EST
shell: bash
run: echo "START_TIME=$(TZ=":America/New_York" date -R|sed 's/.....$//')" >> $GITHUB_ENV
- name: Current datetime - ${{ env.START_TIME }}
run: echo ${{ env.START_TIME }}
- name: Clone repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- if: ${{ github.event.pull_request.merged != true && contains('["ghiscoding"]', github.actor) != true }}
name: Exit early when current actor is not allowed to push new release
run: |
echo "Error: Your GitHub username (${{ github.actor }}) is not on the allowed list of admins for this workflow"
exit 1
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 10
run_install: false
- name: Set NodeJS
uses: actions/setup-node@v6
with:
registry-url: 'https://registry.npmjs.org/'
node-version: 24
- name: Run pnpm install dependencies
run: pnpm install
- name: Build Library
run: pnpm build
- name: Lerna Version (build query)
shell: bash
run: |
if ${{inputs.dryrun == true && inputs.graduate != true}}
then
echo "LERNA_VERSION_TYPE=🧪 Dry-Run" >> $GITHUB_ENV
echo "LERNA_VERSION_QUERY=lerna version --yes --dry-run" >> $GITHUB_ENV
elif ${{inputs.dryrun == true && inputs.graduate == true}}
then
echo "LERNA_VERSION_TYPE=🧪 Dry-Run w/Graduate" >> $GITHUB_ENV
echo "LERNA_VERSION_QUERY=lerna version --yes --dry-run --conventional-graduate" >> $GITHUB_ENV
elif ${{inputs.dryrun != true && inputs.graduate == true}}
then
echo "LERNA_VERSION_TYPE=🚀 Prod Version w/Graduate" >> $GITHUB_ENV
echo "LERNA_VERSION_QUERY=lerna version --yes --conventional-graduate" >> $GITHUB_ENV
elif ${{inputs.dryrun != true && inputs.graduate != true}}
then
echo "LERNA_VERSION_TYPE=🚀 Prod Version" >> $GITHUB_ENV
echo "LERNA_VERSION_QUERY=lerna version --yes" >> $GITHUB_ENV
fi
- name: Final version query type - ${{ env.LERNA_VERSION_TYPE }}
run: echo "${{ env.LERNA_VERSION_QUERY }}"
- name: Lerna Version 🏷️
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
pnpm exec ${{ env.LERNA_VERSION_QUERY }}
- name: Lerna Publish 📦
if: ${{ inputs.dryrun != true }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pnpm exec lerna publish from-package --force-publish --yes
- name: Build Website (GitHub demo site)
if: ${{ inputs.dryrun != true }}
run: pnpm build:demo
# deploy (re-publish) GitHub demo page with a Prod build but only when merging to "master" branch
# and the commit message contains the text "chore: release"
- name: Deploy to gh-pages
if: ${{ inputs.dryrun != true }}
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./packages/demo/dist