Unverified Commit de4bc454 authored by ysaito1001's avatar ysaito1001 Committed by GitHub
Browse files

Allow multiple releases per day in the smithy-rs repository (#3875)

## Motivation and Context
Currently, we can only make one `smithy-rs` release per day, and this
restricts our ability to respond to urgent issues. This PR lifts that
limitation, allowing us to make multiple releases per day.

## Description
The core of this change is in the `render` subcommand of `changelogger`.
When generating a date-based release tag, it now checks for existing
tags on the same day. If a tag already exists, the `render` subcommand
will append a numerical suffix to ensure the new tag is unique.

In fact, appending a numerical suffix to make a release tag unique has
been a workaround in our release pipeline (outside the `smithy-rs`
repository) for quite some time. With the changes in this PR, we can
eliminate that temporary solution from the release pipeline.

Now that `changelogger` requires access to previous tags, CI steps that
run `generate-smithy-rs-release` need to checkout the `smithy-rs`
repository with all tags (`fetch-depth: 0` is for that purpose).

## Testing
- [x] Added unit tests for `changelogger`
- [x] Successfully bumped the release tag in
[dry-run](https://github.com/smithy-lang/smithy-rs/actions/runs/11356509152/job/31588857360#step:8:26)
(based on [this dummy
change](https://github.com/smithy-lang/smithy-rs/commit/cb19b31eaa506d66d9869261c920784ccc311b15)
to trick `changelogger` into thinking that it has to bump a release tag)
- [x] Successfully bumped the release tag in the release pipeline
(without the temporary hack we placed last year)

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent c8c610f1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -65,6 +65,9 @@ jobs:
      with:
        path: smithy-rs
        ref: ${{ inputs.git_ref }}
        # `generate-smithy-rs-release` requires access to previous tags to determine if a numerical suffix is needed
        # to make the release tag unique
        fetch-depth: 0
    # The models from aws-sdk-rust are needed to generate the full SDK for CI
    - uses: actions/checkout@v4
      with:
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ const assert = require("assert");
const fs = require("fs");

const smithy_rs_repo = {
    owner: "awslabs",
    owner: "smithy-lang",
    repo: "smithy-rs",
};

+24 −13
Original line number Diff line number Diff line
@@ -181,12 +181,18 @@ jobs:
        ref: ${{ inputs.commit_sha }}
        path: smithy-rs
        token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }}
        fetch-depth: 0
    - name: Generate release artifacts
      uses: ./smithy-rs/.github/actions/docker-build
      with:
        action: generate-smithy-rs-release
    - name: Download all artifacts
      uses: ./smithy-rs/.github/actions/download-all-artifacts
    # This step is not idempotent, as it pushes release artifacts to the `smithy-rs-release-1.x.y` branch. However,
    # if this step succeeds but a subsequent step fails, retrying the release workflow is "safe" in that it does not
    # create any inconsistent states; this step would simply fail because the release branch would be ahead of `main`
    # due to previously pushed artifacts.
    # To successfully retry a release, revert the commits in the release branch that pushed the artifacts.
    - name: Push smithy-rs changes
      shell: bash
      working-directory: smithy-rs-release/smithy-rs
@@ -202,7 +208,7 @@ jobs:
          # 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 fetch --unshallow
          git fetch
          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.
@@ -214,18 +220,7 @@ jobs:
          fi
        fi
        echo "commit_sha=$(git rev-parse HEAD)" > $GITHUB_OUTPUT
    - name: Tag release
      uses: actions/github-script@v7
      with:
        github-token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }}
        script: |
          const createReleaseScript = require("./smithy-rs/.github/workflows/release-scripts/create-release.js");
          await createReleaseScript({
            github,
            isDryRun: ${{ inputs.dry_run }},
            releaseManifestPath: "smithy-rs-release/smithy-rs-release-manifest.json",
            releaseCommitish: "${{ steps.push-changelog.outputs.commit_sha }}"
          });
    # This step is idempotent; the `publisher` will not publish a crate if the version is already published on crates.io.
    - name: Publish to crates.io
      shell: bash
      working-directory: smithy-rs-release/crates-to-publish
@@ -247,7 +242,23 @@ jobs:
        else
          publisher publish -y --location .
        fi
    # This step is not idempotent and MUST be performed last, as it will generate a new release in the `smithy-rs`
    # repository with the release tag that is always unique and has an increasing numerical suffix.
    - name: Tag release
      uses: actions/github-script@v7
      with:
        github-token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }}
        script: |
          const createReleaseScript = require("./smithy-rs/.github/workflows/release-scripts/create-release.js");
          await createReleaseScript({
            github,
            isDryRun: ${{ inputs.dry_run }},
            releaseManifestPath: "smithy-rs-release/smithy-rs-release-manifest.json",
            releaseCommitish: "${{ steps.push-changelog.outputs.commit_sha }}"
          });

  # If this step fails for any reason, there's no need to retry the release workflow, as this step is auxiliary
  # and the release itself was successful. Instead, manually trigger `backport-pull-request.yml`.
  open-backport-pull-request:
    name: Open backport pull request to merge the release branch back to main
    needs:
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "changelogger"
version = "0.2.0"
version = "0.3.0"
dependencies = [
 "anyhow",
 "clap",
+1 −1
Original line number Diff line number Diff line
[package]
name = "changelogger"
version = "0.2.0"
version = "0.3.0"
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>"]
description = "A CLI tool render and update changelogs from changelog files"
edition = "2021"
Loading