From 926d459c8f44427d091446a2dc94251237d519f2 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 25 Oct 2018 09:13:25 -0700 Subject: [PATCH] Script away cargo version bumping --- RELEASE.md | 4 +- scripts/increment-cargo-version.sh | 64 ++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100755 scripts/increment-cargo-version.sh diff --git a/RELEASE.md b/RELEASE.md index ebe907f32..995bfad07 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -12,9 +12,9 @@ When cutting a new channel branch these pre-steps are required: 1. Pick your branch point for release on master. 2. Create the branch. The name should be "v" + the first 2 "version" fields from Cargo.toml. For example, a Cargo.toml with version = "0.9.0" implies the next branch name is "v0.9". -3. Update Cargo.toml to the next semantic version (e.g. 0.9.0 -> 0.10.0). +3. Update Cargo.toml to the next semantic version (e.g. 0.9.0 -> 0.10.0) by running `./scripts/increment-cargo-version.sh`. 4. Push your new branch to solana.git -5. Land your Carto.toml change as a master PR. +5. Land your Cargo.toml change as a master PR. At this point, ci/channel-info.sh should show your freshly cut release branch as "BETA_CHANNEL" and the previous release branch as "STABLE_CHANNEL". diff --git a/scripts/increment-cargo-version.sh b/scripts/increment-cargo-version.sh new file mode 100755 index 000000000..e32858966 --- /dev/null +++ b/scripts/increment-cargo-version.sh @@ -0,0 +1,64 @@ +#!/bin/bash -e + +usage() { + cat <&2 +} + +MAJOR=0 +MINOR=0 +PATCH=0 +SPECIAL="" +semverParseInto "$(readCargoVersion ./Cargo.toml)" MAJOR MINOR PATCH SPECIAL +[[ -n $MAJOR ]] || usage + +currentVersion="$MAJOR.$MINOR.$PATCH" + +case ${1:-minor} in +patch) + PATCH=$((PATCH + 1)) + ;; +major) + MAJOR=$((MAJOR+ 1)) + ;; +minor) + MINOR=$((MINOR+ 1)) + ;; +*) + echo "Error: unknown argument: $1" + usage + ;; +esac + +newVersion="$MAJOR.$MINOR.$PATCH" + +for Cargo_toml in {,common/}Cargo.toml; do + ( + set -x + sed -i $Cargo_toml -e "s/^version = \"$currentVersion\"$/version = \"$newVersion\"/" + ) +done +echo "$currentVersion -> $newVersion" + +exit 0