forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7cabe20
commit 926d459
Showing
2 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |