File: bump-release

package info (click to toggle)
golang-github-appc-docker2aci 0.17.2%2Bdfsg-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 528 kB
  • sloc: sh: 221; makefile: 6
file content (50 lines) | stat: -rwxr-xr-x 1,256 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash -e
#
# Attempt to bump the docker2aci release to the specified version by replacing
# all occurrences of the current/previous version.
#
# Generates two commits: the release itself and the bump to the next +git
# version
#
# YMMV, no disclaimer or warranty, etc.

# make sure we are running in a toplevel directory
if ! [[ "$0" =~ "scripts/bump-release" ]]; then
	echo "This script must be run in a toplevel docker2aci directory"
	exit 255
fi

if ! [[ "$1" =~ ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]$ ]]; then
	echo "Usage: scripts/bump-release <VERSION>"
	echo "   where VERSION must be vX.Y.Z"
	exit 255
fi

function replace_stuff() {
	local FROM
	local TO
	local REPLACE

	FROM=$1
	TO=$2
	# escape special characters
	REPLACE=$(sed -e 's/[]\/$*.^|[]/\\&/g'<<< $FROM)
	shift 2
	echo $* | xargs sed -i --follow-symlinks -e "s/$REPLACE/$TO/g"
}

function replace_version() {
	replace_stuff $1 $2 lib/version.go
}

NEXT=${1:1} 	        # 0.2.3
NEXTGIT="${NEXT}+git"   # 0.2.3+git

PREVGIT=$(grep -Po 'var Version = "\K[^"]*(?=")' lib/version.go) # 0.1.2+git
PREV=${PREVGIT::-4}     # 0.1.2

replace_version $PREVGIT $NEXT
git commit -am "version: bump to v${NEXT}"

replace_version $NEXT $NEXTGIT
git commit -am "version: bump to v${NEXTGIT}"