File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -e
4+
5+ #
6+ # # Given version, this script creates & pushes a relevant git-tag.
7+ #
8+
9+ # required version
10+ VERSION=$1
11+
12+ # Make sure ${VERSION} is provided before proceeding
13+ if [[ -z " ${VERSION} " ]]; then
14+ >&2 printf " \nERR: version missing: version needs to be passed as the first argument. Try:\n"
15+ >&2 printf " \t./%s %s\n\n" " $( basename " $0 " ) " " v0.4.22"
16+ exit 1
17+ fi
18+
19+ # Verify there's no uncommitted changes
20+ if [[ -n " $( git status --untracked-files=no --porcelain) " ]]; then
21+ >&2 printf " \nERR: working directory not clean. Commit, or stash changes to continue.\n\n"
22+ exit 1
23+ fi
24+
25+ # Make sure specified ${VERSION} is present in Dockerfile
26+ if ! grep -q " ${VERSION} " " ./Dockerfile" ; then
27+ >&2 printf " \nERR: Requested version not present in Dockerfile. Make sure that's what you want to do.\n\n"
28+ exit 1
29+ fi
30+
31+ # Update git-tags from the remote
32+ git fetch --tags
33+
34+ # Get last build number
35+ LAST=$( git tag | grep ' +build' | sed ' s|^.*build||' | sort -h | tail -n 1)
36+ LAST=${LAST:- 1}
37+
38+ # Increment it
39+ (( LAST++ ))
40+
41+ # Construct the full ${TAG}, ex: `v0.7.7+build666`
42+ TAG=" ${VERSION} +build${LAST} "
43+
44+ printf " Creating tag: %s…\t" " ${TAG} "
45+ git tag -sa " ${TAG} " -m " ${TAG} "
46+ echo " done"
47+
48+ printf " Pushing tag: %s…\t" " ${TAG} "
49+ git push origin " ${TAG} "
50+ echo " All done"
You can’t perform that action at this time.
0 commit comments