show version in cli and web
This commit is contained in:
50
_do_bump_version
Executable file
50
_do_bump_version
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
|
||||
# safety checks
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "usage: $0 <major|minor|patch>" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -n "$(git status --porcelain)" ]]; then
|
||||
echo "working directory is dirty" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# get the current verison from last git tag into array and
|
||||
# inc the provided part
|
||||
semver_expression='s/^v([0-9]+)\.([0-9]+)\.([0-9]+).*$/\1 \2 \3/'
|
||||
version=( $(git describe --tags | sed -E -e "$semver_expression" ) )
|
||||
case "$1" in
|
||||
major)
|
||||
((version[0]++))
|
||||
version[1]=0
|
||||
version[2]=0
|
||||
;;
|
||||
minor)
|
||||
((version[1]++))
|
||||
version[2]=0
|
||||
;;
|
||||
patch)
|
||||
((version[2]++))
|
||||
;;
|
||||
*)
|
||||
echo 'please provide a valid version in increment' >&2
|
||||
exit 1
|
||||
esac
|
||||
new_version="v${version[0]}.${version[1]}.${version[2]}"
|
||||
|
||||
# write version to go
|
||||
mkdir version >/dev/null 2>&1
|
||||
cat > version/version.go << EOL
|
||||
// generated by \`_do_bump_version\` script in project root
|
||||
// $(date)
|
||||
// DO NOT EDIT
|
||||
|
||||
package version
|
||||
|
||||
const VERSION = "$new_version"
|
||||
EOL
|
||||
|
||||
# create and tag single commit with a change to the version file
|
||||
git commit --all --message "bump to $new_version"
|
||||
git tag "$new_version"
|
||||
Reference in New Issue
Block a user