1414 description : Release version (X.Y.Z)
1515 required : true
1616 type : string
17- pull_request :
18- types : [closed]
19- branches :
20- - develop
21- - main
2217
2318permissions :
2419 actions : write
2520 contents : write
26- pull-requests : read
2721
2822concurrency :
29- group : release-${{ github.event_name == 'workflow_dispatch' && inputs.target_branch || github.event.pull_request.base.ref }}
23+ group : release-${{ inputs.target_branch }}
3024 cancel-in-progress : false
3125
3226env :
3327 CARGO_TERM_COLOR : always
34- MAIN_BASE_VERSION : ${{ vars.MAIN_BASE_VERSION }}
35- DEVELOP_BASE_VERSION : ${{ vars.DEVELOP_BASE_VERSION }}
3628
3729jobs :
3830 plan :
39- if : github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true
4031 runs-on : ubuntu-latest
4132 outputs :
42- should_release : ${{ steps.plan.outputs.should_release }}
43- reason : ${{ steps.plan.outputs.reason }}
44- bump : ${{ steps.plan.outputs.bump }}
45- base_version : ${{ steps.plan.outputs.base_version }}
4633 previous_version : ${{ steps.plan.outputs.previous_version }}
4734 version : ${{ steps.plan.outputs.version }}
4835 target_branch : ${{ steps.plan.outputs.target_branch }}
49- source_branch : ${{ steps.plan.outputs.source_branch }}
50- merge_sha : ${{ steps.context.outputs.merge_sha }}
5136 steps :
5237 - name : Checkout selected branch
53- if : github.event_name == 'workflow_dispatch'
5438 uses : actions/checkout@v4
5539 with :
5640 ref : ${{ inputs.target_branch }}
5741 fetch-depth : 0
5842
59- - name : Checkout merge commit
60- if : github.event_name == 'pull_request'
61- uses : actions/checkout@v4
62- with :
63- ref : ${{ github.event.pull_request.merge_commit_sha }}
64- fetch-depth : 0
65-
6643 - name : Fetch tags
6744 run : git fetch --force --tags
6845
69- - name : Resolve base versions
70- id : bases
71- shell : bash
72- run : |
73- set -euo pipefail
74-
75- current_version="$(
76- sed -nE 's/^version = "([0-9]+\.[0-9]+\.[0-9]+)"/\1/p' Cargo.toml | head -n1
77- )"
78-
79- if [[ -z "${current_version}" ]]; then
80- echo "Could not determine the current Cargo version." >&2
81- exit 1
82- fi
83-
84- echo "main_base_version=${MAIN_BASE_VERSION:-$current_version}" >> "$GITHUB_OUTPUT"
85- echo "develop_base_version=${DEVELOP_BASE_VERSION:-$current_version}" >> "$GITHUB_OUTPUT"
86-
87- - name : Resolve release context
88- id : context
89- shell : bash
90- run : |
91- set -euo pipefail
92-
93- if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
94- echo "target_branch=${{ inputs.target_branch }}" >> "$GITHUB_OUTPUT"
95- echo "source_branch=workflow_dispatch" >> "$GITHUB_OUTPUT"
96- echo "release_version=${{ inputs.version }}" >> "$GITHUB_OUTPUT"
97- echo "merge_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
98- else
99- echo "target_branch=${{ github.event.pull_request.base.ref }}" >> "$GITHUB_OUTPUT"
100- echo "source_branch=${{ github.event.pull_request.head.ref }}" >> "$GITHUB_OUTPUT"
101- echo "release_version=" >> "$GITHUB_OUTPUT"
102- echo "merge_sha=${{ github.event.pull_request.merge_commit_sha }}" >> "$GITHUB_OUTPUT"
103- fi
104-
10546 - name : Plan release
10647 id : plan
10748 env :
108- TARGET_BRANCH : ${{ steps.context.outputs.target_branch }}
109- SOURCE_BRANCH : ${{ steps.context.outputs.source_branch }}
110- RELEASE_VERSION : ${{ steps.context.outputs.release_version }}
111- MAIN_BASE_VERSION : ${{ steps.bases.outputs.main_base_version }}
112- DEVELOP_BASE_VERSION : ${{ steps.bases.outputs.develop_base_version }}
49+ TARGET_BRANCH : ${{ inputs.target_branch }}
50+ RELEASE_VERSION : ${{ inputs.version }}
11351 run : devops/ga-release-plan.sh
11452
115- - name : Stop on non-release branches
116- if : steps.plan.outputs.should_release != 'true'
117- shell : bash
118- run : |
119- echo "Skipping release: ${{ steps.plan.outputs.reason }}"
120-
12153 prepare_release :
12254 needs : plan
123- if : needs.plan.outputs.should_release == 'true'
12455 runs-on : ubuntu-latest
12556 outputs :
12657 release_sha : ${{ steps.release_commit.outputs.release_sha }}
@@ -142,17 +73,6 @@ jobs:
14273 exit 1
14374 fi
14475
145- - name : Ensure release commit includes merged change
146- if : github.event_name == 'pull_request'
147- shell : bash
148- run : |
149- set -euo pipefail
150-
151- if ! git merge-base --is-ancestor "${{ needs.plan.outputs.merge_sha }}" HEAD; then
152- echo "The target branch no longer contains merge commit ${{ needs.plan.outputs.merge_sha }}." >&2
153- exit 1
154- fi
155-
15676 - name : Configure git author
15777 run : |
15878 git config user.name "github-actions[bot]"
@@ -189,7 +109,6 @@ jobs:
189109
190110 create_release :
191111 needs : [plan, prepare_release]
192- if : needs.plan.outputs.should_release == 'true'
193112 runs-on : ubuntu-latest
194113 steps :
195114 - name : Check out release commit
@@ -205,7 +124,7 @@ jobs:
205124 set -euo pipefail
206125
207126 NOTES_ARGS=()
208- if [[ "${{ needs.plan.outputs.previous_version }}" != " ${{ needs.plan.outputs.base_version }}" ]]; then
127+ if [[ -n " ${{ needs.plan.outputs.previous_version }}" ]]; then
209128 NOTES_ARGS+=(-f previous_tag_name="${{ needs.plan.outputs.previous_version }}")
210129 fi
211130
0 commit comments