-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bump_version.sh and tag.sh to support bumping versions and taggin…
…g through scripts. Update setup.py to include the semver package which is used by the bump_version.sh script.
- Loading branch information
Showing
3 changed files
with
57 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bash | ||
|
||
# bump_version.sh (show|major|minor|patch|prerelease|build) | ||
|
||
set -o nounset | ||
set -o errexit | ||
set -o pipefail | ||
|
||
VERSION_FILE=src/example/_version.py | ||
|
||
HELP_INFORMATION="bump_version.sh (show|major|minor|patch|prerelease|build|finalize)" | ||
|
||
old_version=$(sed -n "s/^__version__ = \"\(.*\)\"$/\1/p" $VERSION_FILE) | ||
|
||
if [ $# -ne 1 ] | ||
then | ||
echo "$HELP_INFORMATION" | ||
else | ||
case $1 in | ||
major|minor|patch|prerelease|build) | ||
new_version=$(python -c "import semver; print(semver.bump_$1('$old_version'))") | ||
echo Changing version from "$old_version" to "$new_version" | ||
tmp_file=/tmp/version.$$ | ||
sed "s/$old_version/$new_version/" $VERSION_FILE > $tmp_file | ||
mv $tmp_file $VERSION_FILE | ||
git add $VERSION_FILE | ||
git commit -m"Bump version from $old_version to $new_version" | ||
git push | ||
;; | ||
finalize) | ||
new_version=$(python -c "import semver; print(semver.finalize_version('$old_version'))") | ||
echo Changing version from "$old_version" to "$new_version" | ||
tmp_file=/tmp/version.$$ | ||
sed "s/$old_version/$new_version/" $VERSION_FILE > $tmp_file | ||
mv $tmp_file $VERSION_FILE | ||
git add $VERSION_FILE | ||
git commit -m"Bump version from $old_version to $new_version" | ||
git push | ||
;; | ||
show) | ||
echo "$old_version" | ||
;; | ||
*) | ||
echo "$HELP_INFORMATION" | ||
;; | ||
esac | ||
fi |
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,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o nounset | ||
set -o errexit | ||
set -o pipefail | ||
|
||
version=$(./bump_version.sh show) | ||
|
||
git tag "v$version" && git push --tags |