From 6c1b2786ec1901c446cd57f8665febea7e5e0fd6 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sun, 20 Jun 2021 23:03:10 +0100 Subject: [PATCH] Add simple release script to automate tag generation --- release.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 release.sh diff --git a/release.sh b/release.sh new file mode 100755 index 00000000..ba075463 --- /dev/null +++ b/release.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +# Fail if any command fails +set -e + +PROJECT=$1 +VERSION=$2 + +# Sanity check that we actually have a version +if [ "$VERSION" = "" ]; then + echo "Usage $0 " + exit 1 +fi + +# Set up $DIRECTORY and $TAGNAME +case "$PROJECT" in + agb) + DIRECTORY="agb" + TAGNAME="v$VERSION" + ;; + agb-image-converter) + DIRECTORY="agb-image-converter" + TAGNAME="agb-image-converter/v$VERSION" + ;; + mgba-test-runner) + DIRECTORY="mgba-test-runner" + TAGNAME="mgba-test-runner/v$VERSION" + ;; + + *) + echo "Unknown project name $PROJECT" + exit 1 + ;; +esac + +# Check that no out-standing changes in git +if [ ! -z "$(git status --porcelain)" ]; then + echo "Uncommitted changes, please commit first" + exit 1 +fi + +# Sanity check to make sure the build works +(cd agb && cargo test) +(cd agb-image-converter && cargo test) + +# Update the version in Cargo.toml +sed -i -e "s/^version = .*/version = $VERSION/" "$DIRECTORY/Cargo.toml" + +# Also update the lock file +(cd "$DIRECTORY" && cargo update) +git add "$DIRECTIORY/Cargo.toml" + +if [ "$PROJECT" = "agb" ]; then + # also update the agb version in the template + sed -i -e "s/agb = \"\(.*\)\"/$VERSION/" template/Cargo.toml + git add template/Cargo.toml +fi + +# Commit the Cargo.toml changes +git commit -m "Release $PROJECT v$VERSION" + +# Tag the version +git tag -a $TAGNAME -m "$PROJECT - v$VERSION" + +echo "Done! Push with" +echo "git push origin $TAGNAME" \ No newline at end of file