forked from smithy-lang/smithy-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Idempotent release action (smithy-lang#2353)
* Do not require the released commit to be at the tip of the branch. * Update comment. * If you release an old commit, it must be ready to go as is. * Tag the commit that updates gradle.properties. * Check out the specific commit instead of the branch. * Simplify. * We need to set the release branch. * You can't refer to outputs directly. * Make sure to tag the right commit. * Pass the commit SHA explicitly.
- Loading branch information
1 parent
c060263
commit f705bde
Showing
2 changed files
with
39 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,11 +113,13 @@ jobs: | |
runs-on: ubuntu-latest | ||
outputs: | ||
release_branch: ${{ needs.get-or-create-release-branch.outputs.release_branch }} | ||
commit_sha: ${{ steps.gradle-push.outputs.commit_sha }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ needs.get-or-create-release-branch.outputs.release_branch }} | ||
ref: ${{ inputs.commit_sha }} | ||
path: smithy-rs | ||
fetch-depth: 0 | ||
token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }} | ||
- name: Upgrade gradle.properties | ||
uses: ./smithy-rs/.github/actions/docker-build | ||
|
@@ -132,13 +134,30 @@ jobs: | |
shell: bash | ||
env: | ||
SEMANTIC_VERSION: ${{ inputs.semantic_version }} | ||
RELEASE_COMMIT_SHA: ${{ inputs.commit_sha }} | ||
RELEASE_BRANCH_NAME: ${{ needs.get-or-create-release-branch.outputs.release_branch }} | ||
DRY_RUN: ${{ inputs.dry_run }} | ||
run: | | ||
set -x | ||
# For debugging purposes | ||
git status | ||
# The file was actually changed, we need to commit the changes | ||
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; } | ||
if ! git diff-index --quiet HEAD; then | ||
# gradle.properties was changed, we need to commit and push the diff | ||
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}" | ||
# This will fail if we tried to release from a non-HEAD commit on the release branch. | ||
# The only scenario where we would try to release a non-HEAD commit from the release branch is | ||
# to retry a release action execution that failed due to a transient issue. | ||
# In that case, we expect the commit to be releasable as-is, i.e. the runtime crate version in gradle.properties | ||
# should already be the expected one. | ||
git push origin "HEAD:refs/heads/${RELEASE_BRANCH_NAME}" | ||
echo "commit_sha=$(git rev-parse HEAD)" > $GITHUB_OUTPUT | ||
else | ||
echo "commit_sha=${RELEASE_COMMIT_SHA}" > $GITHUB_OUTPUT | ||
fi | ||
release: | ||
name: Release | ||
|
@@ -159,7 +178,7 @@ jobs: | |
- name: Checkout smithy-rs | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ needs.upgrade-gradle-properties.outputs.release_branch }} | ||
ref: ${{ needs.upgrade-gradle-properties.outputs.commit_sha }} | ||
path: smithy-rs | ||
token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }} | ||
- name: Generate release artifacts | ||
|
@@ -171,9 +190,20 @@ jobs: | |
- name: Push smithy-rs changes | ||
shell: bash | ||
working-directory: smithy-rs-release/smithy-rs | ||
id: push-changelog | ||
env: | ||
RELEASE_BRANCH_NAME: ${{ needs.upgrade-gradle-properties.outputs.release_branch }} | ||
run: | | ||
echo "Pushing release commits..." | ||
git push origin | ||
if ! git diff-index --quiet HEAD; then | ||
echo "Pushing release commits..." | ||
# This will fail if we tried to release from a non-HEAD commit on the release branch. | ||
# The only scenario where we would try to release a non-HEAD commit from the release branch is | ||
# to retry a release action execution that failed due to a transient issue. | ||
# In that case, we expect the commit to be releasable as-is, i.e. the changelog should have already | ||
# been processed. | ||
git push origin "HEAD:refs/heads/${RELEASE_BRANCH_NAME}" | ||
fi | ||
echo "commit_sha=$(git rev-parse HEAD)" > $GITHUB_OUTPUT | ||
- name: Tag release | ||
uses: actions/github-script@v6 | ||
with: | ||
|
@@ -184,7 +214,7 @@ jobs: | |
github, | ||
isDryRun: ${{ inputs.dry_run }}, | ||
releaseManifestPath: "smithy-rs-release/smithy-rs-release-manifest.json" | ||
releaseCommitish: ${{ needs.upgrade-gradle-properties.outputs.release_branch }}, | ||
releaseCommitish: ${{ steps.push-changelog.outputs.commit_sha }} | ||
}); | ||
- name: Publish to crates.io | ||
shell: bash | ||
|