Skip to content

Commit

Permalink
Script away cargo version bumping
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines authored and solana-grimes committed Oct 25, 2018
1 parent 7cabe20 commit 926d459
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
4 changes: 2 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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".

Expand Down
64 changes: 64 additions & 0 deletions scripts/increment-cargo-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash -e

usage() {
cat <<EOF
usage: $0 [major|minor|patch]
Increments the Cargo.toml version.
A minor version increment is the default
EOF
exit 0
}

here="$(dirname "$0")"
cd "$here"/..
source ci/semver_bash/semver.sh

readCargoVersion() {
declare Cargo_toml="$1"

while read -r version equals semver _; do
if [[ $version = version && $equals = = ]]; then
echo "${semver//\"/}"
return
fi
done < <(cat "$Cargo_toml")
echo "Unable to locate version in $Cargo_toml" 1>&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

0 comments on commit 926d459

Please sign in to comment.