From 4a1c4491549425f4a69bd078f0e9da3164ad8e84 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Tue, 26 Sep 2023 17:15:14 -0400 Subject: [PATCH] Update release script (#819) * Update releaser script to check Cargo.toml version * Update releaser script to check Cargo.lock version * Update Cargo.toml/lock * Let releaser script show actual branch to be on * Echo releaser script errors to stderr * Use unique exit codes for releaser script errors * Add changelog --- Cargo.lock | 2 +- Cargo.toml | 2 +- changelog.d/819.misc | 1 + scripts/release.sh | 30 ++++++++++++++++++++++++------ 4 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 changelog.d/819.misc diff --git a/Cargo.lock b/Cargo.lock index 2f5bd615..fbe77e09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -727,7 +727,7 @@ dependencies = [ [[package]] name = "matrix-hookshot" -version = "4.4.1" +version = "4.5.1" dependencies = [ "atom_syndication", "contrast", diff --git a/Cargo.toml b/Cargo.toml index 179ade61..de1b1917 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "matrix-hookshot" -version = "4.5.0" +version = "4.5.1" edition = "2021" [lib] diff --git a/changelog.d/819.misc b/changelog.d/819.misc new file mode 100644 index 00000000..925350e1 --- /dev/null +++ b/changelog.d/819.misc @@ -0,0 +1 @@ +Update the release script to check for consistency between Node & Rust package versions. diff --git a/scripts/release.sh b/scripts/release.sh index 65834c97..c88984fd 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -3,23 +3,41 @@ if ! command -v jq &> /dev/null then - echo "You must install jq to use this script" - exit + echo "You must install jq to use this script" >&2 + exit 1 fi VERSION=`jq -r .version package.json` + +function parseCargoVersion { + awk '$1 == "version" {gsub("\"", "", $3); print $3}' $1 +} +CARGO_TOML_VERSION=`parseCargoVersion Cargo.toml` +if [[ $VERSION != $CARGO_TOML_VERSION ]]; then + echo "Node & Rust package versions do not match." >&2 + echo "Node version (package.json): ${VERSION}" >&2 + echo "Rust version (Cargo.toml): ${CARGO_TOML_VERSION}" >&2 + exit 2 +fi +CARGO_LOCK_VERSION=`parseCargoVersion <(grep -A1 matrix-hookshot Cargo.lock)` +if [[ $CARGO_TOML_VERSION != $CARGO_LOCK_VERSION ]]; then + echo "Rust package version does not match the lockfile." >&2 + echo "Rust version (Cargo.toml): ${CARGO_TOML_VERSION}" >&2 + echo "Lockfile version (Cargo.lock): ${CARGO_LOCK_VERSION}" >&2 + exit 3 +fi TAG="$VERSION" HEAD_BRANCH=`git remote show origin | sed -n '/HEAD branch/s/.*: //p'` REPO_NAME=`git remote show origin -n | grep -m 1 -oP '(?<=git@github.com:)(.*)(?=.git)'` if [[ "`git branch --show-current`" != $HEAD_BRANCH ]]; then - echo "You must be on the develop branch to run this command." - exit 1 + echo "You must be on the $HEAD_BRANCH branch to run this command." >&2 + exit 4 fi if [ $(git tag -l "$TAG") ]; then - echo "Tag $TAG already exists, not continuing." - exit 1 + echo "Tag $TAG already exists, not continuing." >&2 + exit 5 fi echo "Drafting a new release"