-
Notifications
You must be signed in to change notification settings - Fork 174
/
Copy pathpre-bump-semver.sh
executable file
·62 lines (48 loc) · 1.9 KB
/
pre-bump-semver.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
#!/bin/sh
#
# If we are on the master branch, and the last commit was a merge commit
# then we have work to do.
#
# We need to auto-bump the semver.
#
# We will then commit the new semver file and publish it back to the repo,
# which will cause a new build to be done using the new semver.
#
ENABLED_BRANCH=master
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$BRANCH" = "$ENABLED_BRANCH" ]
then
REV=$(git rev-parse --short HEAD 2> /dev/null)
MSHA=$(git rev-list -1 --merges ${REV}~1..${REV})
if [ ! -z "$MSHA" ]
then
# Ensure we are topped off
git pull origin $BRANCH > /dev/null 2>&1
# If the VERSION file was NOT updated as part of this commit (i.e. not manually updated due to branch having a breaking-change)
MODS=$(git diff --name-only --diff-filter=M @~..@)
VMOD=$(echo ${MODS} | grep common/version/VERSION)
if [ -z "$VMOD" ]
then
# Auto-bump the semver
./bump-semver.sh
# Commit the new/bumped semver
git commit -am "semver bump" --no-verify > /dev/null 2>&1
# Lay down the tag for the new semver
./apply-semver-tag.sh
# Publish the bumped semver up into the repo so everyone receives it
git push origin HEAD > /dev/null 2>&1
# Publish the tags as well
git push origin --tags
# Inform Makefile to stop executing and exit. The push that was performed above
# will cause another build to start, and it will do the entire build using the
# newly-bumped semver.
exit 200
# If the VERSION file WAS updated as part of this commit (i.e. it was manually updated due to branch having a breaking-change)
else
# Add/publish the tag for the new manually updated semver
./apply-semver-tag.sh
git push origin --tags
fi
fi
fi
exit 100