@@ -9,9 +9,9 @@ if [ $# -ne 1 ]; then
9
9
fi
10
10
11
11
FILE_BUILD_GRADLE=" $SELF_ROOT /algoliasearch/common.gradle"
12
- FILE_API_CLIENT=" $SELF_ROOT /algoliasearch/src/main/java/com/algolia/search/saas/Client.java"
13
12
SELF_ROOT=$( cd $( dirname " $0 " ) && pwd)
14
13
VERSION_CODE=$1
14
+ CHANGELOG=" CHANGELOG.md"
15
15
16
16
set +eo pipefail
17
17
COUNT_DOTS=$( grep -o " \." <<< $VERSION_CODE | wc -l)
25
25
# Check that the working repository is clean (without any changes, neither staged nor unstaged).
26
26
# An exception is the change log, which should have been edited, but not necessarily committed (we usually commit it
27
27
# along with the version number).
28
- if [[ ! -z ` git status --porcelain | grep -v " CHANGELOG.md\|?? " ` ]]; then
28
+ if [[ ! -z ` git status --porcelain | grep -v " $ CHANGELOG" ` ]]; then
29
29
echo " ERROR: Working copy not clean! Aborting." 1>&2
30
30
echo " Please revert or commit any pending changes before releasing." 1>&2
31
+ echo " Changes: $( git status) "
31
32
exit 1
32
33
fi
33
34
34
35
# Check that the change log contains information for the new version.
35
36
set +e
36
- version_in_change_log=$( cat " $SELF_ROOT /CHANGELOG.md " | grep -E " ^#+" | sed -E ' s/^#* ([0-9.]*)\s*.*$/\1/g' | grep -x " $VERSION_CODE " )
37
+ version_in_change_log=$( cat " $SELF_ROOT /$ CHANGELOG" | grep -E " ^#+" | sed -E ' s/^#* ([0-9.]*)\s*.*$/\1/g' | grep -x " $VERSION_CODE " )
37
38
set -e
38
39
if [[ -z $version_in_change_log ]]; then
39
40
echo " Version $VERSION_CODE not found in change log! Aborting." 1>&2
40
41
exit 2
41
42
fi
42
43
43
- $SELF_ROOT /tools/update-version.sh $VERSION_CODE
44
+ # Only release on master (for manual runs, cannot happen through fastlane)
45
+ currentBranch=$( git rev-parse --abbrev-ref HEAD)
46
+ if [ " $currentBranch " != ' master' ]; then
47
+ printf " Release: You must be on master\\ n"
48
+ exit 1
49
+ fi
50
+
51
+ function call_sed(){
52
+ PATTERN=" $1 "
53
+ FILENAME=" $2 "
54
+
55
+ # Mac needs a space between sed's inplace flag and extension
56
+ if [ " $( uname) " == " Darwin" ]; then
57
+ sed -E -i ' ' " $PATTERN " " $FILENAME "
58
+ else
59
+ sed -E -i " $PATTERN " " $FILENAME "
60
+ fi
61
+ }
62
+
63
+ echo " Updating version number to $VERSION_CODE ..."
64
+ call_sed " s/VERSION = '.*'/VERSION = '$VERSION_CODE '/" " $FILE_BUILD_GRADLE "
44
65
45
66
for flavor in online offline
46
67
do
@@ -76,10 +97,16 @@ $SELF_ROOT/gradlew promoteRepository
76
97
# Revert flavor to original.
77
98
git checkout $SELF_ROOT /algoliasearch/build.gradle
78
99
100
+ # Commit to git
101
+ set +e # don\'t crash if already committed
102
+ git add .
103
+ git commit -m " chore(release): Version $VERSION_CODE [ci skip]"
104
+ set -e
79
105
# Commit to git and push to GitHub
80
106
git add .
81
107
git commit -m " Version $VERSION_CODE "
82
108
git tag $VERSION_CODE
83
109
84
110
echo " Release complete! Pushing to GitHub"
85
- git push --tags
111
+ git push origin $VERSION_CODE HEAD
112
+
0 commit comments