Skip to content

Commit e51d822

Browse files
authored
chore(release): release automation fixes and refactoring (#3885)
- Fix promote_rc dry run message to use correct remote. - Support spaces in metadata parsing and format commit SHA with space for GitHub autolinking. - Trigger release publish workflow from create_rc workflow using workflow_call. - Replace version markers during backport processing. - Split release_test.py into separate files for each command. - Refactor release tool BUILD targets to use py_library and glob.
1 parent e433644 commit e51d822

20 files changed

Lines changed: 2048 additions & 1741 deletions

.github/workflows/release_create_rc.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ permissions:
1313
issues: write
1414

1515
jobs:
16-
generate_rc:
16+
tag_rc:
1717
runs-on: ubuntu-latest
18+
outputs:
19+
tag_name: ${{ steps.tagger.outputs.tag_name }}
1820
steps:
1921
- name: Checkout repository
2022
uses: actions/checkout@v7
@@ -32,8 +34,16 @@ jobs:
3234
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
3335
3436
- name: Attempt RC Tagging
37+
id: tagger
3538
run: |
3639
bazel run //tools/private/release -- \
3740
create-rc --issue ${{ inputs.issue }} --remote origin
3841
env:
3942
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
44+
call_release:
45+
needs: tag_rc
46+
uses: ./.github/workflows/release_publish.yaml
47+
with:
48+
tag_name: ${{ needs.tag_rc.outputs.tag_name }}
49+
secrets: inherit
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
# Cut a release whenever a new tag is pushed to the repo.
16-
name: Release
16+
name: "Release: Publish"
1717

1818
on:
1919
push:
@@ -33,6 +33,17 @@ on:
3333
secrets:
3434
publish_token:
3535
required: false
36+
workflow_call:
37+
inputs:
38+
tag_name:
39+
description: "release tag: tag that will be released"
40+
required: true
41+
type: string
42+
publish_to_pypi:
43+
description: 'Publish to PyPI'
44+
required: false
45+
type: boolean
46+
default: true
3647

3748
jobs:
3849
release:
@@ -42,7 +53,7 @@ jobs:
4253
- name: Checkout
4354
uses: actions/checkout@v7
4455
with:
45-
ref: ${{ github.ref_name }}
56+
ref: ${{ inputs.tag_name || github.ref_name }}
4657
- name: Create release archive and notes
4758
run: .github/workflows/create_archive_and_notes.sh ${{ inputs.tag_name || github.ref_name }}
4859
- name: Release
@@ -73,7 +84,7 @@ jobs:
7384
- name: Checkout
7485
uses: actions/checkout@v7
7586
with:
76-
ref: ${{ github.tag_name || github.ref_name }}
87+
ref: ${{ inputs.tag_name || github.ref_name }}
7788
- if: github.event_name == 'push' || github.event.inputs.publish_to_pypi
7889
env:
7990
# This special value tells pypi that the user identity is supplied within the token

RELEASING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ specific commit.
6666
To trigger the workflow, use the `gh workflow run` command:
6767

6868
```shell
69-
gh workflow run release.yml --ref <TAG>
69+
gh workflow run release_publish.yaml --ref <TAG>
7070
```
7171

7272
By default, the workflow will publish the wheel to PyPI. To skip this step,
7373
you can set the `publish_to_pypi` input to `false`:
7474

7575
```shell
76-
gh workflow run release.yml --ref <TAG> -f publish_to_pypi=false
76+
gh workflow run release_publish.yaml --ref <TAG> -f publish_to_pypi=false
7777
```
7878

7979
### Determining Semantic Version
Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,97 @@
1-
load("@rules_python//python:defs.bzl", "py_test")
1+
load("@rules_python//python:defs.bzl", "py_library", "py_test")
2+
3+
py_library(
4+
name = "release_test_helper",
5+
srcs = ["release_test_helper.py"],
6+
deps = [
7+
"//tools/private/release:release_lib",
8+
],
9+
)
10+
11+
py_test(
12+
name = "changelog_news_test",
13+
srcs = ["changelog_news_test.py"],
14+
deps = [
15+
":release_test_helper",
16+
"//tools/private/release:release_lib",
17+
],
18+
)
19+
20+
py_test(
21+
name = "create_rc_test",
22+
srcs = ["create_rc_test.py"],
23+
deps = [
24+
":release_test_helper",
25+
"//tools/private/release:release_lib",
26+
],
27+
)
28+
29+
py_test(
30+
name = "create_release_branch_test",
31+
srcs = ["create_release_branch_test.py"],
32+
deps = [
33+
":release_test_helper",
34+
"//tools/private/release:release_lib",
35+
],
36+
)
37+
38+
py_test(
39+
name = "git_test",
40+
srcs = ["git_test.py"],
41+
deps = [
42+
"//tools/private/release:release_lib",
43+
],
44+
)
45+
46+
py_test(
47+
name = "prepare_test",
48+
srcs = ["prepare_test.py"],
49+
deps = [
50+
":release_test_helper",
51+
"//tools/private/release:release_lib",
52+
],
53+
)
54+
55+
py_test(
56+
name = "process_backports_test",
57+
srcs = ["process_backports_test.py"],
58+
deps = [
59+
":release_test_helper",
60+
"//tools/private/release:release_lib",
61+
],
62+
)
63+
64+
py_test(
65+
name = "promote_rc_test",
66+
srcs = ["promote_rc_test.py"],
67+
deps = [
68+
":release_test_helper",
69+
"//tools/private/release:release_lib",
70+
],
71+
)
72+
73+
py_test(
74+
name = "release_issue_test",
75+
srcs = ["release_issue_test.py"],
76+
deps = [
77+
"//tools/private/release:release_lib",
78+
],
79+
)
280

381
py_test(
482
name = "release_test",
583
srcs = ["release_test.py"],
684
deps = [
7-
"//tools/private/release",
85+
"//tools/private/release:release_lib",
86+
],
87+
)
88+
89+
py_test(
90+
name = "utils_test",
91+
srcs = ["utils_test.py"],
92+
deps = [
93+
":release_test_helper",
94+
"//tools/private/release:release_lib",
895
"@dev_pip//packaging",
996
],
1097
)

0 commit comments

Comments
 (0)