-
Notifications
You must be signed in to change notification settings - Fork 12
Add Scripts for Bumping Versions and Tagging #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mcdonnnj
merged 4 commits into
develop
from
improvement/add_version_bump_and_tag_scripts
Jan 10, 2020
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
67c6960
Add bump_version.sh and tag.sh to support bumping versions and taggin…
mcdonnnj 5b6392d
Move semver requirement to test from install.
mcdonnnj e3e3d90
Move semver requirement from test requirements in setup.py to require…
mcdonnnj 03278ca
Add comments explaining why a temp file is used when updating the ver…
mcdonnnj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,51 @@ | ||
#!/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" | ||
# A temp file is used to provide compatability with macOS development | ||
# as a result of macOS using the BSD version of sed | ||
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" | ||
# A temp file is used to provide compatability with macOS development | ||
# as a result of macOS using the BSD version of sed | ||
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 hidden or 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
-r requirements-test.txt | ||
ipython | ||
semver |
This file contains hidden or 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it may come up in the future and so we don't forget our past, we should probably add a brief comment here about why we do this business with the temp file (short version: Mac OS uses BSD
sed
- see cisagov/cyhy-mailer@283dcbf)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. I've added comments in 03278ca to explain.