Skip to content

Release NPM packages #157

Release NPM packages

Release NPM packages #157

name: Release NPM packages
on:
workflow_dispatch:
# Require a version bump (patch, minor, major) and an optional dist tag
inputs:
version_bump:
description: 'Version bump (patch, minor, or major)'
required: true
default: 'patch'
dist_tag:
description: 'Dist tag (latest, next, etc.)'
required: false
default: 'latest'
schedule:
# Auto-publish every Monday
- cron: '0 9 * * 1'
jobs:
release:
# Only run this workflow from the trunk branch and when it's triggered by dmsnell OR adamziel
if: >
github.ref == 'refs/heads/trunk' && (
github.actor == 'adamziel' ||
github.actor == 'dmsnell' ||
github.actor == 'bgrgicak' ||
github.actor == 'brandonpayton'
)
# Specify runner + deployment step
runs-on: ubuntu-latest
environment:
name: npm
env:
NPM_TOKEN: ${{ secrets.NPM_AUTOMATION_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
clean: true
persist-credentials: false
submodules: true
- name: Config git user
run: |
git config --global user.name "deployment_bot"
git config --global user.email "[email protected]"
git remote set-url origin https://${{ secrets.GH_ACTOR }}:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}
- name: Authenticate with Registry
run: |
echo "@php-wasm:registry=https://registry.npmjs.org/" > ~/.npmrc
echo "@wp-playground:registry=https://registry.npmjs.org/" >> ~/.npmrc
echo "registry=https://registry.npmjs.org/" >> ~/.npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- uses: ./.github/actions/prepare-playground
# Version bump, release, tag a new version on GitHub
- name: Release new version of NPM packages
shell: bash
run: npx [email protected] publish ${{ inputs.version_bump || 'patch' }} --yes --no-private --loglevel=verbose --dist-tag=${{ inputs.dist_tag || 'latest' }}