-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the release flow to use release branches (#2253)
* What happens if we comment out the runtime crate version from gradle.properties? * Allow running the release and the CI workflows from an arbitrary commit. * Does a fake version work? * Pass `git_ref` from the release workflow. * It needs to be a valid semver version. * Sketch new command to upgrade version in gradle.properties * Command implementation * Plug the new publisher command into the `release` action. * Plumb end-to-end * Fix copyright header. * Fix lint. * Temporarily comment out the sanity check. * Ignore sanity check * Add a command that prints out the template for CHANGELOG.next.toml * Add branch check + empty TOML generation. * Add copyright headers. * Fix imports. * Remove sanity check. * Move script to a file. * Add a check to validate the tag. * Remove second build step. * Move to .github/scripts folder. * Make the script easier to run locally * Fail if anything fails. * Add comment. * Update .github/scripts/get-or-create-release-branch.sh Co-authored-by: david-perez <d@vidp.dev> * Update .github/scripts/get-or-create-release-branch.sh Co-authored-by: david-perez <d@vidp.dev> * Update .github/scripts/get-or-create-release-branch.sh Co-authored-by: david-perez <d@vidp.dev> * Update .github/workflows/ci.yml Co-authored-by: david-perez <d@vidp.dev> * Remove touch. * Fix indentation and branch name. * Update .github/workflows/ci.yml Co-authored-by: david-perez <d@vidp.dev> * Update .github/workflows/release.yml Co-authored-by: david-perez <d@vidp.dev> * Update .github/workflows/release.yml Co-authored-by: david-perez <d@vidp.dev> * Explicit flags. * Use the path that was provided. * Format --------- Co-authored-by: david-perez <d@vidp.dev>
- Loading branch information
1 parent
7a0bcc2
commit d9c0b2e
Showing
14 changed files
with
337 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
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 | ||
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 | ||
|
||
if [[ "${DRY_RUN}" == "true" ]]; then | ||
branch_name="${branch_name}-preview" | ||
fi | ||
echo "release_branch=${branch_name}" >"${output_file}" | ||
|
||
if [[ "${DRY_RUN}" == "true" ]]; then | ||
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/${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 | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* 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; | ||
|
||
#[derive(Parser, Debug, Eq, PartialEq)] | ||
pub struct InitArgs {} | ||
|
||
pub fn subcommand_init(_args: &InitArgs) -> anyhow::Result<()> { | ||
writeln!(std::io::stdout(), "{}", EXAMPLE_ENTRY)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
*/ | ||
|
||
pub mod entry; | ||
pub mod init; | ||
pub mod render; | ||
pub mod split; |
Oops, something went wrong.