forked from mopsalarm/Pr0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·70 lines (54 loc) · 1.9 KB
/
release.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
#!/bin/bash
set -eu -o pipefail
if [ $# -eq 0 ] ; then
VERSION=$(egrep -o '[0-9]+' <app/version.gradle)
else
echo "usage: $(basename "$0")"
exit 1
fi
VERSION_NEXT=$(( VERSION + 1 ))
VERSION_PREVIOUS=$(curl -s https://app.pr0gramm.com/beta/open/update.json | jq .version)
UPLOAD_AUTH=$(<upload_auth)
# check if we are clear to go
if [ -n "$(git status --porcelain)" ] ; then
echo "Please commit all your changes and clean working directory."
git status
exit 1
fi
echo "Release steps:"
echo " * Start release of version $VERSION (current beta is $VERSION_PREVIOUS)"
echo " * Upload apk to the update manager using auth '$UPLOAD_AUTH'"
echo " * Create tag for version v$VERSION"
echo " * Increase version to $VERSION_NEXT"
echo ""
# user needs to type yes to continue
read -p 'Is this correct?: ' CONFIRM || exit 1
[ "$CONFIRM" == "yes" ] || exit 1
function format_version() {
local VERSION=$1
echo -n "1."$(( VERSION/10 ))'.'$((VERSION % 10 ))
}
function deploy_upload_apk() {
local FLAVOR=$1
local APK_ALIGNED=app/build/outputs/apk/app-${FLAVOR}-release.apk
local APK_UNALIGNED=app/build/outputs/apk/app-${FLAVOR}-release-unaligned.apk
echo "Upload apk file now..."
curl -u "$UPLOAD_AUTH" -F apk=@"${APK_ALIGNED}" \
https://app.pr0gramm.com/update-manager/upload
}
# compile code and create apks
./gradlew clean assembleOpenRelease generateOpenDebugSources
for FLAVOR in "open" ; do
deploy_upload_apk ${FLAVOR}
done
# create tag for this version
git tag -a "$(format_version ${VERSION})" \
-m "Released version $(format_version ${VERSION})"
# increase app version for further development
echo "ext { appVersion = $VERSION_NEXT }" > app/version.gradle
git add app/version.gradle
git commit -m "Increase version to $VERSION_NEXT after release"
git push
git push --tags
# link to the release manager
echo "Go to the release manager at https://[email protected]/update-manager/"