-
Notifications
You must be signed in to change notification settings - Fork 4.3k
109 lines (98 loc) · 4.84 KB
/
publish-npm-packages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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)
if: ${{ github.event.inputs.release_type != 'wp' }}
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: cli
ref: trunk
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Checkout (for publishing)
if: ${{ github.event.inputs.release_type != 'wp' }}
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: publish
# Later, we switch this branch in the script that publishes packages.
ref: trunk
token: ${{ secrets.GUTENBERG_TOKEN }}
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Checkout (for publishing WP major version)
if: ${{ github.event.inputs.release_type == 'wp' && github.event.inputs.wp_version }}
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: publish
ref: wp/${{ github.event.inputs.wp_version }}
# We need to ensure that Lerna can read the commit created during the previous npm publishing.
# Lerna assumes that all packages need publishing if it can't access the necessary information.
fetch-depth: 999
token: ${{ secrets.GUTENBERG_TOKEN }}
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Configure git user name and email (for publishing)
run: |
cd publish
git config user.name "Gutenberg Repository Automation"
git config user.email [email protected]
- name: Setup Node.js
if: ${{ github.event.inputs.release_type != 'wp' }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: 'cli/.nvmrc'
registry-url: 'https://registry.npmjs.org'
check-latest: true
- name: Setup Node.js (for WP major version)
if: ${{ github.event.inputs.release_type == 'wp' && github.event.inputs.wp_version }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: 'publish/.nvmrc'
registry-url: 'https://registry.npmjs.org'
check-latest: true
- name: Publish development packages to npm ("next" dist-tag)
if: ${{ github.event.inputs.release_type == 'development' }}
run: |
cd cli
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 cli
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 version ("wp/${{ github.event.inputs.wp_version || 'X.Y' }}" dist-tag)
if: ${{ github.event.inputs.release_type == 'wp' && github.event.inputs.wp_version }}
run: |
cd publish
npm ci
npx lerna publish patch --dist-tag wp-${{ github.event.inputs.wp_version }} --no-private --yes --no-verify-access
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}