Skip to content

Commit

Permalink
Remove flags from release (#3521)
Browse files Browse the repository at this point in the history
## Motivation and Context
This removes the (unneeded) flags from the smithy-rs release job that
set the stable/unstable versions.

## Testing
- [x] ran a dry run on the branch

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
  • Loading branch information
rcoh authored Mar 29, 2024
1 parent 58d40b7 commit 0b9a2b8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 138 deletions.
30 changes: 1 addition & 29 deletions .github/scripts/get-or-create-release-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,18 @@
#
set -eux

# Compute the name of the release branch starting from the version that needs to be released ($SEMANTIC_VERSION).
# If it's the beginning of a new release series, the branch is created and pushed to the remote (chosen according to
# the value $DRY_RUN).
#
# The script populates an output file with key-value pairs that are needed in the release CI workflow to carry out
# the next steps in the release flow: the name of the release branch and a boolean flag that is set to 'true' if this
# is the beginning of a new release series.

if [ -z "$SEMANTIC_VERSION" ]; then
echo "'SEMANTIC_VERSION' must be populated."
exit 1
fi

if [ -z "$1" ]; then
echo "You need to specify the path of the file where you want to collect the output"
exit 1
else
output_file="$1"
fi

# Split on the dots
version_array=(${SEMANTIC_VERSION//./ })
major=${version_array[0]}
minor=${version_array[1]}
patch=${version_array[2]}
if [[ "${major}" == "" || "${minor}" == "" || "${patch}" == "" ]]; then
echo "'${SEMANTIC_VERSION}' is not a valid semver tag"
exit 1
fi
if [[ $major == 0 ]]; then
branch_name="smithy-rs-release-${major}.${minor}.x"
if [[ $patch == 0 ]]; then
echo "new_release_series=true" >"${output_file}"
fi
else
branch_name="smithy-rs-release-${major}.x.y"
if [[ $minor == 0 && $patch == 0 ]]; then
echo "new_release_series=true" >"${output_file}"
fi
fi
branch_name="smithy-rs-release-1.x.y"

if [[ "${DRY_RUN}" == "true" ]]; then
branch_name="${branch_name}-preview"
Expand Down
85 changes: 4 additions & 81 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
rust_version: 1.74.1

name: Release smithy-rs
run-name: ${{ inputs.dry_run && 'Dry run' || 'Prod run' }} - ${{ github.workflow }} ${{ inputs.stable_semantic_version }}/${{ inputs.unstable_semantic_version }} (${{ inputs.commit_sha }})
run-name: ${{ inputs.dry_run && 'Dry run' || 'Prod run' }} - ${{ github.workflow }} (${{ inputs.commit_sha }})
on:
workflow_dispatch:
inputs:
Expand All @@ -23,16 +23,6 @@ on:
You must use the non-abbreviated SHA (e.g. b2318b0 won't work!).
required: true
type: string
stable_semantic_version:
description: |
Stable semantic version: The semver tag that you want to release for stable crates (e.g. 1.0.2)
required: true
type: string
unstable_semantic_version:
description: |
Unstable semantic version: The semver tag that you want to release for unstable crates (e.g. 0.52.1)
required: true
type: string
dry_run:
description: |
Dry run: When selected, it only produces release artifacts, but will not cut a release tag in GitHub or publish to crates.io
Expand Down Expand Up @@ -122,7 +112,6 @@ jobs:
uses: ./smithy-rs/.github/actions/docker-build
with:
action: check-semver-hazards
action-arguments: ${{ inputs.stable_semantic_version }} ${{ inputs.unstable_semantic_version }}

get-or-create-release-branch:
name: Get or create a release branch
Expand Down Expand Up @@ -150,83 +139,17 @@ jobs:
id: branch-push
shell: bash
env:
SEMANTIC_VERSION: ${{ inputs.stable_semantic_version }}
DRY_RUN: ${{ inputs.dry_run }}
run: |
set -e
./.github/scripts/get-or-create-release-branch.sh output
cat output > $GITHUB_OUTPUT
upgrade-gradle-properties:
name: Upgrade gradle.properties
needs:
- get-or-create-release-branch
# See https://github.com/actions/runner/issues/2205#issuecomment-1381988186 for an explanation as to why
# we need this here _even though_ the job we depend on is never skipped.
if: |
always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
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@v4
with:
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
with:
action: upgrade-gradle-properties
action-arguments: ${{ inputs.stable_semantic_version }} ${{ inputs.unstable_semantic_version }}
- name: Download all artifacts
uses: ./smithy-rs/.github/actions/download-all-artifacts
- name: Push gradle.properties changes
id: gradle-push
working-directory: upgrade-gradle-properties/smithy-rs
shell: bash
env:
SEMANTIC_VERSION: ${{ inputs.stable_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
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 'user.email=aws-sdk-rust-primary@amazon.com' 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.
if [[ "${DRY_RUN}" == "true" ]]; then
# During dry-runs, "git push" without "--force" can fail if smithy-rs-release-x.y.z-preview is behind
# smithy-rs-release-x.y.z, but that does not matter much during dry-runs.
git push --force origin "HEAD:refs/heads/${RELEASE_BRANCH_NAME}"
else
git push origin "HEAD:refs/heads/${RELEASE_BRANCH_NAME}"
fi
echo "commit_sha=$(git rev-parse HEAD)" > $GITHUB_OUTPUT
else
echo "commit_sha=${RELEASE_COMMIT_SHA}" > $GITHUB_OUTPUT
fi
release:
name: Release
needs:
- upgrade-gradle-properties
- get-or-create-release-branch
# See https://github.com/actions/runner/issues/2205#issuecomment-1381988186 for an explanation as to why
# we need this here _even though_ the job we depend on is never skipped.
if: |
Expand All @@ -242,7 +165,7 @@ jobs:
- name: Checkout smithy-rs
uses: actions/checkout@v4
with:
ref: ${{ needs.upgrade-gradle-properties.outputs.commit_sha }}
ref: ${{ inputs.commit_sha }}
path: smithy-rs
token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }}
- name: Generate release artifacts
Expand All @@ -256,7 +179,7 @@ jobs:
working-directory: smithy-rs-release/smithy-rs
id: push-changelog
env:
RELEASE_BRANCH_NAME: ${{ needs.upgrade-gradle-properties.outputs.release_branch }}
RELEASE_BRANCH_NAME: ${{ needs.get-or-create-release-branch.outputs.release_branch }}
DRY_RUN: ${{ inputs.dry_run }}
run: |
if ! git diff-index --quiet HEAD; then
Expand Down
28 changes: 0 additions & 28 deletions tools/ci-scripts/upgrade-gradle-properties

This file was deleted.

0 comments on commit 0b9a2b8

Please sign in to comment.