From e6d1e6440d5d5eb31772fd4bc32642450766010e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 7 Dec 2022 10:16:33 +0100 Subject: [PATCH] add bump.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit for bumping crates in this workspace (it requires cargo-edit being installed). Signed-off-by: Fabian Grünbichler --- bump.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 bump.sh diff --git a/bump.sh b/bump.sh new file mode 100755 index 00000000..08ad1199 --- /dev/null +++ b/bump.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +package=$1 + +if [[ -z "$package" ]]; then + echo "USAGE:" + echo -e "\t bump.sh [patch|minor|major|]" + echo "" + echo "Defaults to bumping patch version by 1" + exit 0 +fi + +cargo_set_version="$(command -v cargo-set-version)" +if [[ -z "$cargo_set_version" || ! -x "$cargo_set_version" ]]; then + echo 'bump.sh requires "cargo set-version", provided by "cargo-edit".' + exit 1 +fi + +if [[ ! -e "$package/Cargo.toml" ]]; then + echo "Invalid crate '$package'" + exit 1 +fi + +version=$2 +if [[ -z "$version" ]]; then + version="patch" +fi + +case "$version" in + patch|minor|major) + bump="--bump" + ;; + *) + bump= + ;; +esac + +cargo_toml="$package/Cargo.toml" +changelog="$package/debian/changelog" + +cargo set-version -p "$package" $bump "$version" +version="$(cargo metadata --format-version=1 | jq ".packages[] | select(.name == \"$package\").version" | sed -e 's/\"//g')" +DEBFULLNAME="Proxmox Support Team" DEBEMAIL="support@proxmox.com" dch --no-conf --changelog "$changelog" --newversion "$version-1" --distribution stable +git commit --edit -sm "bump $package to $version-1" Cargo.toml "$cargo_toml" "$changelog"