-
Notifications
You must be signed in to change notification settings - Fork 4.9k
129 lines (116 loc) · 5.6 KB
/
Copy pathpublish-npm-packages.yml
File metadata and controls
129 lines (116 loc) · 5.6 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Publish npm packages
on:
workflow_dispatch:
inputs:
release_type:
description: 'Release type'
required: true
type: choice
default: 'development'
options:
- development
- latest
- bugfix
- wp
wp_version:
description: 'WordPress major version (`wp` only)'
type: string
# Prevents overlapping package releases without canceling an in-progress release.
concurrency:
# Scope package release dispatches by target npm release branch.
# `latest` and `bugfix` both target wp/latest and must serialize.
group: npm-publish-wp-${{ github.event.inputs.release_type == 'wp' && github.event.inputs.wp_version || github.event.inputs.release_type == 'development' && 'next' || 'latest' }}
cancel-in-progress: false
queue: max
# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}
jobs:
release:
name: Release - ${{ github.event.inputs.release_type }}
runs-on: 'ubuntu-24.04'
permissions:
contents: read
environment: WordPress packages
steps:
- name: Checkout (for CLI)
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: cli
ref: trunk
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false
- name: Checkout (for publishing)
if: ${{ github.event.inputs.release_type != 'wp' }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
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' }}
persist-credentials: true
- name: Checkout (for publishing WP major version)
if: ${{ github.event.inputs.release_type == 'wp' && github.event.inputs.wp_version }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
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' }}
persist-credentials: true
- 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
# The release CLI is always loaded from trunk, so use its runtime for every release.
# The selected publishing branch must remain installable under this runtime.
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: 'cli/.nvmrc'
registry-url: 'https://registry.npmjs.org'
check-latest: true
package-manager-cache: false
- name: Set up npm
uses: ./cli/.github/setup-npm
with:
working-directory: cli
cache: false
- name: Publish development packages to npm ("next" dist-tag)
if: ${{ github.event.inputs.release_type == 'development' }}
run: |
cd cli
npm ci
npm exec --no release-cli -- npm-next --ci --repository-path ../publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish packages based on the latest Gutenberg plugin to npm ("latest" dist-tag)
if: ${{ github.event.inputs.release_type == 'latest' }}
run: |
cd cli
npm ci
npm exec --no release-cli -- npm-latest --semver minor --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
npm exec --no release-cli -- 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 cli
npm ci
npm exec --no release-cli -- npm-wp --wp-version "$WP_VERSION" --ci --repository-path ../publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
WP_VERSION: ${{ github.event.inputs.wp_version }}