Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update release script #819

Merged
merged 7 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "matrix-hookshot"
version = "4.5.0"
version = "4.5.1"
edition = "2021"

[lib]
Expand Down
1 change: 1 addition & 0 deletions changelog.d/819.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update the release script to check for consistency between Node & Rust package versions.
30 changes: 24 additions & 6 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading