-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·67 lines (50 loc) · 1.67 KB
/
release.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
#!/bin/bash
changelog() {
# NOTE: This requires github_changelog_generator to be installed.
# https://github.com/skywinder/github-changelog-generator
if [ -z "$NEXT" ]; then
NEXT="Unreleased"
fi
echo "Generating changelog upto version: $NEXT"
github_changelog_generator \
--user="samirsilwal" \
--project="structures" \
--token="$GITHUB_TOKEN" \
--no-verbose \
--pr-label "**Changes**" \
--bugs-label "**Bug Fixes**" \
--issues-label "**Closed Issues**" \
--future-release="$NEXT" \
--release-branch=master \
--exclude-labels=unnecessary,duplicate,question,invalid,wontfix
}
printfln() {
printf "\n$1\n"
}
BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo "$TRAVIS_BRANCH"; else echo "$TRAVIS_PULL_REQUEST_BRANCH"; fi)
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
printfln "Exiting for pull request without versioning .....!!!!"
fi
last_tag=$(git tag --sort=-creatordate | head -n 1)
printfln "$last_tag"
if [ -z "$last_tag" ]; then
new_tag="1.0.0"
else
if [ "$BRANCH" == "master" ]; then
new_tag=$(semver bump major $last_tag)
elif [ "$BRANCH" == "dev" ]; then
new_tag=$(semver bump patch $last_tag)
timestamp=$(date -u +%Y%m%d%H%M%S)
new_tag="${new_tag}-${BRANCH}.$timestamp"
fi
fi
if [ "$BRANCH" == "dev" ] || [ "$BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo "Bumping the version: ${last_tag} -> ${new_tag}"
git tag "${new_tag}"
changelog
git add CHANGELOG.md
echo "hello world" > hello.txt
export TEST="version 1.0.4"
echo ${TEST} > my_var.txt
hub release create "$new_tag" -m "$new_tag" || true
fi