Skip to content

Commit 656f6ba

Browse files
committed
Add release script
1 parent 62b33ac commit 656f6ba

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

scripts/new-release.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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"

0 commit comments

Comments
 (0)