-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbump.sh
executable file
·75 lines (49 loc) · 2.66 KB
/
bump.sh
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
set -euo pipefail
#======================================================================================================================
# Get image details (call script from image directory).
#======================================================================================================================
IMAGE=`basename ${PWD}`
IMAGE_DIR=${PWD}
#======================================================================================================================
# Check the version file exists.
#======================================================================================================================
VERSION_FILE=${IMAGE_DIR}/VERSION
if [[ ! -f "${VERSION_FILE}" ]] ; then
echo "Unable to find version file ${VERSION_FILE}."
exit 1
fi
#======================================================================================================================
# Get the current and new versions.
#======================================================================================================================
CURRENT_VERSION=`cat ${VERSION_FILE}`
A=(${CURRENT_VERSION//./ })
NEW_VERSION="${A[0]}.${A[1]}.$((++A[2]))"
echo "Updating ${IMAGE} from ${CURRENT_VERSION} to ${NEW_VERSION}."
#======================================================================================================================
# Make sure the current branch is 'main'.
#======================================================================================================================
cd ${IMAGE_DIR}
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
if [[ "${CURRENT_BRANCH}" != "main" ]] ; then
echo "Current branch is not 'main'."
exit 1
fi
#======================================================================================================================
# Create a new branch.
#======================================================================================================================
git pull
NEW_BRANCH="v${NEW_VERSION}"
git branch ${NEW_BRANCH}
git checkout ${NEW_BRANCH}
#======================================================================================================================
# Update VERSION and commit.
#======================================================================================================================
printf "%s" ${NEW_VERSION} > VERSION
git add VERSION
export GPG_TTY=$(tty)
git commit --message "Bumping version to ${NEW_VERSION}"
#======================================================================================================================
# Done!
#======================================================================================================================
echo "Done."