Support prerelease versioning

This commit is contained in:
Michael Vines 2018-10-25 11:45:15 -07:00
parent 113b002095
commit 3ae53961c8
1 changed files with 8 additions and 4 deletions

View File

@ -2,7 +2,7 @@
usage() { usage() {
cat <<EOF cat <<EOF
usage: $0 [major|minor|patch] usage: $0 [major|minor|patch|-preXYZ]
Increments the Cargo.toml version. Increments the Cargo.toml version.
A minor version increment is the default A minor version increment is the default
@ -33,7 +33,8 @@ SPECIAL=""
semverParseInto "$(readCargoVersion ./Cargo.toml)" MAJOR MINOR PATCH SPECIAL semverParseInto "$(readCargoVersion ./Cargo.toml)" MAJOR MINOR PATCH SPECIAL
[[ -n $MAJOR ]] || usage [[ -n $MAJOR ]] || usage
currentVersion="$MAJOR.$MINOR.$PATCH" currentVersion="$MAJOR.$MINOR.$PATCH$SPECIAL"
SPECIAL=""
case ${1:-minor} in case ${1:-minor} in
patch) patch)
@ -45,20 +46,23 @@ major)
minor) minor)
MINOR=$((MINOR+ 1)) MINOR=$((MINOR+ 1))
;; ;;
-*)
SPECIAL="$1"
;;
*) *)
echo "Error: unknown argument: $1" echo "Error: unknown argument: $1"
usage usage
;; ;;
esac esac
newVersion="$MAJOR.$MINOR.$PATCH" newVersion="$MAJOR.$MINOR.$PATCH$SPECIAL"
# shellcheck disable=2044 # Disable 'For loops over find output are fragile...' # shellcheck disable=2044 # Disable 'For loops over find output are fragile...'
for Cargo_toml in $(find . -name Cargo.toml); do for Cargo_toml in $(find . -name Cargo.toml); do
# Bump crate version # Bump crate version
( (
set -x set -x
sed -i "$Cargo_toml" -e "s/^version = \"[^\"]\"$/version = \"$newVersion\"/" sed -i "$Cargo_toml" -e "s/^version = \"[^\"]*\"$/version = \"$newVersion\"/"
) )
# Fix up the internal references to the solana_program_interface crate # Fix up the internal references to the solana_program_interface crate