From ca22c78066f761896f7f4b5fc20b843dce679377 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Thu, 26 Jan 2023 14:51:55 +0000 Subject: [PATCH 01/37] What happens if we comment out the runtime crate version from gradle.properties? --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 7ffa3792ec..42d6f38271 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ rust.msrv=1.62.1 org.gradle.jvmargs=-Xmx1024M # Version number to use for the generated runtime crates -smithy.rs.runtime.crate.version=0.54.1 +#smithy.rs.runtime.crate.version=0.54.1 kotlin.code.style=official From 1d045ea5dbf4f7749ccbbb46de57957f8591f6ee Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Thu, 26 Jan 2023 15:42:51 +0000 Subject: [PATCH 02/37] Allow running the release and the CI workflows from an arbitrary commit. --- .github/workflows/ci.yml | 15 +++++++++++++++ .github/workflows/release.yml | 34 ++++++++++++++++------------------ 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94c0ed4681..143e4b5919 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,13 @@ on: required: false default: false type: boolean + git_ref: + description: | + The git reference that all checks should be run against. It can be a branch, a tag or a commit SHA. + If unspecified, it will default to the git reference that triggered the execution of this workflow. + required: false + type: string + default: "" env: rust_version: 1.62.1 @@ -39,6 +46,7 @@ jobs: - uses: actions/checkout@v3 with: path: smithy-rs + ref: ${{ inputs.git_ref }} # The models from aws-sdk-rust are needed to generate the full SDK for CI - uses: actions/checkout@v3 with: @@ -84,6 +92,7 @@ jobs: - uses: actions/checkout@v3 with: path: smithy-rs + ref: ${{ inputs.git_ref }} - name: Run ${{ matrix.test.action }} uses: ./smithy-rs/.github/actions/docker-build with: @@ -113,6 +122,7 @@ jobs: - uses: actions/checkout@v3 with: path: smithy-rs + ref: ${{ inputs.git_ref }} - name: Run ${{ matrix.test.action }} uses: ./smithy-rs/.github/actions/docker-build with: @@ -128,6 +138,8 @@ jobs: RUSTFLAGS: -D warnings steps: - uses: actions/checkout@v3 + with: + ref: ${{ inputs.git_ref }} # Pinned to the commit hash of v2.1.0 - uses: Swatinem/rust-cache@b894d59a8d236e2979b247b80dac8d053ab340dd with: @@ -190,6 +202,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + ref: ${{ inputs.git_ref }} # Pinned to the commit hash of v2.1.0 - uses: Swatinem/rust-cache@b894d59a8d236e2979b247b80dac8d053ab340dd with: @@ -258,6 +272,7 @@ jobs: - uses: actions/checkout@v3 with: path: smithy-rs + ref: ${{ inputs.git_ref }} - name: Run ${{ matrix.actions.action }} uses: ./smithy-rs/.github/actions/docker-build with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b4ac6c289c..66909c4146 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,10 +13,18 @@ env: rust_version: 1.62.1 name: Release smithy-rs -run-name: ${{ github.workflow }} - ${{ inputs.dry_run && 'Dry run' || 'Production run' }} +run-name: ${{ github.workflow }} ${{ inputs.semantic_version }} (${{ inputs.commit_sha }}) - ${{ inputs.dry_run && 'Dry run' || 'Production run' }} on: workflow_dispatch: inputs: + commit_sha: + description: The SHA of the git commit that you want to release (e.g. b2318b0) + required: true + type: string + semantic_version: + description: The semver tag that you want to release (e.g. 0.52.1) + required: true + type: string dry_run: description: Dry runs will only produce release artifacts, but will not cut a release tag in GitHub nor publish to crates.io required: true @@ -24,30 +32,18 @@ on: default: true jobs: - main-branch-check: - name: Check that workflow is running in main - runs-on: ubuntu-latest - steps: - - name: Main branch check - if: ${{ github.ref_name != 'main' }} - uses: actions/github-script@v6 - with: - script: | - core.setFailed("The release workflow can only be ran on main (current branch: ${{ github.ref_name }})") - - # If a release is kicked off before an image is built after push to main, - # or if a dry-run release is kicked off against a non-main branch to test - # automation changes, we'll need to build a base image to work against. - # This job will be a no-op if an image was already built on main. + # We'll need to build a base image to work against if: + # - a release was kicked off before the image build step triggered by a push to the release branch/main completed + # - a dry-run release was kicked off against a feature branch to test automation changes + # This job will be a no-op if an image had already been built. acquire-base-image: name: Acquire Base Image - needs: - - main-branch-check runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: path: smithy-rs + ref: ${{ inputs.commit_sha }} fetch-depth: 0 - name: Acquire base image id: acquire @@ -61,6 +57,7 @@ jobs: release-ci: name: Prerelease checks + if: inputs.dry_run == false needs: - acquire-base-image uses: ./.github/workflows/ci.yml @@ -81,6 +78,7 @@ jobs: - name: Checkout smithy-rs uses: actions/checkout@v3 with: + ref: ${{ inputs.commit_sha }} path: smithy-rs token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }} - name: Generate release artifacts From 37bc560c742f2a3f20477a827c8f262d0c01e4a1 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Thu, 26 Jan 2023 15:43:50 +0000 Subject: [PATCH 03/37] Does a fake version work? --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 42d6f38271..98994d3771 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ rust.msrv=1.62.1 org.gradle.jvmargs=-Xmx1024M # Version number to use for the generated runtime crates -#smithy.rs.runtime.crate.version=0.54.1 +smithy.rs.runtime.crate.version=head kotlin.code.style=official From a8a6ff2e2179a91705034dce7acd33b8c2f3b409 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Thu, 26 Jan 2023 15:44:26 +0000 Subject: [PATCH 04/37] Pass `git_ref` from the release workflow. --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 66909c4146..032b0ce30e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,6 +63,7 @@ jobs: uses: ./.github/workflows/ci.yml with: run_sdk_examples: false + git_ref: ${{ inputs.commit_sha }} release: name: Release From 219f125a7fc90edd1bd512525f56164da5d97a78 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Thu, 26 Jan 2023 15:51:27 +0000 Subject: [PATCH 05/37] It needs to be a valid semver version. --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 98994d3771..9857dcc895 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ rust.msrv=1.62.1 org.gradle.jvmargs=-Xmx1024M # Version number to use for the generated runtime crates -smithy.rs.runtime.crate.version=head +smithy.rs.runtime.crate.version=0.0.0-smithy-rs-head kotlin.code.style=official From 9394c6b1285ae4d6c217cc922dbb730538a9eff6 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Thu, 26 Jan 2023 18:14:17 +0000 Subject: [PATCH 06/37] Sketch new command to upgrade version in gradle.properties --- .github/workflows/release.yml | 2 +- tools/publisher/src/fs.rs | 2 +- tools/publisher/src/main.rs | 10 ++++++++++ tools/publisher/src/subcommand/mod.rs | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 032b0ce30e..839d9b0014 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ on: required: true type: string dry_run: - description: Dry runs will only produce release artifacts, but will not cut a release tag in GitHub nor publish to crates.io + description: Dry runs will only produce release artifacts, but they will not cut a release tag in GitHub nor publish to crates.io required: true type: boolean default: true diff --git a/tools/publisher/src/fs.rs b/tools/publisher/src/fs.rs index c2b529c738..1ab53fa778 100644 --- a/tools/publisher/src/fs.rs +++ b/tools/publisher/src/fs.rs @@ -9,7 +9,7 @@ use tokio::fs::File; use tokio::io::{AsyncReadExt, AsyncWriteExt}; /// Abstraction of the filesystem to allow for more tests to be added in the future. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Copy)] pub enum Fs { Real, } diff --git a/tools/publisher/src/main.rs b/tools/publisher/src/main.rs index 273601a3c6..176f04a9ce 100644 --- a/tools/publisher/src/main.rs +++ b/tools/publisher/src/main.rs @@ -16,6 +16,8 @@ use publisher::subcommand::publish::subcommand_publish; use publisher::subcommand::publish::PublishArgs; use publisher::subcommand::tag_versions_manifest::subcommand_tag_versions_manifest; use publisher::subcommand::tag_versions_manifest::TagVersionsManifestArgs; +use publisher::subcommand::upgrade_runtime_crates_version::subcommand_upgrade_runtime_crates_version; +use publisher::subcommand::upgrade_runtime_crates_version::UpgradeRuntimeCratesVersionArgs; use publisher::subcommand::yank_release::{subcommand_yank_release, YankReleaseArgs}; use tracing_subscriber::fmt::format::FmtSpan; @@ -24,6 +26,11 @@ use tracing_subscriber::fmt::format::FmtSpan; enum Args { /// Fixes path dependencies in manifests to also have version numbers FixManifests(FixManifestsArgs), + /// Upgrade the version of the runtime crates used by the code generator (via `gradle.properties`). + /// + /// The command will fail if you try to perform a downgrade - e.g. change the version from + /// `0.53.1` to `0.52.0` or `0.53.0`. + UpgradeRuntimeCratesVersion(UpgradeRuntimeCratesVersionArgs), /// Publishes crates to crates.io Publish(PublishArgs), /// Publishes an empty library crate to crates.io when a new runtime crate is introduced. @@ -52,6 +59,9 @@ async fn main() -> Result<()> { match Args::parse() { Args::ClaimCrateNames(args) => subcommand_claim_crate_names(&args).await?, + Args::UpgradeRuntimeCratesVersion(args) => { + subcommand_upgrade_runtime_crates_version(&args).await? + } Args::Publish(args) => subcommand_publish(&args).await?, Args::FixManifests(args) => subcommand_fix_manifests(&args).await?, Args::YankRelease(args) => subcommand_yank_release(&args).await?, diff --git a/tools/publisher/src/subcommand/mod.rs b/tools/publisher/src/subcommand/mod.rs index 9462cf58ca..256993e7b0 100644 --- a/tools/publisher/src/subcommand/mod.rs +++ b/tools/publisher/src/subcommand/mod.rs @@ -9,4 +9,5 @@ pub mod generate_version_manifest; pub mod hydrate_readme; pub mod publish; pub mod tag_versions_manifest; +pub mod upgrade_runtime_crates_version; pub mod yank_release; From 6ee191db470a75f2c319a840766cf920bc03882b Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Thu, 26 Jan 2023 18:14:34 +0000 Subject: [PATCH 07/37] Command implementation --- .../upgrade_runtime_crates_version.rs | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs diff --git a/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs b/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs new file mode 100644 index 0000000000..c6abcbaff7 --- /dev/null +++ b/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs @@ -0,0 +1,67 @@ +use crate::fs::Fs; +use anyhow::{anyhow, bail, Context}; +use clap::Parser; +use regex::Regex; +use std::path::{Path, PathBuf}; + +#[derive(Parser, Debug)] +pub struct UpgradeRuntimeCratesVersionArgs { + /// The version of runtime crates you want the code generator to use (e.g. `0.52.0`). + #[clap(long)] + version: String, + /// The path to the `gradle.properties` file. It will default to `gradle.properties` if + /// left unspecified. + #[clap(long, default_value = "gradle.properties")] + gradle_properties_path: PathBuf, +} + +pub async fn subcommand_upgrade_runtime_crates_version( + args: &UpgradeRuntimeCratesVersionArgs, +) -> Result<(), anyhow::Error> { + let upgraded_version = semver::Version::parse(args.version.as_str()) + .with_context(|| format!("{} is not a valid semver version", &args.version))?; + let fs = Fs::Real; + let gradle_properties = read_gradle_properties(fs, &args.gradle_properties_path).await?; + let version_regex = + Regex::new(r"(?Psmithy\.rs\.runtime\.crate\.version=)(?P\d+\.\d+\.\d+-.*)") + .unwrap(); + let current_version = version_regex.captures(&gradle_properties).ok_or_else(|| { + anyhow!("Failed to extract the expected runtime crates version from gradle.properties") + })?; + let current_version = current_version.name("version").unwrap(); + let current_version = semver::Version::parse(current_version.as_str()) + .with_context(|| format!("{} is not a valid semver version", current_version.as_str()))?; + if current_version > upgraded_version + // Special version tag used on the `main` branch + && current_version != semver::Version::parse("0.0.0-smithy-rs-head").unwrap() + { + bail!("Moving from {current_version} to {upgraded_version} would be a *downgrade*. This command doesn't allow it!"); + } + let updated_gradle_properties = version_regex.replace( + &gradle_properties, + format!("${{field}}{}", upgraded_version.to_string()), + ); + update_gradle_properties( + fs, + &args.gradle_properties_path, + updated_gradle_properties.as_ref(), + ) + .await?; + Ok(()) +} + +async fn read_gradle_properties(fs: Fs, path: &Path) -> Result { + let bytes = fs.read_file(path).await?; + let contents = + String::from_utf8(bytes).context("The gradle.properties file contained non-UTF8 data")?; + Ok(contents) +} + +async fn update_gradle_properties( + fs: Fs, + path: &Path, + contents: &str, +) -> Result<(), anyhow::Error> { + fs.write_file(path, contents.as_bytes()).await?; + Ok(()) +} From 9d997d1cf2f5b5980287413aabd840228c3761f7 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Fri, 27 Jan 2023 12:27:17 +0000 Subject: [PATCH 08/37] Plug the new publisher command into the `release` action. --- .github/workflows/release.yml | 62 ++++++++++++++++++- .../scripts/upgrade-gradle-properties | 9 +++ 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100755 tools/ci-build/scripts/upgrade-gradle-properties diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 839d9b0014..092c527834 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -65,11 +65,69 @@ jobs: run_sdk_examples: false git_ref: ${{ inputs.commit_sha }} + upgrade-gradle-properties: + name: Prerelease checks + if: inputs.dry_run == false + needs: + - release-ci + - acquire-base-image + outputs: + commit_sha: ${{ steps.gradle-push.outputs.commit_sha }} + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ inputs.commit_sha }} + token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }} + - name: Upgrade gradle.properties + uses: ./smithy-rs/.github/actions/docker-build + with: + action: upgrade-gradle-smithy-rs-release ${{ inputs.semantic_version }} + - name: Push gradle.properties changes + id: gradle-push + shell: bash + env: + SEMANTIC_VERSION: ${{ inputs.semantic_version }} + run: | + if [[ git status --porcelain ]]; then + git commit gradle.properties -m "Upgrade the smithy-rs runtime crates version to ${SEMANTIC_VERSION}" + if [[ "${{ inputs.dry_run }}" == "true" ]]; then + echo "Pushing a preview of the release to the smithy-rs-release-preview branch" + git push --force origin HEAD:smithy-rs-release-preview + else + echo "Pushing upgraded gradle.properties commits..." + git push origin + fi + fi + echo "commit_sha=$(git rev-parse --verify --short HEAD)" > $GITHUB_OUTPUT + + # We'll need to build a base image again if the previous job upgraded the gradle.properties file. + # This job will be a no-op if the version in gradle.properties had already been upgraded. + acquire-base-image-2: + name: Acquire Base Image + runs-on: ubuntu-latest + needs: + - upgrade-gradle-properties + steps: + - uses: actions/checkout@v3 + with: + path: smithy-rs + # The ref for the commit after the gradle.properties upgrade + ref: ${{ needs.upgrade-gradle-properties.outputs.commit_sha }} + fetch-depth: 0 + - name: Acquire base image + id: acquire + run: ./smithy-rs/tools/ci-build/acquire-build-image + - name: Upload base image + uses: actions/upload-artifact@v3 + with: + name: smithy-rs-base-image + path: smithy-rs-base-image + retention-days: 1 + release: name: Release needs: - - acquire-base-image - - release-ci + - acquire-base-image-2 runs-on: ubuntu-latest steps: - name: Install Rust diff --git a/tools/ci-build/scripts/upgrade-gradle-properties b/tools/ci-build/scripts/upgrade-gradle-properties new file mode 100755 index 0000000000..3402ae23e3 --- /dev/null +++ b/tools/ci-build/scripts/upgrade-gradle-properties @@ -0,0 +1,9 @@ +#!/bin/bash +# +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + +set -eux + +publisher upgrade-runtime-crates-version --version ${1} From 8a8713a662445931dfdb4a1717558fc96a7609c4 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Fri, 27 Jan 2023 13:16:02 +0000 Subject: [PATCH 09/37] Plumb end-to-end --- .github/workflows/release.yml | 94 +++++++++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 092c527834..4705ac7cfe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ # Allow only one release to run at a time concurrency: - group: release-smithy-rs + group: release-smithy-rs-${{ inputs.dry_run }} cancel-in-progress: true env: @@ -65,18 +65,70 @@ jobs: run_sdk_examples: false git_ref: ${{ inputs.commit_sha }} + get-or-create-release-branch: + name: Get or create a release branch + needs: + - release-ci + outputs: + release_branch: ${{ steps.branch-push.outputs.release_branch }} + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ inputs.commit_sha }} + token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }} + - name: Get or create release branch + id: branch-push + shell: bash + env: + SEMANTIC_VERSION: ${{ inputs.semantic_version }} + DRY_RUN: ${{ inputs.dry_run }} + run: | + # Split on the dots + version_array=( ${SEMANTIC_VERSION//./ } ) + major=version_array[0] + if [[ major == 0 ]]; then + minor=version_array[1] + branch_name="smithy-rs-release-${major}.${minor}.x" + else + branch_name="smithy-rs-release-${major}.x.y" + fi + if [[ "${DRY_RUN}" == "true" ]]; then + branch_name="${branch_name}-preview" + fi + echo "branch_name=${branch_name}" > $GITHUB_OUTPUT + + if [[ "${DRY_RUN}" == "true" ]]; then + git push -f origin HEAD:${branch_name} + else + if [[ git ls-remote --exit-code --heads origin ${branch_name} ]]; then + # The release branch already exists, we need to make sure that our commit is its current tip + branch_head_sha=$(git rev-parse --verify --short refs/heads/patches) + commit_sha=$(git rev-parse --verify --short HEAD) + if [[ branch_head_sha != commit_sha ]]; then + echo "The release branch - ${branch_name} - already exists. ${commit_sha}, the commit you chose when " + echo "launching this release, is not its current HEAD (${branch_head_sha}). This is not allowed: you " + echo "MUST release from the HEAD of the release branch if it already exists." + exit 1 + fi + else + # The release branch does not exist, we create it and set the current commit as its tip + git checkout -b ${branch_name} + git push origin ${branch_name} + fi + fi + upgrade-gradle-properties: - name: Prerelease checks + name: Upgrade gradle.properties if: inputs.dry_run == false needs: - - release-ci - - acquire-base-image + - get-or-create-release-branch outputs: commit_sha: ${{ steps.gradle-push.outputs.commit_sha }} + release_branch: ${{ needs.get-or-create-release-branch.outputs.release_branch }} steps: - uses: actions/checkout@v3 with: - ref: ${{ inputs.commit_sha }} + ref: ${{ inputs.release_branch }} token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }} - name: Upgrade gradle.properties uses: ./smithy-rs/.github/actions/docker-build @@ -87,16 +139,13 @@ jobs: shell: bash env: SEMANTIC_VERSION: ${{ inputs.semantic_version }} + DRY_RUN: ${{ inputs.dry_run }} run: | - if [[ git status --porcelain ]]; then + if [[ git diff-index --quiet HEAD ]]; then + # The file was actually changed, we need to commit and push the changes git commit gradle.properties -m "Upgrade the smithy-rs runtime crates version to ${SEMANTIC_VERSION}" - if [[ "${{ inputs.dry_run }}" == "true" ]]; then - echo "Pushing a preview of the release to the smithy-rs-release-preview branch" - git push --force origin HEAD:smithy-rs-release-preview - else - echo "Pushing upgraded gradle.properties commits..." - git push origin - fi + echo "Pushing upgraded gradle.properties commits..." + git push origin fi echo "commit_sha=$(git rev-parse --verify --short HEAD)" > $GITHUB_OUTPUT @@ -107,6 +156,9 @@ jobs: runs-on: ubuntu-latest needs: - upgrade-gradle-properties + outputs: + commit_sha: ${{ steps.output.outputs.commit_sha }} + release_branch: ${{ needs.upgrade-gradle-properties.outputs.release_branch }} steps: - uses: actions/checkout@v3 with: @@ -123,6 +175,11 @@ jobs: name: smithy-rs-base-image path: smithy-rs-base-image retention-days: 1 + - name: Persist the SHA we used to build the Docker image + id: output + shell: bash + run: | + echo "commit_sha=$(git rev-parse --verify --short HEAD)" > $GITHUB_OUTPUT release: name: Release @@ -137,7 +194,7 @@ jobs: - name: Checkout smithy-rs uses: actions/checkout@v3 with: - ref: ${{ inputs.commit_sha }} + ref: ${{ needs.acquire-base-image-2.outputs.release_branch }} path: smithy-rs token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }} - name: Generate release artifacts @@ -150,13 +207,8 @@ jobs: shell: bash working-directory: smithy-rs-release/smithy-rs run: | - if [[ "${{ inputs.dry_run }}" == "true" ]]; then - echo "Pushing a preview of the release to the smithy-rs-release-preview branch" - git push --force origin HEAD:smithy-rs-release-preview - else - echo "Pushing release commits..." - git push origin - fi + echo "Pushing release commits..." + git push origin - name: Tag release uses: actions/github-script@v6 with: From 9cadab2f7b9ab739f189d201a71f4fc847a46feb Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Fri, 27 Jan 2023 13:20:02 +0000 Subject: [PATCH 10/37] Fix copyright header. --- .../src/subcommand/upgrade_runtime_crates_version.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs b/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs index c6abcbaff7..e2c51b3fa4 100644 --- a/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs +++ b/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs @@ -1,3 +1,8 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + use crate::fs::Fs; use anyhow::{anyhow, bail, Context}; use clap::Parser; From 93dcf7bd8d73b409308902b0de7d037c89f7caac Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Fri, 27 Jan 2023 13:20:30 +0000 Subject: [PATCH 11/37] Fix lint. --- .../publisher/src/subcommand/upgrade_runtime_crates_version.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs b/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs index e2c51b3fa4..3fa73cd439 100644 --- a/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs +++ b/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs @@ -44,7 +44,7 @@ pub async fn subcommand_upgrade_runtime_crates_version( } let updated_gradle_properties = version_regex.replace( &gradle_properties, - format!("${{field}}{}", upgraded_version.to_string()), + format!("${{field}}{}", upgraded_version), ); update_gradle_properties( fs, From d1632646e578a0da0f400d9934cedd35e339b212 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Fri, 27 Jan 2023 13:26:19 +0000 Subject: [PATCH 12/37] Temporarily comment out the sanity check. --- .../src/subcommand/generate_version_manifest.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/publisher/src/subcommand/generate_version_manifest.rs b/tools/publisher/src/subcommand/generate_version_manifest.rs index be2d791599..44c1fb9982 100644 --- a/tools/publisher/src/subcommand/generate_version_manifest.rs +++ b/tools/publisher/src/subcommand/generate_version_manifest.rs @@ -143,14 +143,14 @@ fn find_released_versions( let unrecent_version = parse_version(crate_name, &unrecent_version.version)?; if unrecent_version != recent_version { // Sanity check: version numbers shouldn't decrease - if unrecent_version > recent_version { - bail!( - "Version number for `{}` decreased between releases (from `{}` to `{}`)", - crate_name, - unrecent_version, - recent_version - ); - } + // if unrecent_version > recent_version { + // bail!( + // "Version number for `{}` decreased between releases (from `{}` to `{}`)", + // crate_name, + // unrecent_version, + // recent_version + // ); + // } // If the crate is in both version manifests with differing version // numbers, then it is part of the release From 91b2978550a087cca93fdee2da53e4e85c7461c1 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Fri, 27 Jan 2023 14:18:06 +0000 Subject: [PATCH 13/37] Ignore sanity check --- tools/publisher/src/subcommand/generate_version_manifest.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/publisher/src/subcommand/generate_version_manifest.rs b/tools/publisher/src/subcommand/generate_version_manifest.rs index 44c1fb9982..68fc146007 100644 --- a/tools/publisher/src/subcommand/generate_version_manifest.rs +++ b/tools/publisher/src/subcommand/generate_version_manifest.rs @@ -319,6 +319,7 @@ mod tests { } #[test] + #[ignore] fn test_find_released_versions_decreased_version_number_sanity_check() { let result = find_released_versions( &fake_manifest( From 63b3a568c9292752233ca50f65df78c4cd882a2d Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Mon, 30 Jan 2023 11:40:54 +0000 Subject: [PATCH 14/37] Add a command that prints out the template for CHANGELOG.next.toml --- tools/changelogger/src/init.rs | 11 +++++++++++ tools/changelogger/src/lib.rs | 1 + tools/changelogger/src/main.rs | 16 ++++++++-------- 3 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 tools/changelogger/src/init.rs diff --git a/tools/changelogger/src/init.rs b/tools/changelogger/src/init.rs new file mode 100644 index 0000000000..8578149d48 --- /dev/null +++ b/tools/changelogger/src/init.rs @@ -0,0 +1,11 @@ +use crate::render::EXAMPLE_ENTRY; +use clap::Parser; +use std::io::Write; + +#[derive(Parser, Debug, Eq, PartialEq)] +pub struct InitArgs {} + +pub fn subcommand_init(_args: &InitArgs) -> anyhow::Result<()> { + writeln!(std::io::stdout(), "{}", EXAMPLE_ENTRY)?; + Ok(()) +} diff --git a/tools/changelogger/src/lib.rs b/tools/changelogger/src/lib.rs index 8eb12613f0..483dfd2013 100644 --- a/tools/changelogger/src/lib.rs +++ b/tools/changelogger/src/lib.rs @@ -4,5 +4,6 @@ */ pub mod entry; +pub mod init; pub mod render; pub mod split; diff --git a/tools/changelogger/src/main.rs b/tools/changelogger/src/main.rs index 5e3655ad67..2143b608fe 100644 --- a/tools/changelogger/src/main.rs +++ b/tools/changelogger/src/main.rs @@ -4,27 +4,27 @@ */ use anyhow::Result; +use changelogger::init::subcommand_init; +use changelogger::render::subcommand_render; +use changelogger::split::subcommand_split; use clap::Parser; -use render::subcommand_render; -use split::subcommand_split; - -mod entry; -mod render; -mod split; #[derive(Parser, Debug, Eq, PartialEq)] #[clap(name = "changelogger", author, version, about)] pub enum Args { /// Split SDK changelog entries into a separate file - Split(split::SplitArgs), + Split(changelogger::split::SplitArgs), /// Render a TOML/JSON changelog into GitHub-flavored Markdown - Render(render::RenderArgs), + Render(changelogger::render::RenderArgs), + /// Print to stdout the empty "next" CHANGELOG template. + Init(changelogger::init::InitArgs), } fn main() -> Result<()> { match Args::parse() { Args::Split(split) => subcommand_split(&split), Args::Render(render) => subcommand_render(&render), + Args::Init(init) => subcommand_init(&init), } } From aa2a7eb34299ca0ba85b05b6847f5f24100a1f57 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Mon, 30 Jan 2023 12:10:01 +0000 Subject: [PATCH 15/37] Add branch check + empty TOML generation. --- .github/workflows/release.yml | 57 +++++++++++++++++-- .../scripts/generate-new-changelog-next-toml | 9 +++ 2 files changed, 60 insertions(+), 6 deletions(-) create mode 100755 tools/ci-build/scripts/generate-new-changelog-next-toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4705ac7cfe..a15e3fd347 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -71,6 +71,7 @@ jobs: - release-ci outputs: release_branch: ${{ steps.branch-push.outputs.release_branch }} + new_release_series: ${{ steps.branch-push.outputs.new_release_series }} steps: - uses: actions/checkout@v3 with: @@ -86,24 +87,32 @@ jobs: # Split on the dots version_array=( ${SEMANTIC_VERSION//./ } ) major=version_array[0] + minor=version_array[1] + patch=version_array[2] if [[ major == 0 ]]; then - minor=version_array[1] branch_name="smithy-rs-release-${major}.${minor}.x" + if [[ patch == 0 ]]; then + echo "new_release_series=true" > $GITHUB_OUTPUT + fi else branch_name="smithy-rs-release-${major}.x.y" + if [[ minor == 0 && patch == 0 ]]; then + echo "new_release_series=true" > $GITHUB_OUTPUT + fi fi + if [[ "${DRY_RUN}" == "true" ]]; then branch_name="${branch_name}-preview" fi - echo "branch_name=${branch_name}" > $GITHUB_OUTPUT + echo "release_branch=${branch_name}" > $GITHUB_OUTPUT if [[ "${DRY_RUN}" == "true" ]]; then git push -f origin HEAD:${branch_name} else + commit_sha=$(git rev-parse --verify --short HEAD) if [[ git ls-remote --exit-code --heads origin ${branch_name} ]]; then # The release branch already exists, we need to make sure that our commit is its current tip branch_head_sha=$(git rev-parse --verify --short refs/heads/patches) - commit_sha=$(git rev-parse --verify --short HEAD) if [[ branch_head_sha != commit_sha ]]; then echo "The release branch - ${branch_name} - already exists. ${commit_sha}, the commit you chose when " echo "launching this release, is not its current HEAD (${branch_head_sha}). This is not allowed: you " @@ -111,9 +120,17 @@ jobs: exit 1 fi else - # The release branch does not exist, we create it and set the current commit as its tip - git checkout -b ${branch_name} - git push origin ${branch_name} + # The release branch does not exist. + # We need to make sure that the commit SHA that we are releasing is on `main`. + git fetch origin main + if [[ git branch --contains ${commit_sha} | grep main ]]; then + # We can then create create the release branch and set the current commit as its tip + git checkout -b ${branch_name} + git push origin ${branch_name} + else + echo "You must choose a commit from main to create a new release series!" + exit 1 + fi fi fi @@ -242,3 +259,31 @@ jobs: else publisher publish -y --location . fi + + trim-changelog-next-on-main: + name: Remove released entries from CHANGELOG.next.toml on the main branch + if: inputs.dry_run == false && needs.get-or-create-release-branch.outputs.new_release_series == true + needs: + - get-or-create-release-branch + - release + runs-on: ubuntu-latest + steps: + - name: Checkout smithy-rs + uses: actions/checkout@v3 + with: + ref: ${{ inputs.commit_sha }} + token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }} + - name: Empty CHANGELOG.next.toml + uses: ./smithy-rs/.github/actions/docker-build + with: + action: generate-new-changelog-next-toml + - name: Push smithy-rs changes + shell: bash + run: | + # This will fail if other commits have been pushed to `main` after `commit_sha` + # In particular, this will ALWAYS fail if you are creating a new release series from + # a commit that is not the current tip of `main`. + # We can build more refined automation to handle this case in the future - until then, it'll require + # a manual PR to edit the current CHANGELOG.next.toml file and remove the released entries. + git commit CHANGELOG.next.toml -m "Remove released entries from CHANGELOG.next.toml" + git push origin main diff --git a/tools/ci-build/scripts/generate-new-changelog-next-toml b/tools/ci-build/scripts/generate-new-changelog-next-toml new file mode 100755 index 0000000000..e318c01e7f --- /dev/null +++ b/tools/ci-build/scripts/generate-new-changelog-next-toml @@ -0,0 +1,9 @@ +#!/bin/bash +# +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + +set -eux + +changelogger init > CHANGELOG.next.toml From 14c4118e24d625f49b21cdfbcadc7502108bcf05 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Mon, 30 Jan 2023 13:20:44 +0000 Subject: [PATCH 16/37] Add copyright headers. --- tools/changelogger/src/init.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/changelogger/src/init.rs b/tools/changelogger/src/init.rs index 8578149d48..90377e4029 100644 --- a/tools/changelogger/src/init.rs +++ b/tools/changelogger/src/init.rs @@ -1,3 +1,8 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + use crate::render::EXAMPLE_ENTRY; use clap::Parser; use std::io::Write; From 99b6eced3541e069258c7cc25e8d99b45f7f029b Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Mon, 30 Jan 2023 13:21:30 +0000 Subject: [PATCH 17/37] Fix imports. --- tools/changelogger/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/changelogger/src/main.rs b/tools/changelogger/src/main.rs index 2143b608fe..db36023ff3 100644 --- a/tools/changelogger/src/main.rs +++ b/tools/changelogger/src/main.rs @@ -31,9 +31,9 @@ fn main() -> Result<()> { #[cfg(test)] mod tests { use super::Args; - use crate::entry::ChangeSet; - use crate::render::RenderArgs; - use crate::split::SplitArgs; + use changelogger::entry::ChangeSet; + use changelogger::render::RenderArgs; + use changelogger::split::SplitArgs; use clap::Parser; use std::path::PathBuf; From f8de00227858cef87c63cdb1603b92d755410444 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Tue, 31 Jan 2023 11:29:45 +0000 Subject: [PATCH 18/37] Remove sanity check. --- .../subcommand/generate_version_manifest.rs | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/tools/publisher/src/subcommand/generate_version_manifest.rs b/tools/publisher/src/subcommand/generate_version_manifest.rs index 68fc146007..719cb167f7 100644 --- a/tools/publisher/src/subcommand/generate_version_manifest.rs +++ b/tools/publisher/src/subcommand/generate_version_manifest.rs @@ -142,16 +142,6 @@ fn find_released_versions( if let Some(unrecent_version) = unrecent_versions.crates.get(crate_name) { let unrecent_version = parse_version(crate_name, &unrecent_version.version)?; if unrecent_version != recent_version { - // Sanity check: version numbers shouldn't decrease - // if unrecent_version > recent_version { - // bail!( - // "Version number for `{}` decreased between releases (from `{}` to `{}`)", - // crate_name, - // unrecent_version, - // recent_version - // ); - // } - // If the crate is in both version manifests with differing version // numbers, then it is part of the release released_versions.insert(crate_name.clone(), recent_version.to_string()); @@ -318,36 +308,6 @@ mod tests { assert!(result.is_ok()); } - #[test] - #[ignore] - fn test_find_released_versions_decreased_version_number_sanity_check() { - let result = find_released_versions( - &fake_manifest( - &[ - ("aws-config", "0.11.0"), - ("aws-sdk-s3", "0.13.0"), - ("aws-sdk-dynamodb", "0.12.0"), - ], - None, - ), - &fake_manifest( - &[ - ("aws-config", "0.11.0"), - ("aws-sdk-s3", "0.12.0"), // oops, S3 went backwards - ("aws-sdk-dynamodb", "0.12.0"), - ], - None, - ), - ); - assert!(result.is_err()); - let error = format!("{}", result.err().unwrap()); - assert!( - error.starts_with("Version number for `aws-sdk-s3` decreased"), - "Unexpected error: {}", - error - ); - } - #[test] fn test_find_released_versions() { let result = find_released_versions( From dd472e435caa69cc15f378c16bc46c964c9471e2 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Tue, 31 Jan 2023 11:38:28 +0000 Subject: [PATCH 19/37] Move script to a file. --- .github/workflows/release.yml | 51 +------------------------ tools/get-or-create-release-branch.sh | 55 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 50 deletions(-) create mode 100644 tools/get-or-create-release-branch.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a15e3fd347..d5f67cd309 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,56 +83,7 @@ jobs: env: SEMANTIC_VERSION: ${{ inputs.semantic_version }} DRY_RUN: ${{ inputs.dry_run }} - run: | - # Split on the dots - version_array=( ${SEMANTIC_VERSION//./ } ) - major=version_array[0] - minor=version_array[1] - patch=version_array[2] - if [[ major == 0 ]]; then - branch_name="smithy-rs-release-${major}.${minor}.x" - if [[ patch == 0 ]]; then - echo "new_release_series=true" > $GITHUB_OUTPUT - fi - else - branch_name="smithy-rs-release-${major}.x.y" - if [[ minor == 0 && patch == 0 ]]; then - echo "new_release_series=true" > $GITHUB_OUTPUT - fi - fi - - if [[ "${DRY_RUN}" == "true" ]]; then - branch_name="${branch_name}-preview" - fi - echo "release_branch=${branch_name}" > $GITHUB_OUTPUT - - if [[ "${DRY_RUN}" == "true" ]]; then - git push -f origin HEAD:${branch_name} - else - commit_sha=$(git rev-parse --verify --short HEAD) - if [[ git ls-remote --exit-code --heads origin ${branch_name} ]]; then - # The release branch already exists, we need to make sure that our commit is its current tip - branch_head_sha=$(git rev-parse --verify --short refs/heads/patches) - if [[ branch_head_sha != commit_sha ]]; then - echo "The release branch - ${branch_name} - already exists. ${commit_sha}, the commit you chose when " - echo "launching this release, is not its current HEAD (${branch_head_sha}). This is not allowed: you " - echo "MUST release from the HEAD of the release branch if it already exists." - exit 1 - fi - else - # The release branch does not exist. - # We need to make sure that the commit SHA that we are releasing is on `main`. - git fetch origin main - if [[ git branch --contains ${commit_sha} | grep main ]]; then - # We can then create create the release branch and set the current commit as its tip - git checkout -b ${branch_name} - git push origin ${branch_name} - else - echo "You must choose a commit from main to create a new release series!" - exit 1 - fi - fi - fi + run: ./tools/get-or-create-release-branch.sh upgrade-gradle-properties: name: Upgrade gradle.properties diff --git a/tools/get-or-create-release-branch.sh b/tools/get-or-create-release-branch.sh new file mode 100644 index 0000000000..3c74ffd6e1 --- /dev/null +++ b/tools/get-or-create-release-branch.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +# + +# Split on the dots +version_array=( ${SEMANTIC_VERSION//./ } ) +major=${version_array[0]} +minor=${version_array[1]} +patch=${version_array[2]} +if [[ $major == 0 ]]; then + branch_name="smithy-rs-release-${major}.${minor}.x" + if [[ $patch == 0 ]]; then + echo "new_release_series=true" > $GITHUB_OUTPUT + fi +else + branch_name="smithy-rs-release-${major}.x.y" + if [[ $minor == 0 && $patch == 0 ]]; then + echo "new_release_series=true" > $GITHUB_OUTPUT + fi +fi + +if [[ "${DRY_RUN}" == "true" ]]; then + branch_name="${branch_name}-preview" +fi +echo "release_branch=${branch_name}" > $GITHUB_OUTPUT + +if [[ "${DRY_RUN}" == "true" ]]; then + git push -f origin "HEAD:${branch_name}" +else + commit_sha=$(git rev-parse --verify --short HEAD) + if git ls-remote --exit-code --heads origin "${branch_name}"; then + # The release branch already exists, we need to make sure that our commit is its current tip + branch_head_sha=$(git rev-parse --verify --short refs/heads/patches) + if [[ "${branch_head_sha}" != "${commit_sha}" ]]; then + echo "The release branch - ${branch_name} - already exists. ${commit_sha}, the commit you chose when " + echo "launching this release, is not its current HEAD (${branch_head_sha}). This is not allowed: you " + echo "MUST release from the HEAD of the release branch if it already exists." + exit 1 + fi + else + # The release branch does not exist. + # We need to make sure that the commit SHA that we are releasing is on `main`. + git fetch origin main + if git branch --contains "${commit_sha}" | grep main; then + # We can then create create the release branch and set the current commit as its tip + git checkout -b "${branch_name}" + git push origin "${branch_name}" + else + echo "You must choose a commit from main to create a new release series!" + exit 1 + fi + fi +fi From 7841f536c48edb4c2337a3d8f5789a51f7d55710 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Tue, 31 Jan 2023 11:49:04 +0000 Subject: [PATCH 20/37] Add a check to validate the tag. --- tools/get-or-create-release-branch.sh | 5 +++++ 1 file changed, 5 insertions(+) mode change 100644 => 100755 tools/get-or-create-release-branch.sh diff --git a/tools/get-or-create-release-branch.sh b/tools/get-or-create-release-branch.sh old mode 100644 new mode 100755 index 3c74ffd6e1..11149461cd --- a/tools/get-or-create-release-branch.sh +++ b/tools/get-or-create-release-branch.sh @@ -3,12 +3,17 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 # +set -e # 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 From e07e0cdd702ac03c72df499dc86f284b493e2bc4 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Tue, 31 Jan 2023 17:44:33 +0000 Subject: [PATCH 21/37] Remove second build step. --- .github/workflows/release.yml | 36 ++--------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d5f67cd309..f063ba69de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -117,42 +117,10 @@ jobs: fi echo "commit_sha=$(git rev-parse --verify --short HEAD)" > $GITHUB_OUTPUT - # We'll need to build a base image again if the previous job upgraded the gradle.properties file. - # This job will be a no-op if the version in gradle.properties had already been upgraded. - acquire-base-image-2: - name: Acquire Base Image - runs-on: ubuntu-latest - needs: - - upgrade-gradle-properties - outputs: - commit_sha: ${{ steps.output.outputs.commit_sha }} - release_branch: ${{ needs.upgrade-gradle-properties.outputs.release_branch }} - steps: - - uses: actions/checkout@v3 - with: - path: smithy-rs - # The ref for the commit after the gradle.properties upgrade - ref: ${{ needs.upgrade-gradle-properties.outputs.commit_sha }} - fetch-depth: 0 - - name: Acquire base image - id: acquire - run: ./smithy-rs/tools/ci-build/acquire-build-image - - name: Upload base image - uses: actions/upload-artifact@v3 - with: - name: smithy-rs-base-image - path: smithy-rs-base-image - retention-days: 1 - - name: Persist the SHA we used to build the Docker image - id: output - shell: bash - run: | - echo "commit_sha=$(git rev-parse --verify --short HEAD)" > $GITHUB_OUTPUT - release: name: Release needs: - - acquire-base-image-2 + - upgrade-gradle-properties runs-on: ubuntu-latest steps: - name: Install Rust @@ -162,7 +130,7 @@ jobs: - name: Checkout smithy-rs uses: actions/checkout@v3 with: - ref: ${{ needs.acquire-base-image-2.outputs.release_branch }} + ref: ${{ needs.upgrade-gradle-properties.outputs.release_branch }} path: smithy-rs token: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }} - name: Generate release artifacts From 815ffc5305304ba84501fd681ef10a8555bbb6b9 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 10:30:19 +0000 Subject: [PATCH 22/37] Move to .github/scripts folder. --- {tools => .github/scripts}/get-or-create-release-branch.sh | 0 .github/workflows/release.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename {tools => .github/scripts}/get-or-create-release-branch.sh (100%) diff --git a/tools/get-or-create-release-branch.sh b/.github/scripts/get-or-create-release-branch.sh similarity index 100% rename from tools/get-or-create-release-branch.sh rename to .github/scripts/get-or-create-release-branch.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f063ba69de..04671c443e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,7 +83,7 @@ jobs: env: SEMANTIC_VERSION: ${{ inputs.semantic_version }} DRY_RUN: ${{ inputs.dry_run }} - run: ./tools/get-or-create-release-branch.sh + run: ./.github/scripts/get-or-create-release-branch.sh upgrade-gradle-properties: name: Upgrade gradle.properties From 485101045bbe615327150a12fad5aa65d4d06e09 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 11:15:40 +0000 Subject: [PATCH 23/37] Make the script easier to run locally --- .github/scripts/get-or-create-release-branch.sh | 13 ++++++++++--- .github/workflows/release.yml | 5 ++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/scripts/get-or-create-release-branch.sh b/.github/scripts/get-or-create-release-branch.sh index 11149461cd..e7fa3a0686 100755 --- a/.github/scripts/get-or-create-release-branch.sh +++ b/.github/scripts/get-or-create-release-branch.sh @@ -5,6 +5,13 @@ # set -e +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]} @@ -17,19 +24,19 @@ fi if [[ $major == 0 ]]; then branch_name="smithy-rs-release-${major}.${minor}.x" if [[ $patch == 0 ]]; then - echo "new_release_series=true" > $GITHUB_OUTPUT + 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" > $GITHUB_OUTPUT + echo "new_release_series=true" > "${output_file}" fi fi if [[ "${DRY_RUN}" == "true" ]]; then branch_name="${branch_name}-preview" fi -echo "release_branch=${branch_name}" > $GITHUB_OUTPUT +echo "release_branch=${branch_name}" > "${output_file}" if [[ "${DRY_RUN}" == "true" ]]; then git push -f origin "HEAD:${branch_name}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 04671c443e..524ee67711 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,7 +83,10 @@ jobs: env: SEMANTIC_VERSION: ${{ inputs.semantic_version }} DRY_RUN: ${{ inputs.dry_run }} - run: ./.github/scripts/get-or-create-release-branch.sh + run: | + touch output + ./.github/scripts/get-or-create-release-branch.sh output + cat output > $GITHUB_OUTPUT upgrade-gradle-properties: name: Upgrade gradle.properties From a439fc59b73619a0a0fd97606c66f68a3729da65 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 11:15:59 +0000 Subject: [PATCH 24/37] Fail if anything fails. --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 524ee67711..cff2097834 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,6 +84,8 @@ jobs: SEMANTIC_VERSION: ${{ inputs.semantic_version }} DRY_RUN: ${{ inputs.dry_run }} run: | + set -e + touch output ./.github/scripts/get-or-create-release-branch.sh output cat output > $GITHUB_OUTPUT From a318f048322551419d0721516a15fa6131e37403 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 11:21:32 +0000 Subject: [PATCH 25/37] Add comment. --- .github/scripts/get-or-create-release-branch.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/scripts/get-or-create-release-branch.sh b/.github/scripts/get-or-create-release-branch.sh index e7fa3a0686..dec6e5918f 100755 --- a/.github/scripts/get-or-create-release-branch.sh +++ b/.github/scripts/get-or-create-release-branch.sh @@ -5,6 +5,21 @@ # set -e +# 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). +# If it isn't the beginning of a new release series, the script makes sure that the commit that will be tagged is at +# the tip of the (pre-existing) release branch. +# +# 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 From 42fc4fb9563b1606d270d7b70bd80a0e1b2cfef7 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:23:48 +0000 Subject: [PATCH 26/37] Update .github/scripts/get-or-create-release-branch.sh Co-authored-by: david-perez --- .github/scripts/get-or-create-release-branch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/get-or-create-release-branch.sh b/.github/scripts/get-or-create-release-branch.sh index dec6e5918f..bd5724e2b7 100755 --- a/.github/scripts/get-or-create-release-branch.sh +++ b/.github/scripts/get-or-create-release-branch.sh @@ -71,7 +71,7 @@ else # We need to make sure that the commit SHA that we are releasing is on `main`. git fetch origin main if git branch --contains "${commit_sha}" | grep main; then - # We can then create create the release branch and set the current commit as its tip + # We can then create the release branch and set the current commit as its tip git checkout -b "${branch_name}" git push origin "${branch_name}" else From 7751de1630414376439a0d7067864dc49308eb72 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:23:56 +0000 Subject: [PATCH 27/37] Update .github/scripts/get-or-create-release-branch.sh Co-authored-by: david-perez --- .github/scripts/get-or-create-release-branch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/get-or-create-release-branch.sh b/.github/scripts/get-or-create-release-branch.sh index bd5724e2b7..4fbd303876 100755 --- a/.github/scripts/get-or-create-release-branch.sh +++ b/.github/scripts/get-or-create-release-branch.sh @@ -56,7 +56,7 @@ echo "release_branch=${branch_name}" > "${output_file}" if [[ "${DRY_RUN}" == "true" ]]; then git push -f origin "HEAD:${branch_name}" else - commit_sha=$(git rev-parse --verify --short HEAD) + commit_sha=$(git rev-parse --short HEAD) if git ls-remote --exit-code --heads origin "${branch_name}"; then # The release branch already exists, we need to make sure that our commit is its current tip branch_head_sha=$(git rev-parse --verify --short refs/heads/patches) From 3a52ed7e0625e869a900934da81250b2690994a1 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:24:25 +0000 Subject: [PATCH 28/37] Update .github/scripts/get-or-create-release-branch.sh Co-authored-by: david-perez --- .github/scripts/get-or-create-release-branch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/get-or-create-release-branch.sh b/.github/scripts/get-or-create-release-branch.sh index 4fbd303876..ab4b7a433d 100755 --- a/.github/scripts/get-or-create-release-branch.sh +++ b/.github/scripts/get-or-create-release-branch.sh @@ -54,7 +54,7 @@ fi echo "release_branch=${branch_name}" > "${output_file}" if [[ "${DRY_RUN}" == "true" ]]; then - git push -f origin "HEAD:${branch_name}" + git push --force origin "HEAD:${branch_name}" else commit_sha=$(git rev-parse --short HEAD) if git ls-remote --exit-code --heads origin "${branch_name}"; then From 0414ccef4bbcf3da949d94d565fea8b8c3ba2efe Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:24:47 +0000 Subject: [PATCH 29/37] Update .github/workflows/ci.yml Co-authored-by: david-perez --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 143e4b5919..eb5cfb9254 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ on: default: false type: boolean git_ref: - description: | + description: | The git reference that all checks should be run against. It can be a branch, a tag or a commit SHA. If unspecified, it will default to the git reference that triggered the execution of this workflow. required: false From e3c0bc20c56708708f1d558b01fec59e12e83fce Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:26:26 +0000 Subject: [PATCH 30/37] Remove touch. --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cff2097834..800c851aa9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -86,7 +86,6 @@ jobs: run: | set -e - touch output ./.github/scripts/get-or-create-release-branch.sh output cat output > $GITHUB_OUTPUT From 9a739bace9eb677632560a0315c3981a198298c5 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:28:41 +0000 Subject: [PATCH 31/37] Fix indentation and branch name. --- .../scripts/get-or-create-release-branch.sh | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/.github/scripts/get-or-create-release-branch.sh b/.github/scripts/get-or-create-release-branch.sh index ab4b7a433d..a32c5afe60 100755 --- a/.github/scripts/get-or-create-release-branch.sh +++ b/.github/scripts/get-or-create-release-branch.sh @@ -16,67 +16,67 @@ set -e # is the beginning of a new release series. if [ -z "$SEMANTIC_VERSION" ]; then - echo "'SEMANTIC_VERSION' must be populated." - exit 1 + 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 + echo "You need to specify the path of the file where you want to collect the output" + exit 1 else - output_file="$1" + output_file="$1" fi # Split on the dots -version_array=( ${SEMANTIC_VERSION//./ } ) +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 + 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 + 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 + branch_name="smithy-rs-release-${major}.x.y" + if [[ $minor == 0 && $patch == 0 ]]; then + echo "new_release_series=true" >"${output_file}" + fi fi if [[ "${DRY_RUN}" == "true" ]]; then - branch_name="${branch_name}-preview" + branch_name="${branch_name}-preview" fi -echo "release_branch=${branch_name}" > "${output_file}" +echo "release_branch=${branch_name}" >"${output_file}" if [[ "${DRY_RUN}" == "true" ]]; then - git push --force origin "HEAD:${branch_name}" + git push --force origin "HEAD:${branch_name}" else - commit_sha=$(git rev-parse --short HEAD) - if git ls-remote --exit-code --heads origin "${branch_name}"; then - # The release branch already exists, we need to make sure that our commit is its current tip - branch_head_sha=$(git rev-parse --verify --short refs/heads/patches) - if [[ "${branch_head_sha}" != "${commit_sha}" ]]; then - echo "The release branch - ${branch_name} - already exists. ${commit_sha}, the commit you chose when " - echo "launching this release, is not its current HEAD (${branch_head_sha}). This is not allowed: you " - echo "MUST release from the HEAD of the release branch if it already exists." - exit 1 - fi - else - # The release branch does not exist. - # We need to make sure that the commit SHA that we are releasing is on `main`. - git fetch origin main - if git branch --contains "${commit_sha}" | grep main; then - # We can then create the release branch and set the current commit as its tip - git checkout -b "${branch_name}" - git push origin "${branch_name}" + commit_sha=$(git rev-parse --short HEAD) + if git ls-remote --exit-code --heads origin "${branch_name}"; then + # The release branch already exists, we need to make sure that our commit is its current tip + branch_head_sha=$(git rev-parse --verify --short "refs/heads/${branch_name}") + if [[ "${branch_head_sha}" != "${commit_sha}" ]]; then + echo "The release branch - ${branch_name} - already exists. ${commit_sha}, the commit you chose when " + echo "launching this release, is not its current HEAD (${branch_head_sha}). This is not allowed: you " + echo "MUST release from the HEAD of the release branch if it already exists." + exit 1 + fi else - echo "You must choose a commit from main to create a new release series!" - exit 1 + # The release branch does not exist. + # We need to make sure that the commit SHA that we are releasing is on `main`. + git fetch origin main + if git branch --contains "${commit_sha}" | grep main; then + # We can then create the release branch and set the current commit as its tip + git checkout -b "${branch_name}" + git push origin "${branch_name}" + else + echo "You must choose a commit from main to create a new release series!" + exit 1 + fi fi - fi fi From c95e89534182f5640130da205ffaf70372dde4e5 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:29:45 +0000 Subject: [PATCH 32/37] Update .github/workflows/ci.yml Co-authored-by: david-perez --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb5cfb9254..7c674e613e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ on: git_ref: description: | The git reference that all checks should be run against. It can be a branch, a tag or a commit SHA. - If unspecified, it will default to the git reference that triggered the execution of this workflow. + If unspecified, it will default to the git reference or SHA that triggered the execution of this workflow. required: false type: string default: "" From b7dab075f5cc5c6d4903b41b355fa244df3f4bb0 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:30:08 +0000 Subject: [PATCH 33/37] Update .github/workflows/release.yml Co-authored-by: david-perez --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 800c851aa9..9a30aec078 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -116,7 +116,7 @@ jobs: if [[ git diff-index --quiet HEAD ]]; then # The file was actually changed, we need to commit and push the changes git commit gradle.properties -m "Upgrade the smithy-rs runtime crates version to ${SEMANTIC_VERSION}" - echo "Pushing upgraded gradle.properties commits..." + echo "Pushing upgraded gradle.properties commit..." git push origin fi echo "commit_sha=$(git rev-parse --verify --short HEAD)" > $GITHUB_OUTPUT From 53bb4cccae73b9dac51f3648d16187061672e48a Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:30:37 +0000 Subject: [PATCH 34/37] Update .github/workflows/release.yml Co-authored-by: david-perez --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a30aec078..6f22bd9bcc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -119,7 +119,7 @@ jobs: echo "Pushing upgraded gradle.properties commit..." git push origin fi - echo "commit_sha=$(git rev-parse --verify --short HEAD)" > $GITHUB_OUTPUT + echo "commit_sha=$(git rev-parse --short HEAD)" > $GITHUB_OUTPUT release: name: Release From 7806c727c8522f06a386ce314caa1ce45e89f5fb Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:32:19 +0000 Subject: [PATCH 35/37] Explicit flags. --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6f22bd9bcc..e33c355b9d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -115,7 +115,7 @@ jobs: run: | if [[ git diff-index --quiet HEAD ]]; then # The file was actually changed, we need to commit and push the changes - git commit gradle.properties -m "Upgrade the smithy-rs runtime crates version to ${SEMANTIC_VERSION}" + git commit gradle.properties --message "Upgrade the smithy-rs runtime crates version to ${SEMANTIC_VERSION}" echo "Pushing upgraded gradle.properties commit..." git push origin fi @@ -208,5 +208,5 @@ jobs: # a commit that is not the current tip of `main`. # We can build more refined automation to handle this case in the future - until then, it'll require # a manual PR to edit the current CHANGELOG.next.toml file and remove the released entries. - git commit CHANGELOG.next.toml -m "Remove released entries from CHANGELOG.next.toml" + git commit CHANGELOG.next.toml --message "Remove released entries from \`CHANGELOG.next.toml\`" git push origin main From 62e051866faf51689f741847a7809f99b9d748f9 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:34:23 +0000 Subject: [PATCH 36/37] Use the path that was provided. --- .../src/subcommand/upgrade_runtime_crates_version.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs b/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs index 3fa73cd439..57d69b23e3 100644 --- a/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs +++ b/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs @@ -31,7 +31,7 @@ pub async fn subcommand_upgrade_runtime_crates_version( Regex::new(r"(?Psmithy\.rs\.runtime\.crate\.version=)(?P\d+\.\d+\.\d+-.*)") .unwrap(); let current_version = version_regex.captures(&gradle_properties).ok_or_else(|| { - anyhow!("Failed to extract the expected runtime crates version from gradle.properties") + anyhow!("Failed to extract the expected runtime crates version from `{:?}`", &args.gradle_properties_path) })?; let current_version = current_version.name("version").unwrap(); let current_version = semver::Version::parse(current_version.as_str()) @@ -58,7 +58,7 @@ pub async fn subcommand_upgrade_runtime_crates_version( async fn read_gradle_properties(fs: Fs, path: &Path) -> Result { let bytes = fs.read_file(path).await?; let contents = - String::from_utf8(bytes).context("The gradle.properties file contained non-UTF8 data")?; + String::from_utf8(bytes).with_context(|| format!("`{:?}` contained non-UTF8 data", path))?; Ok(contents) } From 2526b893cc6a348853c24b9cf783e20c5baa9d0d Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:34:39 +0000 Subject: [PATCH 37/37] Format --- .../src/subcommand/upgrade_runtime_crates_version.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs b/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs index 57d69b23e3..0bf17e3c01 100644 --- a/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs +++ b/tools/publisher/src/subcommand/upgrade_runtime_crates_version.rs @@ -31,7 +31,10 @@ pub async fn subcommand_upgrade_runtime_crates_version( Regex::new(r"(?Psmithy\.rs\.runtime\.crate\.version=)(?P\d+\.\d+\.\d+-.*)") .unwrap(); let current_version = version_regex.captures(&gradle_properties).ok_or_else(|| { - anyhow!("Failed to extract the expected runtime crates version from `{:?}`", &args.gradle_properties_path) + anyhow!( + "Failed to extract the expected runtime crates version from `{:?}`", + &args.gradle_properties_path + ) })?; let current_version = current_version.name("version").unwrap(); let current_version = semver::Version::parse(current_version.as_str()) @@ -57,8 +60,8 @@ pub async fn subcommand_upgrade_runtime_crates_version( async fn read_gradle_properties(fs: Fs, path: &Path) -> Result { let bytes = fs.read_file(path).await?; - let contents = - String::from_utf8(bytes).with_context(|| format!("`{:?}` contained non-UTF8 data", path))?; + let contents = String::from_utf8(bytes) + .with_context(|| format!("`{:?}` contained non-UTF8 data", path))?; Ok(contents) }