@@ -113,11 +113,13 @@ jobs:
113
113
runs-on : ubuntu-latest
114
114
outputs :
115
115
release_branch : ${{ needs.get-or-create-release-branch.outputs.release_branch }}
116
+ commit_sha : ${{ steps.gradle-push.outputs.commit_sha }}
116
117
steps :
117
118
- uses : actions/checkout@v3
118
119
with :
119
- ref : ${{ needs.get-or-create-release-branch.outputs.release_branch }}
120
+ ref : ${{ inputs.commit_sha }}
120
121
path : smithy-rs
122
+ fetch-depth : 0
121
123
token : ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }}
122
124
- name : Upgrade gradle.properties
123
125
uses : ./smithy-rs/.github/actions/docker-build
@@ -132,13 +134,30 @@ jobs:
132
134
shell : bash
133
135
env :
134
136
SEMANTIC_VERSION : ${{ inputs.semantic_version }}
137
+ RELEASE_COMMIT_SHA : ${{ inputs.commit_sha }}
138
+ RELEASE_BRANCH_NAME : ${{ needs.get-or-create-release-branch.outputs.release_branch }}
135
139
DRY_RUN : ${{ inputs.dry_run }}
136
140
run : |
137
141
set -x
142
+
138
143
# For debugging purposes
139
144
git status
140
- # The file was actually changed, we need to commit the changes
141
- git diff-index --quiet HEAD || { git -c 'user.name=AWS SDK Rust Bot' -c 'user.email=aws-sdk-rust-primary@amazon.com' commit gradle.properties --message "Upgrade the smithy-rs runtime crates version to ${SEMANTIC_VERSION}" && git push origin; }
145
+
146
+ if ! git diff-index --quiet HEAD; then
147
+ # gradle.properties was changed, we need to commit and push the diff
148
+ git -c 'user.name=AWS SDK Rust Bot' -c 'user.email=aws-sdk-rust-primary@amazon.com' commit gradle.properties --message "Upgrade the smithy-rs runtime crates version to ${SEMANTIC_VERSION}"
149
+
150
+ # This will fail if we tried to release from a non-HEAD commit on the release branch.
151
+ # The only scenario where we would try to release a non-HEAD commit from the release branch is
152
+ # to retry a release action execution that failed due to a transient issue.
153
+ # In that case, we expect the commit to be releasable as-is, i.e. the runtime crate version in gradle.properties
154
+ # should already be the expected one.
155
+ git push origin "HEAD:refs/heads/${RELEASE_BRANCH_NAME}"
156
+
157
+ echo "commit_sha=$(git rev-parse HEAD)" > $GITHUB_OUTPUT
158
+ else
159
+ echo "commit_sha=${RELEASE_COMMIT_SHA}" > $GITHUB_OUTPUT
160
+ fi
142
161
143
162
release :
144
163
name : Release
@@ -159,7 +178,7 @@ jobs:
159
178
- name : Checkout smithy-rs
160
179
uses : actions/checkout@v3
161
180
with :
162
- ref : ${{ needs.upgrade-gradle-properties.outputs.release_branch }}
181
+ ref : ${{ needs.upgrade-gradle-properties.outputs.commit_sha }}
163
182
path : smithy-rs
164
183
token : ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }}
165
184
- name : Generate release artifacts
@@ -171,9 +190,20 @@ jobs:
171
190
- name : Push smithy-rs changes
172
191
shell : bash
173
192
working-directory : smithy-rs-release/smithy-rs
193
+ id : push-changelog
194
+ env :
195
+ RELEASE_BRANCH_NAME : ${{ needs.upgrade-gradle-properties.outputs.release_branch }}
174
196
run : |
175
- echo "Pushing release commits..."
176
- git push origin
197
+ if ! git diff-index --quiet HEAD; then
198
+ echo "Pushing release commits..."
199
+ # This will fail if we tried to release from a non-HEAD commit on the release branch.
200
+ # The only scenario where we would try to release a non-HEAD commit from the release branch is
201
+ # to retry a release action execution that failed due to a transient issue.
202
+ # In that case, we expect the commit to be releasable as-is, i.e. the changelog should have already
203
+ # been processed.
204
+ git push origin "HEAD:refs/heads/${RELEASE_BRANCH_NAME}"
205
+ fi
206
+ echo "commit_sha=$(git rev-parse HEAD)" > $GITHUB_OUTPUT
177
207
- name : Tag release
178
208
uses : actions/github-script@v6
179
209
with :
@@ -184,7 +214,7 @@ jobs:
184
214
github,
185
215
isDryRun: ${{ inputs.dry_run }},
186
216
releaseManifestPath: "smithy-rs-release/smithy-rs-release-manifest.json"
187
- releaseCommitish: ${{ needs.upgrade-gradle-properties .outputs.release_branch }},
217
+ releaseCommitish: ${{ steps.push-changelog .outputs.commit_sha }}
188
218
});
189
219
- name : Publish to crates.io
190
220
shell : bash
0 commit comments