-
Notifications
You must be signed in to change notification settings - Fork 1
/
bump.sh
executable file
·71 lines (52 loc) · 1.26 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
#!/bin/bash
OS_NAME="$(uname | awk '{print tolower($0)}')"
################################################################################
# command -v tput > /dev/null && TPUT=true
TPUT=
_echo() {
if [ "${TPUT}" != "" ] && [ "$2" != "" ]; then
echo -e "$(tput setaf $2)$1$(tput sgr0)"
else
echo -e "$1"
fi
}
_result() {
echo
_echo "# $@" 4
}
_command() {
echo
_echo "$ $@" 3
}
_success() {
echo
_echo "+ $@" 2
exit 0
}
_error() {
echo
_echo "- $@" 1
exit 1
}
_replace() {
if [ "${OS_NAME}" == "darwin" ]; then
sed -i "" -e "$1" $2
else
sed -i -e "$1" $2
fi
}
################################################################################
if [ ! -f ./VERSION ]; then
printf "v0.0.x" > ./VERSION
fi
BASENAME=$(basename $PWD)
VERSION=$(cat ./VERSION | xargs)
echo "VERSION=${VERSION}"
VERSION=$(echo ${VERSION} | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
echo "VERSION=${VERSION}"
# ./VERSION :: v1.2.3
echo ${VERSION} > ./VERSION
# ./action.yml :: docker://opspresso/action-builder:v1.2.3
_replace "s/${BASENAME}:.*/${BASENAME}:${VERSION}/g" ./action.yml
# ./Dockerfile :: LABEL version=v1.2.3
_replace "s/LABEL version=.*/LABEL version=${VERSION}/g" ./Dockerfile