Unverified Commit 0b9a2b8e authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Remove flags from release (#3521)

## 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._
parent 58d40b76
Loading
Loading
Loading
Loading
+1 −29
Original line number Diff line number Diff line
@@ -5,19 +5,10 @@
#
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
@@ -25,26 +16,7 @@ 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"
+4 −81
Original line number Diff line number Diff line
@@ -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:
@@ -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
@@ -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
@@ -150,7 +139,6 @@ jobs:
      id: branch-push
      shell: bash
      env:
        SEMANTIC_VERSION: ${{ inputs.stable_semantic_version }}
        DRY_RUN: ${{ inputs.dry_run }}
      run: |
        set -e
@@ -158,75 +146,10 @@ jobs:
        ./.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: |
@@ -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
@@ -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
+0 −28
Original line number Diff line number Diff line
#!/bin/bash
#
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
#

set -eux

STABLE_SEMANTIC_VERSION="${1}"
UNSTABLE_SEMANTIC_VERSION="${2}"
SMITHY_RS_DIR="$(pwd)/smithy-rs"
ARTIFACTS_DIR="$(pwd)/artifacts/upgrade-gradle-properties"
mkdir -p "${ARTIFACTS_DIR}"

pushd "${SMITHY_RS_DIR}"
echo "gradle.properties BEFORE the upgrade"
cat gradle.properties
publisher upgrade-runtime-crates-version --stable-version "${STABLE_SEMANTIC_VERSION}" --version "${UNSTABLE_SEMANTIC_VERSION}"
echo "gradle.properties AFTER the upgrade"
cat gradle.properties
git status
popd

pushd "${ARTIFACTS_DIR}"
mkdir -p smithy-rs
cp -r "${SMITHY_RS_DIR}" .
git -C smithy-rs status
popd