-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstep.sh
executable file
·60 lines (53 loc) · 1.65 KB
/
step.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
#!/bin/bash
# fail if any commands fails
set -e
set -x
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TAG_SED_RULES="tag.sed"
if [ ! -e "$TAG_SED_RULES" ]; then
TAG_SED_RULES="${THIS_SCRIPT_DIR}/tag.sed"
fi
if [ -n "${PROD}" ]; then
suffix="-prod"
sed -i '' -f build_tools/version.sed RELEASE_SPLIT_VERSION
git add RELEASE_SPLIT_VERSION
fi
BITRISE_OLD_TAG=""
if [ -n "${RELEASE_TAG}" ]; then
BITRISE_GIT_TAG="${RELEASE_TAG}${suffix}"
tag_message="chore(version): new release"
else
BITRISE_OLD_TAG="$(git describe --tags --abbrev=0 )"
if [ -n "$(git tag -l ${BITRISE_OLD_TAG}${suffix})" ]; then
BITRISE_GIT_TAG=$(echo $BITRISE_OLD_TAG | sed -f $TAG_SED_RULES )$suffix
tag_message="chore(version): bump version"
else
BITRISE_GIT_TAG="${BITRISE_OLD_TAG}${suffix}"
tag_message="chore(version): new release"
fi
fi
set +e
[[ "$BITRISE_GIT_TAG" =~ "-start" ]] ; changelog_enable=$?
set -e
envman add --key BITRISE_GIT_TAG --value $BITRISE_GIT_TAG
envman add --key CHANGELOG_ENABLE --value $changelog_enable
git commit --allow-empty -m "${tag_message}"
git tag -a "${BITRISE_GIT_TAG}" -m "${tag_message}"
if [ -n "${push}" -a "${push}" == "true" -o "${push}" == "false" ]
then
if [ "${push}" == "true" ]; then
git push --follow-tags origin $BITRISE_GIT_BRANCH
fi
if (( $? )); then
echo "Failure" >&2
exit 1
else
echo "Success, new tags are :"
echo "$(git log --tags --simplify-by-decoration --pretty="format:%ci %d" | head -5)"
# code block that is dependent on success of previous command
fi
exit 0
else
echo "push variable is required and could only be set to true or false"
exit 1
fi