Publish npm packages #87
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: Publish npm packages | |
on: | |
workflow_dispatch: | |
inputs: | |
release_type: | |
description: 'Release type' | |
required: true | |
type: choice | |
default: 'development' | |
options: | |
- development | |
- bugfix | |
- wp | |
wp_version: | |
description: 'WordPress major version (`wp` only)' | |
type: string | |
# Cancels all previous workflow runs for pull requests that have not completed. | |
concurrency: | |
# The concurrency group contains the workflow name and the branch name for pull requests | |
# or the commit hash for any other events. | |
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} | |
cancel-in-progress: true | |
jobs: | |
release: | |
name: Release - ${{ github.event.inputs.release_type }} | |
runs-on: ubuntu-latest | |
environment: WordPress packages | |
steps: | |
- name: Checkout (for CLI) | |
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 | |
with: | |
path: main | |
ref: trunk | |
- name: Checkout (for publishing) | |
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 | |
with: | |
path: publish | |
# Later, we switch this branch in the script that publishes packages. | |
ref: trunk | |
token: ${{ secrets.GUTENBERG_TOKEN }} | |
- name: Configure git user name and email (for publishing) | |
run: | | |
cd publish | |
git config user.name "Gutenberg Repository Automation" | |
git config user.email gutenberg@wordpress.org | |
- name: Setup Node.js | |
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 | |
with: | |
node-version-file: 'main/.nvmrc' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Publish development packages to npm ("next" dist-tag) | |
if: ${{ github.event.inputs.release_type == 'development' }} | |
run: | | |
cd main | |
npm ci | |
./bin/plugin/cli.js npm-next --ci --repository-path ../publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Publish packages to npm with bug fixes ("latest" dist-tag) | |
if: ${{ github.event.inputs.release_type == 'bugfix' }} | |
run: | | |
cd main | |
npm ci | |
./bin/plugin/cli.js npm-bugfix --ci --repository-path ../publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Publish packages to npm for WP major ("wp/${{ github.event.inputs.wp_version || 'X.Y' }}" dist-tag) | |
if: ${{ github.event.inputs.release_type == 'wp' && github.event.inputs.wp_version }} | |
run: | | |
cd main | |
npm ci | |
./bin/plugin/cli.js npm-wp --wp-version=${{ github.event.inputs.wp_version }} --ci --repository-path ../publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |