Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 850d703

Browse files
committed
Support prerelease versioning
1 parent 113b002 commit 850d703

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

scripts/increment-cargo-version.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
usage() {
44
cat <<EOF
5-
usage: $0 [major|minor|patch]
5+
usage: $0 [major|minor|patch|-preXYZ]
66
77
Increments the Cargo.toml version.
88
A minor version increment is the default
@@ -33,7 +33,8 @@ SPECIAL=""
3333
semverParseInto "$(readCargoVersion ./Cargo.toml)" MAJOR MINOR PATCH SPECIAL
3434
[[ -n $MAJOR ]] || usage
3535

36-
currentVersion="$MAJOR.$MINOR.$PATCH"
36+
currentVersion="$MAJOR.$MINOR.$PATCH$SPECIAL"
37+
SPECIAL=""
3738

3839
case ${1:-minor} in
3940
patch)
@@ -45,20 +46,23 @@ major)
4546
minor)
4647
MINOR=$((MINOR+ 1))
4748
;;
49+
-*)
50+
SPECIAL="$1"
51+
;;
4852
*)
4953
echo "Error: unknown argument: $1"
5054
usage
5155
;;
5256
esac
5357

54-
newVersion="$MAJOR.$MINOR.$PATCH"
58+
newVersion="$MAJOR.$MINOR.$PATCH$SPECIAL"
5559

5660
# shellcheck disable=2044 # Disable 'For loops over find output are fragile...'
5761
for Cargo_toml in $(find . -name Cargo.toml); do
5862
# Bump crate version
5963
(
6064
set -x
61-
sed -i "$Cargo_toml" -e "s/^version = \"[^\"]\"$/version = \"$newVersion\"/"
65+
sed -i "$Cargo_toml" -e "s/^version = \"[^\"]*\"$/version = \"$newVersion\"/"
6266
)
6367

6468
# Fix up the internal references to the solana_program_interface crate

0 commit comments

Comments
 (0)