Skip to content
This repository was archived by the owner on Jan 31, 2022. It is now read-only.

Commit 0da2069

Browse files
committed
chore(release): Merge with is release
1 parent e85877e commit 0da2069

File tree

3 files changed

+32
-123
lines changed

3 files changed

+32
-123
lines changed

release-force.sh

Lines changed: 0 additions & 73 deletions
This file was deleted.

release.sh

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ if [ $# -ne 1 ]; then
99
fi
1010

1111
FILE_BUILD_GRADLE="$SELF_ROOT/algoliasearch/common.gradle"
12-
FILE_API_CLIENT="$SELF_ROOT/algoliasearch/src/main/java/com/algolia/search/saas/Client.java"
1312
SELF_ROOT=$(cd $(dirname "$0") && pwd)
1413
VERSION_CODE=$1
14+
CHANGELOG="CHANGELOG.md"
1515

1616
set +eo pipefail
1717
COUNT_DOTS=$(grep -o "\." <<< $VERSION_CODE | wc -l)
@@ -25,22 +25,43 @@ fi
2525
# Check that the working repository is clean (without any changes, neither staged nor unstaged).
2626
# An exception is the change log, which should have been edited, but not necessarily committed (we usually commit it
2727
# 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
2929
echo "ERROR: Working copy not clean! Aborting." 1>&2
3030
echo "Please revert or commit any pending changes before releasing." 1>&2
31+
echo "Changes: $(git status)"
3132
exit 1
3233
fi
3334

3435
# Check that the change log contains information for the new version.
3536
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")
3738
set -e
3839
if [[ -z $version_in_change_log ]]; then
3940
echo "Version $VERSION_CODE not found in change log! Aborting." 1>&2
4041
exit 2
4142
fi
4243

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"
4465

4566
for flavor in online offline
4667
do
@@ -76,10 +97,16 @@ $SELF_ROOT/gradlew promoteRepository
7697
# Revert flavor to original.
7798
git checkout $SELF_ROOT/algoliasearch/build.gradle
7899

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
79105
# Commit to git and push to GitHub
80106
git add .
81107
git commit -m "Version $VERSION_CODE"
82108
git tag $VERSION_CODE
83109

84110
echo "Release complete! Pushing to GitHub"
85-
git push --tags
111+
git push origin $VERSION_CODE HEAD
112+

tools/update-version.sh

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)