1#!/bin/bash
2
3set -eu
4
5package=$1
6tag_prefix=$2
7tag_suffix=$3
8version_increment=$4
9
10if [[ -n $(git status --short --untracked-files=no) ]]; then
11 echo "can't bump version with uncommitted changes"
12 exit 1
13fi
14
15which cargo-set-version > /dev/null || cargo install cargo-edit
16cargo set-version --package $package --bump $version_increment
17cargo check --quiet
18
19new_version=$(script/get-crate-version $package)
20branch_name=$(git rev-parse --abbrev-ref HEAD)
21old_sha=$(git rev-parse HEAD)
22tag_name=${tag_prefix}${new_version}${tag_suffix}
23
24git commit --quiet --all --message "${package} ${new_version}"
25git tag ${tag_name}
26
27cat <<MESSAGE
28Locally committed and tagged ${package} version ${new_version}
29
30To push this:
31 git push origin \\
32 ${tag_name} \\
33 ${branch_name}
34
35To undo this:
36 git reset --hard ${old_sha} && git tag -d ${tag_name}
37MESSAGE