Repository navigation
404 lines (373 loc) · 15 KB
/
Copy pathpullRequestsCommandBeta.yml
File metadata and controls
404 lines (373 loc) · 15 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# This file was automatically generated by github-actions-wac.
# DO NOT MODIFY IT BY HAND. Instead, modify the source *.wac.ts file(s)
# and run "github-actions-wac build" (or "ghawac build") to regenerate this file.
# For more information, run "github-actions-wac --help".
name: 💬 PR Command - Beta Release
'on':
issue_comment:
types:
- created
concurrency:
group: beta-release-${{ github.event.issue.number }}
cancel-in-progress: true
jobs:
checkComment:
name: Check comment for /beta
if: >-
${{ github.event.issue.pull_request && (github.event.comment.body ==
'/beta' || startsWith(github.event.comment.body, '/beta ')) }}
permissions:
contents: read
actions: write
pull-requests: write
issues: write
steps:
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version: 24
- name: Check permission and react to comment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
PERMISSION=$(gh api "/repos/${{ github.repository }}/collaborators/${{
github.event.comment.user.login }}/permission" -q .permission)
if [ "$PERMISSION" != "write" ] && [ "$PERMISSION" != "admin" ]; then
echo "::error::User ${{ github.event.comment.user.login }} does not have write permission (has: $PERMISSION)."
exit 1
fi
gh api --silent -X POST "/repos/${{ github.repository
}}/issues/comments/${{ github.event.comment.id }}/reactions" -f
content=eyes
- name: Create comment
id: create-comment
uses: >-
peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9
with:
issue-number: ${{ github.event.issue.number }}
body: >-
Beta release has been initiated (for more information, click
[here](https://github.com/webiny/webiny-js/actions/runs/${{
github.run_id }})). :sparkles:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: '--max_old_space_size=4096'
YARN_ENABLE_IMMUTABLE_INSTALLS: false
prBranch:
needs: checkComment
name: Get PR branch
permissions:
contents: read
actions: write
pull-requests: read
outputs:
pr-branch: ${{ steps.pr-branch.outputs.pr-branch }}
pr-sha: ${{ steps.pr-sha.outputs.pr-sha }}
release-version: ${{ steps.release-version.outputs.release-version }}
steps:
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version: 24
- name: Get PR branch
id: pr-branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
echo "pr-branch=$(gh pr view ${{ github.event.issue.number }} --repo
${{ github.repository }} --json headRefName -q .headRefName)" >>
$GITHUB_OUTPUT
- name: Get PR head SHA
id: pr-sha
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
echo "pr-sha=$(gh pr view ${{ github.event.issue.number }} --repo ${{
github.repository }} --json headRefOid -q .headRefOid)" >>
$GITHUB_OUTPUT
- name: Parse release version from branch name
id: release-version
run: >-
BRANCH="${{ steps.pr-branch.outputs.pr-branch }}"
VERSION="${BRANCH#release/}"
if [ "$VERSION" = "$BRANCH" ]; then echo "Branch does not match
release/* pattern" && exit 1; fi
echo "release-version=$VERSION" >> $GITHUB_OUTPUT
runs-on: ubuntu-latest
env:
NODE_OPTIONS: '--max_old_space_size=4096'
YARN_ENABLE_IMMUTABLE_INSTALLS: false
build:
name: Build
needs:
- prBranch
runs-on: webiny-build-packages
steps:
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version: 24
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
with:
path: ${{ needs.prBranch.outputs.pr-branch }}
ref: ${{ needs.prBranch.outputs.pr-sha }}
- name: Resolve Yarn cache folder
id: yarn-cache-folder
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
run: echo "path=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25
with:
path: ${{ steps.yarn-cache-folder.outputs.path }}
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: yarn-${{ runner.os }}-
- name: Install dependencies
run: yarn --immutable
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Build packages
run: yarn build
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Compress build cache
run: >-
tar -cf run-build-cache.tzst --use-compress-program=zstdmt -C
"${WEBINY_JS_DIR:-.}" .webiny/cached-packages
env:
WEBINY_JS_DIR: ${{ needs.prBranch.outputs.pr-branch }}
- name: Upload build cache
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: run-build-cache
path: run-build-cache.tzst
retention-days: 7
compression-level: 0
if-no-files-found: error
overwrite: true
env:
NODE_OPTIONS: '--max_old_space_size=4096'
YARN_ENABLE_IMMUTABLE_INSTALLS: false
permissions:
contents: read
actions: write
npmReleaseBeta:
needs:
- prBranch
- build
name: NPM release (beta)
env:
NODE_OPTIONS: '--max_old_space_size=4096'
YARN_ENABLE_IMMUTABLE_INSTALLS: false
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
SLACK_RELEASE_CHANNEL_WEBHOOK: ${{ secrets.SLACK_RELEASE_CHANNEL_WEBHOOK }}
steps:
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version: 24
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
with:
path: ${{ needs.prBranch.outputs.pr-branch }}
ref: ${{ needs.prBranch.outputs.pr-sha }}
fetch-depth: 0
- name: Resolve Yarn cache folder
id: yarn-cache-folder
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
run: echo "path=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25
with:
path: ${{ steps.yarn-cache-folder.outputs.path }}
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: yarn-${{ runner.os }}-
- name: Download build cache
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
name: run-build-cache
continue-on-error: true
- name: Extract build cache
run: >-
if [ ! -f run-build-cache.tzst ]; then
echo "::warning::No build cache artifact - building from scratch. This job will be slower than usual."
exit 0
fi
tar -xf run-build-cache.tzst --use-compress-program=zstdmt -C
"${WEBINY_JS_DIR:-.}"
env:
WEBINY_JS_DIR: ${{ needs.prBranch.outputs.pr-branch }}
- name: Install dependencies
run: yarn --immutable
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Build packages
run: yarn build
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Create ".npmrc" file in the project root
run: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Set git email
run: git config --global user.email "webiny-bot@webiny.com"
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Set git username
run: git config --global user.name "webiny-bot"
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Version and publish beta to NPM
id: release
run: >-
set -o pipefail
yarn release --type=beta --version=${{
needs.prBranch.outputs.release-version }} 2>&1 | tee
/tmp/release-output.txt
BETA_VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+'
/tmp/release-output.txt | tail -1)
echo "beta-version=$BETA_VERSION" >> $GITHUB_OUTPUT
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Notify Slack - Beta Release
env:
BETA_VERSION: ${{ steps.release.outputs.beta-version }}
run: >-
[ -z "$SLACK_RELEASE_CHANNEL_WEBHOOK" ] && echo "Slack webhook not
configured, skipping." && exit 0
PROJECT_NAME=webiny-$(echo $BETA_VERSION | tr . -)
INSTALL_CMD="npx create-webiny-project@${BETA_VERSION}
${PROJECT_NAME}"
MSG="Webiny \`${BETA_VERSION}\` is out! :rocket:\nTo install, run:
\`\`\`${INSTALL_CMD}\`\`\`"
curl -s -o /dev/null -X POST \
-H "Content-type: application/json" \
--data "{\"text\":\"${MSG}\"}" \
"$SLACK_RELEASE_CHANNEL_WEBHOOK"
runs-on: ubuntu-latest
permissions:
contents: read
actions: write
npmReleaseLatest:
needs:
- prBranch
- npmReleaseBeta
name: NPM release ("latest" tag)
environment: release
env:
NODE_OPTIONS: '--max_old_space_size=4096'
YARN_ENABLE_IMMUTABLE_INSTALLS: false
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
SLACK_RELEASE_CHANNEL_WEBHOOK: ${{ secrets.SLACK_RELEASE_CHANNEL_WEBHOOK }}
steps:
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version: 24
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
with:
path: ${{ needs.prBranch.outputs.pr-branch }}
ref: ${{ needs.prBranch.outputs.pr-sha }}
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- name: Resolve Yarn cache folder
id: yarn-cache-folder
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
run: echo "path=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25
with:
path: ${{ steps.yarn-cache-folder.outputs.path }}
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: yarn-${{ runner.os }}-
- name: Download build cache
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
name: run-build-cache
continue-on-error: true
- name: Extract build cache
run: >-
if [ ! -f run-build-cache.tzst ]; then
echo "::warning::No build cache artifact - building from scratch. This job will be slower than usual."
exit 0
fi
tar -xf run-build-cache.tzst --use-compress-program=zstdmt -C
"${WEBINY_JS_DIR:-.}"
env:
WEBINY_JS_DIR: ${{ needs.prBranch.outputs.pr-branch }}
- name: Install dependencies
run: yarn --immutable
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Build packages
run: yarn build
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Create ".npmrc" file in the project root
run: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Set git email
run: git config --global user.email "webiny-bot@webiny.com"
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Set git username
run: git config --global user.name "webiny-bot"
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Version and publish "latest" tag to NPM
id: release
run: >-
set -o pipefail
yarn release --type=latest --version=${{
needs.prBranch.outputs.release-version }} --createGithubRelease=latest
2>&1 | tee /tmp/release-output.txt
echo "latest-version=${{ needs.prBranch.outputs.release-version }}" >>
$GITHUB_OUTPUT
working-directory: ${{ needs.prBranch.outputs.pr-branch }}
- name: Notify Slack - Latest Release
env:
LATEST_VERSION: ${{ steps.release.outputs.latest-version }}
run: >-
[ -z "$SLACK_RELEASE_CHANNEL_WEBHOOK" ] && echo "Slack webhook not
configured, skipping." && exit 0
PROJECT_NAME=webiny-$(echo $LATEST_VERSION | tr . -)
INSTALL_CMD="npx create-webiny-project@${LATEST_VERSION}
${PROJECT_NAME}"
MSG="Webiny \`${LATEST_VERSION}\` is out! :rocket:\nTo install, run:
\`\`\`${INSTALL_CMD}\`\`\`"
curl -s -o /dev/null -X POST \
-H "Content-type: application/json" \
--data "{\"text\":\"${MSG}\"}" \
"$SLACK_RELEASE_CHANNEL_WEBHOOK"
runs-on: ubuntu-latest
permissions:
contents: read
actions: write
notifySlackOnFailure:
name: Notify Slack on failure
needs:
- prBranch
- build
- npmReleaseBeta
- npmReleaseLatest
if: failure()
env:
NODE_OPTIONS: '--max_old_space_size=4096'
YARN_ENABLE_IMMUTABLE_INSTALLS: false
SLACK_RELEASE_CHANNEL_WEBHOOK: ${{ secrets.SLACK_RELEASE_CHANNEL_WEBHOOK }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LABEL: Beta release (/beta)
RUN_URL: >-
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{
github.run_id }}
steps:
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version: 24
- name: Notify Slack
run: >-
set -euo pipefail
[ -z "$SLACK_RELEASE_CHANNEL_WEBHOOK" ] && echo "Slack webhook not
configured, skipping." && exit 0
# Name the jobs that actually failed, so the message says something
without
# anyone having to open the run first.
FAILED=$(gh api --paginate "repos/${{ github.repository
}}/actions/runs/${{ github.run_id }}/jobs" \
--jq '[.jobs[] | select(.conclusion == "failure") | .name] | join(", ")')
[ -n "$FAILED" ] || FAILED="unknown job"
# Built with jq, not string interpolation: job names here contain
double quotes
# (`NPM release ("latest" tag)`) and would produce invalid JSON
otherwise.
jq -nc --arg label "$LABEL" --arg failed "$FAILED" --arg url
"$RUN_URL" \
'{ text: ":rotating_light: \($label) failed: \($failed)\n\($url)" }' \
> /tmp/slack-payload.json
curl -s -o /dev/null -X POST \
-H "Content-type: application/json" \
--data @/tmp/slack-payload.json \
"$SLACK_RELEASE_CHANNEL_WEBHOOK"
runs-on: ubuntu-latest
permissions:
contents: read
actions: write