From 7e268ba8cef5e0b72f176618e949e4042514af45 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sun, 15 Aug 2021 23:12:18 +0100 Subject: [PATCH 1/6] Update agb's cargo.toml when updating a dependency --- release.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/release.sh b/release.sh index 6083308d..991ca66c 100755 --- a/release.sh +++ b/release.sh @@ -70,6 +70,12 @@ if [ "$PROJECT" = "agb" ]; then # also update the agb version in the template sed -i -e "s/^agb = \".*\"/agb = \"$VERSION\"/" template/Cargo.toml git add template/Cargo.toml +else + local PROJECT_NAME_WITH_UNDERSCORES=$(echo -n "$PROJECT" | tr - _) + sed -i -E -e "s/($PROJECT_NAME_WITH_UNDERSCORES = .*version = \")[^\"]+(\".*)/\1$VERSION\2/" agb/Cargo.toml + + (cd agb && cargo update) + git add agb/Cargo.toml agb/Cargo.lock fi # Commit the Cargo.toml changes From 2f12748004cc807c7e75f771627baded98b0fa5c Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sun, 15 Aug 2021 23:15:25 +0100 Subject: [PATCH 2/6] Allow for easier testing --- release.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/release.sh b/release.sh index 991ca66c..c1e75dcc 100755 --- a/release.sh +++ b/release.sh @@ -5,10 +5,11 @@ set -e PROJECT=$1 VERSION=$2 +NO_COMMIT=$3 # Sanity check that we actually have a version if [ "$VERSION" = "" ]; then - echo "Usage $0 " + echo "Usage $0 [--no-commit]" exit 1 fi @@ -18,6 +19,12 @@ if [ ! "$(echo "$VERSION" | grep -E "^[0-9]+\.[0-9]+\.[0-9]+$")" ]; then exit 1 fi +# Check if no commit option is valid +if [ ! "$NO_COMMIT" = "" ] || [ ! "$NO_COMMIT" = "--no-commit" ]; then + echo "Must pass either no last argument or --no-commit" + exit 1 +fi + # Set up $DIRECTORY and $TAGNAME case "$PROJECT" in agb) @@ -49,8 +56,8 @@ if [ ! -z "$(git status --porcelain)" ]; then exit 1 fi -# Check that we are in the master branch -if [ "$(git symbolic-ref --short HEAD)" != "master" ]; then +# Check that we are in the master branch, but only if actually committing +if [ ! "$NO_COMMIT" = "--no-commit" ] && [ "$(git symbolic-ref --short HEAD)" != "master" ]; then echo "You must be in the master branch before releasing" exit 1 fi @@ -78,11 +85,13 @@ else git add agb/Cargo.toml agb/Cargo.lock fi -# Commit the Cargo.toml changes -git commit -m "Release $PROJECT v$VERSION" +if [ ! "$NO_COMMIT" = "--no-commit" ]; then + # Commit the Cargo.toml changes + git commit -m "Release $PROJECT v$VERSION" -# Tag the version -git tag -a $TAGNAME -m "$PROJECT - v$VERSION" + # Tag the version + git tag -a $TAGNAME -m "$PROJECT - v$VERSION" -echo "Done! Push with" -echo "git push --atomic origin master $TAGNAME" \ No newline at end of file + echo "Done! Push with" + echo "git push --atomic origin master $TAGNAME" +fi \ No newline at end of file From 8b2bd66b1953f6f9b0c225b6b3194fe886b03e0a Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sun, 15 Aug 2021 23:15:52 +0100 Subject: [PATCH 3/6] Also check if agb-macros works --- release.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/release.sh b/release.sh index c1e75dcc..0c6e6522 100755 --- a/release.sh +++ b/release.sh @@ -65,6 +65,7 @@ fi # Sanity check to make sure the build works (cd agb && cargo test) (cd agb-image-converter && cargo test) +(cd agb-macros && cargo test) # Update the version in Cargo.toml sed -i -e "s/^version = \".*\"/version = \"$VERSION\"/" "$DIRECTORY/Cargo.toml" From 2e7c2be11e868c42c0bd6d1416470e8cf0e91545 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sun, 15 Aug 2021 23:16:30 +0100 Subject: [PATCH 4/6] Get the booleans correct --- release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.sh b/release.sh index 0c6e6522..ac66b45b 100755 --- a/release.sh +++ b/release.sh @@ -20,7 +20,7 @@ if [ ! "$(echo "$VERSION" | grep -E "^[0-9]+\.[0-9]+\.[0-9]+$")" ]; then fi # Check if no commit option is valid -if [ ! "$NO_COMMIT" = "" ] || [ ! "$NO_COMMIT" = "--no-commit" ]; then +if [ ! "$NO_COMMIT" = "" ] && [ ! "$NO_COMMIT" = "--no-commit" ]; then echo "Must pass either no last argument or --no-commit" exit 1 fi From 2b1ba6c849c1a2c99f285de3a0f1477a63c693fa Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sun, 15 Aug 2021 23:18:55 +0100 Subject: [PATCH 5/6] local can only be used in functions --- release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.sh b/release.sh index ac66b45b..23db2993 100755 --- a/release.sh +++ b/release.sh @@ -79,7 +79,7 @@ if [ "$PROJECT" = "agb" ]; then sed -i -e "s/^agb = \".*\"/agb = \"$VERSION\"/" template/Cargo.toml git add template/Cargo.toml else - local PROJECT_NAME_WITH_UNDERSCORES=$(echo -n "$PROJECT" | tr - _) + PROJECT_NAME_WITH_UNDERSCORES=$(echo -n "$PROJECT" | tr - _) sed -i -E -e "s/($PROJECT_NAME_WITH_UNDERSCORES = .*version = \")[^\"]+(\".*)/\1$VERSION\2/" agb/Cargo.toml (cd agb && cargo update) From 919339173164975c22b191fb1aeb8e04096c22cd Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sun, 15 Aug 2021 23:20:51 +0100 Subject: [PATCH 6/6] Makes sense to me to do the testing later --- release.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/release.sh b/release.sh index 23db2993..7ff20ea3 100755 --- a/release.sh +++ b/release.sh @@ -62,11 +62,6 @@ if [ ! "$NO_COMMIT" = "--no-commit" ] && [ "$(git symbolic-ref --short HEAD)" != exit 1 fi -# Sanity check to make sure the build works -(cd agb && cargo test) -(cd agb-image-converter && cargo test) -(cd agb-macros && cargo test) - # Update the version in Cargo.toml sed -i -e "s/^version = \".*\"/version = \"$VERSION\"/" "$DIRECTORY/Cargo.toml" @@ -86,6 +81,11 @@ else git add agb/Cargo.toml agb/Cargo.lock fi +# Sanity check to make sure the build works +(cd agb && cargo test) +(cd agb-image-converter && cargo test) +(cd agb-macros && cargo test) + if [ ! "$NO_COMMIT" = "--no-commit" ]; then # Commit the Cargo.toml changes git commit -m "Release $PROJECT v$VERSION"