Skip to content

Commit

Permalink
chore: refresh the release script (#323)
Browse files Browse the repository at this point in the history
While releasing the last handful of CLI versions it became clear that
the release script used to do so could use a refresh. For one, it
automated _everything_, which felt risky and most of the time the script
would be aborted before it could tag and push the changes. Another
minor annoyance was not remembering the format of the version or
changelog entry. Additionally, the git log summary would only show from
the last tag, not taking into account that the last tag could be from a
pre-release.

These issues have been addressed, along with some minor
refactoring and formatting. It is still just a basic shell script and
there could certainly be better ways yet.
  • Loading branch information
maxrake authored Apr 29, 2022
1 parent 7343522 commit 286f77c
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,52 @@
#!/bin/sh

LATEST=$(git describe --tags --abbrev=0)
# Releasing a new version of the CLI is initiated with a tag and completed with the
# Release workflow in CI. Run this script from the `main` branch and follow the prompts
# to initiate a new release. There is a manual step required at the end. This is to
# ensure a chance to review the automated work and not accidentally release a new version.

printf "Latest release: %s\n\nGit log:\n" "${LATEST}"
set -eu

LATEST=$(git describe --tags --abbrev=0 --exclude="*-rc*")
printf "Latest release: %s\n\n" "${LATEST}"
printf "Git log since latest release:\n"
git log --oneline HEAD "^${LATEST}"
printf "\n"

printf "version: "
printf "version (w/o a leading 'v'): "
read -r version
TAG=v${version}

printf "changelog: "
printf "changelog (one line summary): "
read -r changelog

sed -E -i.bak "1 s#^#* ${version} - ${changelog}\n#" CHANGELOG
sed -E -i.bak "s/^version = \"([^\"]*)\"/version = \"${version}\"/" cli/Cargo.toml
printf "\nUpdating CHANGELOG, bumping version, running 'cargo check', and adding files for commit ...\n\n"
sed -E -i'.bak' "1 s#^#* ${version} - ${changelog}\n#" CHANGELOG
rm -f CHANGELOG.bak
sed -E -i'.bak' "s/^version = \"([^\"]*)\"/version = \"${version}\"/" cli/Cargo.toml
rm -f cli/Cargo.toml.bak
cargo check
git add Cargo.lock
git add CHANGELOG
git add cli/Cargo.toml
git commit -m "v${version} - ${changelog}"

TAG=v${version}
commit_message="Bump to ${TAG} - ${changelog}"
printf "\nFiles to be added and committed with message: \"%s\"\n\n" "${commit_message}"
git status

echo Tagging / pushing "${TAG}", press any key to proceed...
printf "Press enter to proceed with the commit and tag ..."
read -r
git push
git commit -m "${commit_message}"
git tag --sign -m "${TAG} - ${changelog}" "${TAG}"
git push "${TAG}"

printf "\nOutput of the command: git show %s\n" "${TAG}"
git show "${TAG}"

cat << __instructions__
The automation is done.
Run the following command manually to push the changes:
git push origin main ${TAG}
__instructions__

0 comments on commit 286f77c

Please sign in to comment.