diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-10-19 11:58:17 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-10-21 14:22:03 +0300 |
commit | 3bd55e6a6059e9111ea4339b69ec34159be507a1 (patch) | |
tree | 90026662c18623b951c180d24d4b7d1e567064ac | |
parent | 15b88423c0dd54101f1883213fe520b53178c2a6 (diff) | |
download | subplot-3bd55e6a6059e9111ea4339b69ec34159be507a1.tar.gz |
xxx
Sponsored-by: author
-rwxr-xr-x | release.sh | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..1438ff4 --- /dev/null +++ b/release.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +set -xeuo pipefail + +usage() { + echo "Usage: $0 REMOTE VERSION" + echo "" + echo "where REMOTE is the remote for gitlab.com and VERSION is the new version number" + echo "" +} + +msg() { + echo "$*" +} + +die() { + echo "ERROR: $*" 1>&2 + exit 1 +} + +current_branch() { + git status --branch --short | awk '/^##/ { print $2 }' +} + +crates() { + git ls-files | grep Cargo.toml | sed 's,Cargo\.toml$,,' | sed 's,^$,.,' +} + +# [ "$(current_branch)" == main ] || die "current branch is not 'main'" + +[ "$#" = 2 ] || ( + usage + die " command line arguments" +) +remote="$1" +version="$2" + +if ! echo "$version" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' >/dev/null; then + die "version number must be numbers and dots only" +fi + +# Check that we can publish. +msg "checking that all crates seem OK" +cargo check -q --release --workspace +cargo build -q --release --workspace + +# This is disabled, for now, because it fails, because ordering of +# crate publishing matters. Also, a crate can't be mock-published, +# until it's dependencies are published. +if false; then + msg "checking that all crates can be published" + for crate in $(crates); do + (cd "$crate" && msg "mock publishing in $(pwd)" && cargo publish -q --dry-run) + done +fi + +# The actual release. +msg "making actual release" +echo git tag -sam "Subplot release $version" "$version" +echo git push --tags "$remote" +echo cargo publish + +msg "" +msg "Subplot version $version has been tagged and published on " +msg "gitlab.com and crates.io. Ask Lars or Daniel to push the tag" +msg "git.liw.fi. Please tell everyone about the new hotness." |