@@ -113,11 +113,13 @@ jobs:
113113 runs-on : ubuntu-latest
114114 outputs :
115115 release_branch : ${{ needs.get-or-create-release-branch.outputs.release_branch }}
116+ commit_sha : ${{ steps.gradle-push.outputs.commit_sha }}
116117 steps :
117118 - uses : actions/checkout@v3
118119 with :
119- ref : ${{ needs.get-or-create-release-branch.outputs.release_branch }}
120+ ref : ${{ inputs.commit_sha }}
120121 path : smithy-rs
122+ fetch-depth : 0
121123 token : ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }}
122124 - name : Upgrade gradle.properties
123125 uses : ./smithy-rs/.github/actions/docker-build
@@ -132,13 +134,30 @@ jobs:
132134 shell : bash
133135 env :
134136 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 }}
135139 DRY_RUN : ${{ inputs.dry_run }}
136140 run : |
137141 set -x
142+
138143 # For debugging purposes
139144 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 '[email protected] ' 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 '[email protected] ' 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
142161
143162 release :
144163 name : Release
@@ -159,7 +178,7 @@ jobs:
159178 - name : Checkout smithy-rs
160179 uses : actions/checkout@v3
161180 with :
162- ref : ${{ needs.upgrade-gradle-properties.outputs.release_branch }}
181+ ref : ${{ needs.upgrade-gradle-properties.outputs.commit_sha }}
163182 path : smithy-rs
164183 token : ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }}
165184 - name : Generate release artifacts
@@ -171,9 +190,20 @@ jobs:
171190 - name : Push smithy-rs changes
172191 shell : bash
173192 working-directory : smithy-rs-release/smithy-rs
193+ id : push-changelog
194+ env :
195+ RELEASE_BRANCH_NAME : ${{ needs.upgrade-gradle-properties.outputs.release_branch }}
174196 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
177207 - name : Tag release
178208 uses : actions/github-script@v6
179209 with :
@@ -184,7 +214,7 @@ jobs:
184214 github,
185215 isDryRun: ${{ inputs.dry_run }},
186216 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 }}
188218 });
189219 - name : Publish to crates.io
190220 shell : bash
0 commit comments