forked from atlassian-api/atlassian-python-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbump_version
More file actions
executable file
·65 lines (54 loc) · 1.64 KB
/
bump_version
File metadata and controls
executable file
·65 lines (54 loc) · 1.64 KB
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
#!/bin/bash
if [[ ( -z ${1+x} ) || ( -z ${2+x} ) ]]; then
cat << EOF
usage: $(basename ${0}) repo increment
Quick and dirty version bump script
If a variable "BUILD_VERSION" is set, returns that variable as is
If "BUILD_VERSION" is not set, returns the bumped version based on last existing tag
and appends .devN where N is the build number.
(tags get sorted using 'sort -V', nothing fancy here)
If no tags are present, the initial version will be 0.1.0
Expects arguments:
- repo: the relative/absolute path to the repository
- increment: (major|minor|patch) part of the version to INCREASE, default is patch
EOF
exit 1
fi
REPO_PATH=${1}
INCREASE=${2:patch}
function autoversion(){
if [ -n "${GITHUB_RUN_NUMBER+x}" ]; then
BUILD_NUMBER="${GITHUB_RUN_NUMBER}"
else
BUILD_NUMBER="0" # In the developer machine, this will build x.y.z.dev0
fi
cd ${REPO_PATH} || exit 1
git fetch --tags 2>/dev/null
last_tag=$(git tag | sort -Vr | head -1)
# Catch existing no tags case
if [ -z "${last_tag}" ]; then
echo "0.1.0.dev${BUILD_NUMBER}"
else
a=( ${last_tag//./ } ) # replace points, split into array
case ${INCREASE} in
patch)
((a[2]++))
;;
minor)
((a[1]++))
a[2]=0
;;
major)
((a[0]++))
a[1]=0
a[2]=0
;;
esac
echo "${a[0]}.${a[1]}.${a[2]}.dev${BUILD_NUMBER}"
fi
}
if [ -n "${BUILD_VERSION+x}" ]; then
echo "${BUILD_VERSION}"
else
autoversion
fi