-
-
Save damouse/f764f2c7046ef1da42c252eea85c8a39 to your computer and use it in GitHub Desktop.
Revisions
-
damouse revised this gist
Jul 22, 2020 . 1 changed file with 11 additions and 0 deletions.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 charactersOriginal file line number Diff line number Diff line change @@ -4,8 +4,19 @@ # and is incremented by one for the field indicated by the bump command argument. # Example Usage: # Show the current tag # bump -l # Major bump, like 1.2.3 -> 2.0.0 # bump major This is a new Update for You # Minor bump, like 1.2.3 -> 1.3.0 # bump minor This is a new Update for You # Patch bump, like 1.2.3 -> 1.2.4 # bump patch This is a new Update for You # Install directly with # sudo wget https://gist.github.com/damouse/f764f2c7046ef1da42c252eea85c8a39/raw/bump -O /usr/local/bin/bump && sudo chmod +x /usr/local/bin/bump find_latest_semver() { -
damouse revised this gist
Jul 22, 2020 . 1 changed file with 46 additions and 20 deletions.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 charactersOriginal file line number Diff line number Diff line change @@ -20,27 +20,53 @@ find_latest_semver() { fi } # Call with (major | minor | patch) <version> update_version() { case $1 in "major" ) major=true;; "minor" ) minor=true;; "patch" ) patch=true;; esac shift $(($OPTIND - 1)) version=$2 a=( ${version//./ } ) if [ ! -z $major ]; then ((a[0]++)) a[1]=0 a[2]=0 fi if [ ! -z $minor ]; then ((a[1]++)) a[2]=0 fi if [ ! -z $patch ]; then ((a[2]++)) fi echo "${a[0]}.${a[1]}.${a[2]}" } bump() { latest_ver="${PREFIX}$(find_latest_semver)" latest_commit=$(git rev-parse "${latest_ver}" 2>/dev/null ) head_commit=$(git rev-parse HEAD) next_ver=$(update_version $1 $latest_ver) shift 1 message=$@ if [ "$latest_commit" = "$head_commit" ]; then echo "refusing to tag; $latest_ver already tagged for HEAD ($head_commit)" else echo "bumping $latest_ver to $next_ver with message '$message'" git tag -a "$next_ver" -m "$message" git push --tags fi } usage() { @@ -77,8 +103,8 @@ bump_type=$1 shift 1 case $bump_type in major) bump major "$@";; minor) bump minor "$@";; patch) bump patch "$@";; *) usage esac -
damouse revised this gist
May 26, 2020 . 1 changed file with 1 addition and 1 deletion.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 charactersOriginal file line number Diff line number Diff line change @@ -81,4 +81,4 @@ case $bump_type in minor) bump 0 1 0 "$@";; patch) bump 0 0 1 "$@";; *) usage esac -
damouse revised this gist
May 15, 2020 . 1 changed file with 1 addition and 1 deletion.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 charactersOriginal file line number Diff line number Diff line change @@ -38,7 +38,7 @@ bump() { echo "refusing to tag; $latest_ver already tagged for HEAD ($head_commit)" else echo "bumping $latest_ver to $next_ver with message '$message'" git tag -a "$next_ver" -m "$message" git push --tags fi } -
damouse revised this gist
May 15, 2020 . No changes.There are no files selected for viewing
-
damouse revised this gist
May 15, 2020 . 1 changed file with 3 additions and 0 deletions.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 charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,9 @@ # If no semantic version tags exist in the project, the version starts out at v0.0.0 # and is incremented by one for the field indicated by the bump command argument. # Example Usage: # bump minor This is a new Update for You # Install directly with # sudo wget https://gist.github.com/damouse/f764f2c7046ef1da42c252eea85c8a39/raw/bump -O /usr/local/bin/bump && sudo chmod +x /usr/local/bin/bump find_latest_semver() { -
damouse revised this gist
May 15, 2020 . 1 changed file with 8 additions and 5 deletions.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 charactersOriginal file line number Diff line number Diff line change @@ -28,11 +28,14 @@ bump() { latest_commit=$(git rev-parse "${latest_ver}" 2>/dev/null ) head_commit=$(git rev-parse HEAD) shift 3 message=$@ if [ "$latest_commit" = "$head_commit" ]; then echo "refusing to tag; $latest_ver already tagged for HEAD ($head_commit)" else echo "bumping $latest_ver to $next_ver with message '$message'" git tag -a "$next_ver" -m $message git push --tags fi } @@ -71,8 +74,8 @@ bump_type=$1 shift 1 case $bump_type in major) bump 1 0 0 "$@";; minor) bump 0 1 0 "$@";; patch) bump 0 0 1 "$@";; *) usage esac -
damouse revised this gist
May 15, 2020 . 1 changed file with 7 additions and 4 deletions.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 charactersOriginal file line number Diff line number Diff line change @@ -67,9 +67,12 @@ fi if [ "$#" -lt 2 ]; then usage; exit 0; fi bump_type=$1 shift 1 case $bump_type in major) bump 1 0 0 $@;; minor) bump 0 1 0 $@;; patch) bump 0 0 1 $@;; *) usage esac -
damouse revised this gist
Apr 25, 2020 . 1 changed file with 2 additions and 2 deletions.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 charactersOriginal file line number Diff line number Diff line change @@ -32,8 +32,8 @@ bump() { echo "refusing to tag; $latest_ver already tagged for HEAD ($head_commit)" else echo "bumping $latest_ver to $next_ver with message '$4'" git tag "$next_ver" $4 git push --tags fi } -
damouse revised this gist
Apr 25, 2020 . 1 changed file with 13 additions and 6 deletions.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 charactersOriginal file line number Diff line number Diff line change @@ -27,21 +27,26 @@ bump() { latest_ver="${PREFIX}$(find_latest_semver)" latest_commit=$(git rev-parse "${latest_ver}" 2>/dev/null ) head_commit=$(git rev-parse HEAD) if [ "$latest_commit" = "$head_commit" ]; then echo "refusing to tag; $latest_ver already tagged for HEAD ($head_commit)" else echo "bumping $latest_ver to $next_ver with message '$4'" # git tag "$next_ver" $head_commit # git push --tags fi } usage() { echo "Usage: bump [-p prefix] <major|minor|patch> <message> | -l" echo "Bumps the semantic version field by one for a git-project." echo echo "Options:" echo " -l list the latest tagged version instead of bumping." echo " -p prefix [to be] used for the semver tags." echo "" echo "Example:" echo " bump patch 'Fixed many bugs'" exit 1 } @@ -60,9 +65,11 @@ if [ ! -z "$LIST" ];then exit 0 fi if [ "$#" -lt 2 ]; then usage; exit 0; fi case $1 in major) bump 1 0 0 $2;; minor) bump 0 1 0 $2;; patch) bump 0 0 1 $2;; *) usage esac -
damouse revised this gist
Apr 25, 2020 . 1 changed file with 1 addition and 2 deletions.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 charactersOriginal file line number Diff line number Diff line change @@ -4,8 +4,7 @@ # and is incremented by one for the field indicated by the bump command argument. # Install directly with # sudo wget https://gist.github.com/damouse/f764f2c7046ef1da42c252eea85c8a39/raw/bump -O /usr/local/bin/bump && sudo chmod +x /usr/local/bin/bump find_latest_semver() { pattern="^$PREFIX([0-9]+\.[0-9]+\.[0-9]+)\$" versions=$(for tag in $(git tag); do -
damouse revised this gist
Apr 25, 2020 . No changes.There are no files selected for viewing
-
damouse revised this gist
Apr 25, 2020 . 1 changed file with 5 additions and 1 deletion.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 charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,9 @@ # If no semantic version tags exist in the project, the version starts out at v0.0.0 # and is incremented by one for the field indicated by the bump command argument. # Install directly with # sudo wget https://gist.github.com/damouse/f764f2c7046ef1da42c252eea85c8a39/raw/78e6d9610fed5c64c16a65a71ac39fc344c9d1cc/bump -O /usr/local/bin/bump && sudo chmod +x /usr/local/bin/bump find_latest_semver() { pattern="^$PREFIX([0-9]+\.[0-9]+\.[0-9]+)\$" versions=$(for tag in $(git tag); do @@ -62,4 +65,5 @@ case $1 in major) bump 1 0 0;; minor) bump 0 1 0;; patch) bump 0 0 1;; *) usage esac -
damouse created this gist
Apr 25, 2020 .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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,65 @@ #!/bin/bash # Bumps the semantic version of the git-project. # If no semantic version tags exist in the project, the version starts out at v0.0.0 # and is incremented by one for the field indicated by the bump command argument. find_latest_semver() { pattern="^$PREFIX([0-9]+\.[0-9]+\.[0-9]+)\$" versions=$(for tag in $(git tag); do [[ "$tag" =~ $pattern ]] && echo "${BASH_REMATCH[1]}" done) if [ -z "$versions" ];then echo 0.0.0 else echo "$versions" | tr '.' ' ' | sort -nr -k 1 -k 2 -k 3 | tr ' ' '.' | head -1 fi } increment_ver() { find_latest_semver | awk -F. -v a="$1" -v b="$2" -v c="$3" \ '{printf("%d.%d.%d", $1+a, $2+b , $3+c)}' } bump() { next_ver="${PREFIX}$(increment_ver "$1" "$2" "$3")" latest_ver="${PREFIX}$(find_latest_semver)" latest_commit=$(git rev-parse "${latest_ver}" 2>/dev/null ) head_commit=$(git rev-parse HEAD) if [ "$latest_commit" = "$head_commit" ]; then echo "refusing to tag; $latest_ver already tagged for HEAD ($head_commit)" else echo "tagging $next_ver $head_commit" git tag "$next_ver" $head_commit fi } usage() { echo "Usage: bump [-p prefix] {major|minor|patch} | -l" echo "Bumps the semantic version field by one for a git-project." echo echo "Options:" echo " -l list the latest tagged version instead of bumping." echo " -p prefix [to be] used for the semver tags." exit 1 } while getopts :p:l opt; do case $opt in p) PREFIX="$OPTARG";; l) LIST=1;; \?) usage;; :) echo "option -$OPTARG requires an argument"; exit 1;; esac done shift $((OPTIND-1)) if [ ! -z "$LIST" ];then find_latest_semver exit 0 fi case $1 in major) bump 1 0 0;; minor) bump 0 1 0;; patch) bump 0 0 1;; *) us