Skip to content

Commit 486000e

Browse files
committed
Add support for running tools from different ref
When you manually have to run this workflow updates to the tooling cannot be used without updating the release branch. To workaround this, we support a split between the release on which we act and the tooling we use.
1 parent 759de82 commit 486000e

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

.github/workflows/finalize-release.yml

+36-9
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ on:
99
inputs:
1010
ref:
1111
description: |
12-
The release branch to finalize.
12+
The ref of release to finalize (e.g., 'rc/MAJOR.MINOR.PATCH').
1313
required: true
14+
tool-ref:
15+
description: |
16+
The ref to the tooling to use for the finalize (e.g., 'rc/MAJOR.MINOR.PATCH').
17+
required: false
1418

1519
jobs:
1620
finalize-release:
@@ -20,14 +24,17 @@ jobs:
2024
- name: Determine ref
2125
env:
2226
REF_FROM_INPUT: ${{ inputs.ref }}
27+
TOOL_REF_FROM_INPUT: ${{ inputs.tool-ref }}
2328
REF_FROM_PR: ${{ github.event.pull_request.merge_commit_sha }}
2429
BASE_REF_FROM_PR: ${{ github.event.pull_request.base.ref }}
2530
run: |
2631
if [[ $GITHUB_EVENT_NAME == "workflow_dispatch" ]]; then
2732
echo "REF=$REF_FROM_INPUT" >> "$GITHUB_ENV"
33+
echo "TOOL_REF=$TOOL_REF_FROM_INPUT" >> "$GITHUB_ENV"
2834
echo "BASE_REF=$REF_FROM_INPUT" >> "$GITHUB_ENV"
2935
else
3036
echo "REF=$REF_FROM_PR" >> "$GITHUB_ENV"
37+
echo "TOOL_REF=$REF_FROM_PR" >> "$GITHUB_ENV"
3138
echo "BASE_REF=$BASE_REF_FROM_PR" >> "$GITHUB_ENV"
3239
fi
3340
@@ -36,6 +43,13 @@ jobs:
3643
with:
3744
ref: ${{ env.REF }}
3845
fetch-depth: 0
46+
path: release
47+
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
with:
51+
ref: ${{ env.TOOL_REF }}
52+
path: tooling
3953

4054
- name: Install Python
4155
uses: actions/setup-python@v4
@@ -44,11 +58,13 @@ jobs:
4458

4559
- name: Install dependencies
4660
run: pip install -r scripts/release/requirements.txt
61+
working-directory: tooling
4762

4863
- name: Configure git
4964
run: |
5065
git config user.name "$GITHUB_ACTOR"
5166
git config user.email "[email protected]"
67+
working-directory: release
5268

5369
- name: Update release tag
5470
run: |
@@ -57,6 +73,7 @@ jobs:
5773
5874
git tag -f -a v$version -m "Release v$version"
5975
git push --force origin v$version
76+
working-directory: release
6077

6178
- name: Finalize release
6279
env:
@@ -66,30 +83,40 @@ jobs:
6683
echo "Finalizing release v$version"
6784
6885
gh release edit "v$version" --draft=false --tag=v$version
86+
working-directory: release
6987

7088
- name: Determine if release was a hotfix release
7189
run: |
7290
version=${BASE_REF#rc/}
73-
echo "HOTFIX_RELEASE=$(python scripts/release/is-hotfix-release.py $version)" >> "$GITHUB_ENV"
91+
# We are running the script in the tooling directory with the release directory as the working directory
92+
echo "HOTFIX_RELEASE=$(python ../tooling/scripts/release/is-hotfix-release.py $version)" >> "$GITHUB_ENV"
93+
working-directory: release
94+
95+
- name: Determine next release version
96+
if: env.HOTFIX_RELEASE == 'false'
97+
run: |
98+
version=${BASE_REF#rc/}
99+
next_version=$(python scripts/release/next-version.py --component minor --pre-release dev -- $version)
100+
echo "NEXT_VERSION=$next_version" >> "$GITHUB_ENV"
101+
working-directory: tooling
74102

75103
- name: Bump main version
76-
if: env.HOTFIX_RELEASE == 'false'
77104
env:
78105
GH_TOKEN: ${{ github.token }}
79106
run: |
80-
version=${BASE_REF#rc/}
81-
next_version=$(python scripts/release/next-version.py --component minor --pre-release dev -- $version)
82-
echo "Bumping main version to $next_version"
107+
echo "Bumping main version to $NEXT_VERSION"
83108
84109
git switch main
85110
git pull --ff-only origin main
86111
87112
git switch -c release-automation/bump-version
88113
89-
./scripts/release/bump-version.sh "$next_version"
114+
# We are running the script in the tooling directory with the release directory as the working directory
115+
../tooling/scripts/release/bump-version.sh "$NEXT_VERSION"
90116
91117
git add -u .
92-
git commit -m "Bump version to $next_version"
118+
git commit -m "Bump version to $NEXT_VERSION"
93119
git push --set-upstream origin release-automation/bump-version
94120
95-
gh pr create --repo $GITHUB_REPOSITORY --base main --head release-automation/bump-version --body "Bump the version of main to the dev label of the just released version $next_version" --title "Bump version to $next_version"
121+
gh pr create --repo $GITHUB_REPOSITORY --base main --head release-automation/bump-version --body "Bump the version of main to $NEXT_VERSION" --title "Bump version to $NEXT_VERSION"
122+
working-directory: release

0 commit comments

Comments
 (0)