From 74ab9100ae046f78f4eba2228517903f15cddf09 Mon Sep 17 00:00:00 2001 From: ysaito1001 Date: Tue, 9 Apr 2024 11:24:03 -0500 Subject: [PATCH] Support daily dry run release (#3548) ## Motivation and Context Runs dry-run release workflow daily ## Description We've had quite a few instances where we discovered that a dry-run failed when we were about to release, by which time a good amount of code changes were accumulated in the `main` branch. That sometimes made it harder to investigate the underlying root cause, compared to if we had run dry-run daily. To alleviate the issue, this PR runs a dry-run release daily, ensuring that the `main` branch is in good shape to kick off a prod release and that we can react to a dry-run failure caused by a PR merged to the `main` the previous day. To make this happen, the existing release workflow `release.yml` has been converted to a reusable workflow (with `workflow_call`). This is because a scheduled workflow run cannot take inputs, making it difficult to pass `commit_sha` and the `dry_run` flag to it. With `release.yml` being a reusable workflow, we have two new workflows calling `release.yml`: `prod-release.yml` and `dry-run-release.yml`, both of which we can manually trigger and we can also trigger the latter via cron. Note that there is no longer a checkbox `dry-run` that used to exist in `release.yml`. Instead, we choose a corresponding workflow. ## Testing Verified the previous workflows continued to work: - manually triggered dry-run release - manually triggered prod release However, a scheduled dry-run has not been tested because we first need to check-in `dry-run-release.yml` to main for a scheduled workflow to kick-in. In other words, we'll do live test and see what happens (will fix if any issues come up). ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --- .github/workflows/dry-run-release.yml | 44 +++++++++++++++++++++++++++ .github/workflows/prod-release.yml | 29 ++++++++++++++++++ .github/workflows/release.yml | 20 ++++++------ 3 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/dry-run-release.yml create mode 100644 .github/workflows/prod-release.yml diff --git a/.github/workflows/dry-run-release.yml b/.github/workflows/dry-run-release.yml new file mode 100644 index 000000000..08c56a2cd --- /dev/null +++ b/.github/workflows/dry-run-release.yml @@ -0,0 +1,44 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +# This workflow performs a dry run for smithy-rs release. It can be triggered via either cron or manually. +# When ran, it only produces release artifacts, but will not cut a release tag in GitHub or publish to crates.io. + +name: Smithy-rs dry run release +run-name: ${{ github.workflow }} ${{ inputs.commit_sha == '' && 'scheduled' || (inputs.commit_sha) }} +on: + schedule: + # Runs 00:00 UTC every day + - cron: 0 0 * * * + workflow_dispatch: + inputs: + commit_sha: + description: | + Commit SHA: The SHA of the git commit that you want to release. + You must use the non-abbreviated SHA (e.g. b2318b0 won't work!). + Alternatively, you can use the name of a branch. + required: true + type: string + +jobs: + smithy-rs-manual-dry-run-release: + name: Manual dry run release + if: ${{ github.event_name == 'workflow_dispatch' }} + uses: ./.github/workflows/release.yml + with: + commit_sha: ${{ inputs.commit_sha }} + dry_run: true + secrets: + RELEASE_AUTOMATION_BOT_PAT: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }} + RELEASE_AUTOMATION_BOT_CRATESIO_TOKEN: ${{ secrets.RELEASE_AUTOMATION_BOT_CRATESIO_TOKEN }} + + smithy-rs-scheduled-dry-run-release: + name: Scheduled dry run release + if: ${{ github.event_name == 'schedule' }} + uses: ./.github/workflows/release.yml + with: + commit_sha: main + dry_run: true + secrets: + RELEASE_AUTOMATION_BOT_PAT: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }} + RELEASE_AUTOMATION_BOT_CRATESIO_TOKEN: ${{ secrets.RELEASE_AUTOMATION_BOT_CRATESIO_TOKEN }} diff --git a/.github/workflows/prod-release.yml b/.github/workflows/prod-release.yml new file mode 100644 index 000000000..2192f4420 --- /dev/null +++ b/.github/workflows/prod-release.yml @@ -0,0 +1,29 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +# This workflow performs a production smithy-rs release. It will cut a release tag in GitHub and publish to crates.io. +# It is idempotent (e.g. won't publish the same crates to crates.io twice), so we can run it repeatedly until it succeeds. + +name: Smithy-rs prod release +run-name: ${{ github.workflow }} (${{ inputs.commit_sha }}) +on: + workflow_dispatch: + inputs: + commit_sha: + description: | + Commit SHA: The SHA of the git commit that you want to release. + You must use the non-abbreviated SHA (e.g. b2318b0 won't work!). + Alternatively, you can use the name of a branch. + required: true + type: string + +jobs: + smithy-rs-prod-release: + name: Prod release + uses: ./.github/workflows/release.yml + with: + commit_sha: ${{ inputs.commit_sha }} + dry_run: false + secrets: + RELEASE_AUTOMATION_BOT_PAT: ${{ secrets.RELEASE_AUTOMATION_BOT_PAT }} + RELEASE_AUTOMATION_BOT_CRATESIO_TOKEN: ${{ secrets.RELEASE_AUTOMATION_BOT_CRATESIO_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65934b422..24a311e5a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,8 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 -# This workflow performs a release of smithy-rs. It is manually -# kicked off via GitHub Actions workflow dispatch. +# This is the shared release workflow run by both `prod-release.yml` and `dry-run-release.yml'. +# A calling workflow will indicate whether it wants to run this with a prod run or a dry run. # Allow only one release to run at a time concurrency: @@ -13,22 +13,22 @@ env: rust_version: 1.74.1 name: Release smithy-rs -run-name: ${{ inputs.dry_run && 'Dry run' || 'Prod run' }} - ${{ github.workflow }} (${{ inputs.commit_sha }}) on: - workflow_dispatch: + workflow_call: inputs: commit_sha: - description: | - Commit SHA: The SHA of the git commit that you want to release. - You must use the non-abbreviated SHA (e.g. b2318b0 won't work!). + description: The SHA of the git commit that you want to release. 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 + description: When true, it only produces release artifacts, but will not cut a release tag in GitHub or publish to crates.io. required: true type: boolean - default: true + secrets: + RELEASE_AUTOMATION_BOT_PAT: + required: true + RELEASE_AUTOMATION_BOT_CRATESIO_TOKEN: + required: true jobs: check-actor-for-prod-run: -- GitLab