-
Notifications
You must be signed in to change notification settings - Fork 0
/
changelog-it.sh
68 lines (57 loc) · 1.71 KB
/
changelog-it.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
#!/bin/bash
# Author: Alexsander Falcucci
# Usage: . ./changelog-it.sh
# Description: Script to generate and push new tags on Github
# and changelog automatically. Use it always to releases.
BBlack='\033[1;30m' # Black
BRed='\033[1;31m' # Red
BGreen='\033[1;32m' # Green
BYellow='\033[1;33m' # Yellow
BBlue='\033[1;34m' # Blue
BPurple='\033[1;35m' # Purple
BCyan='\033[1;36m' # Cyan
BWhite='\033[1;37m' # White
RESET='\033[0m'
REMOTE="origin"
git remote | grep upstream
if [[ $? -eq "upstream" ]]; then
REMOTE="upstream"
fi
# return 1 if global command line program installed, else 0
function program_is_installed {
# set to 1 initially
local return_=1
# set to 0 if not found
type $1 >/dev/null 2>&1 || { local return_=0; }
# return value
echo "$return_"
}
# update all tags
git fetch --all
TAG=`eval 'git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1)'`
echo "latest tag $TAG"
HAS_NODE="$(program_is_installed node)"
SEMANTIC_VERSION=$1
SUMMARY=$2
#
while :
do
if [ "$SEMANTIC_VERSION" != "" ]
then
# force to create a semantic version and publish to gitlab
curl -LsS https://raw.githubusercontent.com/falcucci/versiontag/master/versiontag.sh | bash -s $SEMANTIC_VERSION --force
fi
if [ "$HAS_NODE" == "0" ]
then
echo "Please, install nodejs https://nodejs.org/en/download/"
break
fi
NTAG=`eval 'git describe --tags $(git rev-list --tags --max-count=1)'`
if [ "$NTAG" != $TAG ]
then
echo "new tag $NTAG"
changelog-it --range ${TAG}...${NTAG} --release --gmud
# changelog-it --range ${TAG}...origin/master --release ${NTAG} --slack --summary "$SUMMARY"
fi
break
done