Repository navigation
432 lines (408 loc) · 15.9 KB
/
Copy pathrelease.yml
File metadata and controls
432 lines (408 loc) · 15.9 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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
name: Release - Finish
on:
pull_request:
types: [closed]
paths:
- 'version.bzl'
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., selenium-4.28.0 or selenium-4.28.1-ruby)'
required: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
packages: write
jobs:
unlock-on-close:
name: Unlock Trunk on PR Close
if: >-
github.event.repository.fork == false &&
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository &&
startsWith(github.event.pull_request.head.ref, 'release-preparation-') &&
github.event.pull_request.merged == false
uses: ./.github/workflows/restrict-trunk.yml
with:
unlock: true
message: "Trunk has been unlocked: ${{ github.event.pull_request.head.ref }} was closed without merging."
secrets:
SELENIUM_CI_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
extract-tag:
name: Extract Tag
runs-on: ubuntu-latest
if: >
github.event.repository.fork == false &&
((github.event.pull_request.head.repo.full_name == github.repository &&
startsWith(github.event.pull_request.head.ref, 'release-preparation-') &&
github.event.pull_request.merged == true) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.tag != ''))
outputs:
tag: ${{ steps.extract.outputs.tag }}
steps:
- name: Extract tag from input or PR branch
id: extract
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_TAG: ${{ inputs.tag }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
if [ "$EVENT_NAME" == "workflow_dispatch" ]; then
TAG="$INPUT_TAG"
else
# Extract tag from branch name: release-preparation-selenium-4.28.1-ruby -> selenium-4.28.1-ruby
TAG="${PR_HEAD_REF#release-preparation-}"
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
parse-tag:
name: Parse Tag
needs: extract-tag
uses: ./.github/workflows/parse-release-tag.yml
with:
tag: ${{ needs.extract-tag.outputs.tag }}
check-authorization:
name: Check Authorization
needs: extract-tag
uses: ./.github/workflows/check-authorization.yml
create-tag:
name: Create Tag
needs: [parse-tag, check-authorization]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Create release tag
env:
GH_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
TAG: ${{ needs.parse-tag.outputs.tag }}
SHA: ${{ github.event.pull_request.merge_commit_sha || github.sha }}
run: |
if gh api "/repos/${{ github.repository }}/git/ref/tags/${TAG}" >/dev/null 2>&1; then
echo "Tag ${TAG} already exists — skipping creation."
exit 0
fi
gh api -X POST /repos/${{ github.repository }}/git/refs \
-f ref="refs/tags/${TAG}" \
-f sha="${SHA}"
github-release-draft:
name: GitHub Release Draft
needs: [parse-tag, check-authorization]
if: needs.parse-tag.outputs.language == 'all'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Generate release notes against previous minor release
env:
TAG: ${{ needs.parse-tag.outputs.tag }}
SHA: ${{ github.event.pull_request.merge_commit_sha || github.sha }}
run: |
PREV=$(gh release list --exclude-drafts --json tagName \
-q 'map(.tagName | select(test("^selenium-[0-9]+\\.[0-9]+\\.0$")))[0]')
echo "Previous release tag: $PREV"
{
cat scripts/github-actions/release_header.md
echo ""
gh api -X POST "/repos/${{ github.repository }}/releases/generate-notes" \
-f tag_name="$TAG" \
-f previous_tag_name="$PREV" \
-f target_commitish="$SHA" \
--jq .body
} > release_body.md
- name: Create draft GitHub release
uses: ncipollo/release-action@v1
with:
draft: true
allowUpdates: true
bodyFile: "release_body.md"
name: "Selenium ${{ needs.parse-tag.outputs.version }}"
tag: "${{ needs.parse-tag.outputs.tag }}"
commit: ${{ github.event.pull_request.merge_commit_sha || github.sha }}
publish:
name: Build and Publish ${{ matrix.language }}
needs: [parse-tag, check-authorization]
permissions:
contents: read
packages: read
id-token: write
strategy:
fail-fast: false
matrix:
language: [java, ruby, dotnet, javascript]
uses: ./.github/workflows/bazel.yml
with:
name: Publish ${{ matrix.language }}
node-version: ${{ matrix.language == 'javascript' && '24.22.1' || '' }}
run: |
if [ "${{ needs.parse-tag.outputs.language == 'all' || needs.parse-tag.outputs.language == matrix.language }}" = "true" ]; then
./go ${{ matrix.language }}:release rbe
# @selenium/manager ships alongside selenium-webdriver at the same version
if [ "${{ matrix.language }}" = "javascript" ]; then
./go javascript:release_manager rbe
fi
else
echo skipping
fi
artifact-name: ${{ (matrix.language == 'java' || matrix.language == 'dotnet') && (needs.parse-tag.outputs.language == 'all' || needs.parse-tag.outputs.language == matrix.language) && format('release-packages-{0}', matrix.language) || '' }}
artifact-path: ${{ (matrix.language == 'java' || matrix.language == 'dotnet') && 'build/dist/*.*' || '' }}
secrets: inherit
build-python:
name: Build Python
needs: [parse-tag, check-authorization]
if: needs.parse-tag.outputs.language == 'all' || needs.parse-tag.outputs.language == 'python'
uses: ./.github/workflows/bazel.yml
with:
name: Build Python
use-cache: false
run: ./go py:build --config=rbe_release
artifact-name: pypi-distributions
artifact-path: |
bazel-bin/py/selenium-*.whl
bazel-bin/py/selenium-[0-9]*.tar.gz
secrets: inherit
publish-python:
name: Publish Python to PyPI
needs: [parse-tag, build-python]
if: needs.parse-tag.outputs.language == 'all' || needs.parse-tag.outputs.language == 'python'
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
actions: read
steps:
- name: Download Python distributions
uses: actions/download-artifact@v8
with:
name: pypi-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.14.3
with:
skip-existing: true
github-release-publish:
name: GitHub Release Publish
needs: [parse-tag, publish, github-release-draft]
if: >-
always() && !failure() && !cancelled() &&
(needs.parse-tag.outputs.language == 'all' ||
needs.parse-tag.outputs.language == 'java' ||
needs.parse-tag.outputs.language == 'dotnet')
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
attestations: write
steps:
- name: Download release packages
uses: actions/download-artifact@v8
with:
pattern: release-packages-*
merge-multiple: true
path: "build/dist/"
- name: Generate checksums
working-directory: build/dist
run: sha256sum -- * > ../SHA256SUMS && mv ../SHA256SUMS .
- name: Attest build provenance
uses: actions/attest@v4
continue-on-error: true
with:
subject-path: build/dist/*
- name: Upload to GitHub release
env:
GH_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
GH_REPO: ${{ github.repository }}
VERSION: ${{ needs.parse-tag.outputs.version }}
run: |
BASE_VERSION="${VERSION%.*}.0"
gh release upload "selenium-$BASE_VERSION" build/dist/* --clobber
gh release edit "selenium-$BASE_VERSION" --draft=false
generate-docs:
name: Generate ${{ matrix.language }} Documentation
needs: [parse-tag, check-authorization, create-tag]
permissions:
contents: write
strategy:
fail-fast: false
matrix:
language: ${{ fromJSON(needs.parse-tag.outputs.languages) }}
uses: ./.github/workflows/update-documentation.yml
with:
tag: ${{ needs.parse-tag.outputs.tag }}
language: ${{ matrix.language }}
commit: false
docs:
name: Update Documentation
needs: [parse-tag, generate-docs, publish, publish-python, github-release-publish, create-tag]
if: >-
always() && !cancelled() &&
needs.generate-docs.result != 'skipped' &&
needs.publish.result == 'success' &&
(needs.publish-python.result == 'success' || !contains(fromJSON(needs.parse-tag.outputs.languages), 'python')) &&
needs.github-release-publish.result != 'failure' &&
needs.create-tag.result != 'failure'
permissions:
contents: write
uses: ./.github/workflows/update-documentation.yml
with:
tag: ${{ needs.parse-tag.outputs.tag }}
generate: false
verify:
name: Verify ${{ matrix.language }}
needs: [parse-tag, create-tag, publish, publish-python]
if: >-
always() && !cancelled() &&
needs.create-tag.result == 'success' &&
needs.publish.result == 'success' &&
(needs.publish-python.result == 'success' || !contains(fromJSON(needs.parse-tag.outputs.languages), 'python'))
permissions:
contents: read
strategy:
fail-fast: false
matrix:
language: ${{ fromJSON(needs.parse-tag.outputs.languages) }}
runs-on: ubuntu-latest
env:
SEL_M2_USER: ${{ secrets.SEL_M2_USER }}
SEL_M2_PASS: ${{ secrets.SEL_M2_PASS }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.parse-tag.outputs.tag }}
- name: Verify the registry serves the release
run: ./go ${{ matrix.language }}:verify
- name: Slack Notification
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_ICON_EMOJI: ':rotating_light:'
SLACK_COLOR: failure
SLACK_CHANNEL: selenium-tlc
SLACK_USERNAME: GitHub Workflows
SLACK_MESSAGE: |
Could not verify ${{ matrix.language }} ${{ needs.parse-tag.outputs.version }} on its registry. Check the Verify job, then the registry.
<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|view run>
MSG_MINIMAL: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
reset-version:
name: Generate Nightly Versions
needs: [parse-tag, check-authorization]
uses: ./.github/workflows/upload-changes.yml
with:
name: Reset versions
run: ./go ${{ needs.parse-tag.outputs.language }}:version nightly${{ needs.parse-tag.outputs.language == 'all' && ' && ./go rust:version nightly' || '' }}
artifact-name: version-reset
# A rerun builds from trunk HEAD, so the nightly versions must not land there until every publish has succeeded.
update-version:
name: Push Nightly Versions
needs: [parse-tag, reset-version, publish, publish-python]
if: >-
always() && !cancelled() &&
needs.reset-version.result == 'success' &&
needs.publish.result == 'success' &&
(needs.publish-python.result == 'success' || !contains(fromJSON(needs.parse-tag.outputs.languages), 'python'))
permissions:
contents: write
actions: read
uses: ./.github/workflows/commit-changes.yml
with:
ref: trunk
artifact-name: version-reset
commit-message: "[build] Reset versions to nightly after ${{ needs.parse-tag.outputs.tag }} release"
secrets:
SELENIUM_CI_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
# The mirror job needs a grid artifact in the nightly GitHub release. This build job can run any time,
# but nightly-grid-publish has to sit between github-release-publish and mirror.
nightly-grid-build:
name: Build Nightly Grid
needs: [parse-tag, check-authorization]
if: needs.parse-tag.outputs.language == 'all'
uses: ./.github/workflows/bazel.yml
with:
name: Build Nightly Grid
run: ./go java:version nightly && ./go java:package --config=rbe_release
artifact-name: nightly-grid
artifact-path: build/dist/*.*
nightly-grid-publish:
name: Publish Nightly Grid
needs: [parse-tag, nightly-grid-build, github-release-publish]
if: needs.parse-tag.outputs.language == 'all'
permissions:
contents: write
uses: ./.github/workflows/release-grid.yml
with:
artifact-name: nightly-grid
mirror:
name: Update Release Mirror
needs: [parse-tag, update-version, nightly-grid-publish]
if: needs.parse-tag.outputs.language == 'all'
uses: ./.github/workflows/mirror-selenium-releases.yml
secrets: inherit
docker-selenium:
name: Start docker-selenium Release
needs: [parse-tag, github-release-publish]
if: needs.parse-tag.outputs.language == 'all'
runs-on: ubuntu-latest
continue-on-error: true
permissions: {}
steps:
- name: Dispatch Release Preparation
env:
GH_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
VERSION: ${{ needs.parse-tag.outputs.version }}
run: gh workflow run release-preparation.yml -R SeleniumHQ/docker-selenium -f grid-version="$VERSION"
unrestrict-trunk:
name: Unrestrict Trunk Branch
needs: [parse-tag, publish, publish-python, update-version, mirror]
if: >-
always() && !cancelled() &&
needs.publish.result == 'success' &&
(needs.publish-python.result == 'success' || !contains(fromJSON(needs.parse-tag.outputs.languages), 'python')) &&
needs.update-version.result == 'success' &&
(needs.parse-tag.outputs.language != 'all' || needs.mirror.result == 'success')
uses: ./.github/workflows/restrict-trunk.yml
with:
unlock: true
skip-notification: true
secrets:
SELENIUM_CI_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
on-release-complete:
name: On Release Complete
runs-on: ubuntu-latest
needs: [extract-tag, parse-tag, check-authorization, publish, publish-python, generate-docs, docs, create-tag, github-release-draft, github-release-publish, reset-version, update-version, nightly-grid-build, nightly-grid-publish, mirror, unrestrict-trunk]
if: always() && !cancelled() && needs.extract-tag.result != 'skipped' && needs.check-authorization.result != 'failure'
permissions:
actions: read
contents: read
steps:
- name: Checkout release scripts
uses: actions/checkout@v6
with:
sparse-checkout: scripts/github-actions
persist-credentials: false
- name: Summarize release
id: summary
env:
TAG: ${{ needs.parse-tag.outputs.tag || needs.extract-tag.outputs.tag }}
LANGUAGES: ${{ needs.parse-tag.outputs.languages }}
UNLOCK: ${{ needs.unrestrict-trunk.result }}
run: ./scripts/github-actions/release-summary.sh
- name: Slack Notification
if: ${{ !cancelled() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_ICON_EMOJI: ${{ steps.summary.outputs.icon || ':warning:' }}
SLACK_COLOR: ${{ steps.summary.outputs.color || 'warning' }}
SLACK_CHANNEL: selenium-tlc
SLACK_USERNAME: GitHub Workflows
SLACK_MESSAGE: |
${{ steps.summary.outputs.message || format('{0} release finished, but its summary could not be built.', needs.extract-tag.outputs.tag) }}
<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|view run>
MSG_MINIMAL: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}