-
Notifications
You must be signed in to change notification settings - Fork 1
/
version.sh
76 lines (56 loc) · 1.97 KB
/
version.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
72
73
74
75
#!/bin/sh
result=""
env -i
FILE=$(git describe --contains | cut -d$'\n' -f1)
echo $FILE #| cut -d " " -f1
if [[ $FILE == "" ]]; then
#bitrise doesn't really check out correctly so check out the right branch
export gitStatusOld=`git status`
echo $gitStatusOld
export gitBranch=`git switch -c $BITRISE_GIT_BRANCH`
echo $gitBranch
export gitStatusNew=`git status`
echo $gitStatusNew
#Tell the user we're version bumping
result="There is no tag. Running version bump and making a tag now"
echo $result
#get the marketing version output
export wholeOutput=`xcrun agvtool what-marketing-version`
echo $wholeOutput
#get the whole version number
export oldTag=`echo $wholeOutput | grep Cameras | cut -d '"' -f2`
echo $oldTag
#get the first part of the version number for safekeeping
export majorVersionNumber=`echo $oldTag | cut -d '.' -f1`
echo $majorVersionNumber
#cut just the minor version we need
export minorVersionNumber=`echo $oldTag | cut -d '.' -f2`
echo $minorVersionNumber
#BUMP IT
export newMinorNumber=$(($minorVersionNumber+1))
echo $newMinorNumber
#assemble new version number
export newVersionNumber="$majorVersionNumber.$newMinorNumber.0"
echo $newVersionNumber
#version bump
export wholeOutput=`xcrun agvtool new-marketing-version $newVersionNumber`
echo $wholeOutput
#git tag new version number
git tag $newVersionNumber
#git status
export gitStatus=`git status`
echo $gitStatus
#get branch only
export gitBranch=`echo $gitStatus | cut -d ' ' -f3`
echo $gitBranch
#try checking out to the right freaking place
export checkout=`git checkout $gitBranch`
echo $checkout
#git add and commit and push
git add .
git commit -m "version bump to $newVersionNumber"
git push origin HEAD:$gitBranch
else
result="There is a tag. Not executing version bump, exiting"
echo $result
fi