Last active
November 4, 2019 23:11
-
-
Save k2s/2feac7fb5ca8319a8bd198a731015a81 to your computer and use it in GitHub Desktop.
xDrip - build custom APK from multiple pull requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# !!! this folder is only for build | |
# TODO make it parameter of script | |
XDRIP_PATH=/tmp/xdrip-build | |
# !!! public JSON file you are able to publish | |
# this is useful if you include k2s/customUpdater feature and then you are able to update to next releases | |
UPDATE_URL=https://gist.githubusercontent.com/k2s/aa7928197d8ea508135bc20bb9bdd664/raw/xdrip.json | |
# TODO do following only if XDRIP_PATH doesn't exists | |
### clone the main repo | |
git clone https://github.com/NightscoutFoundation/xDrip.git $XDRIP_PATH | |
cd $XDRIP_PATH | |
### make sure there are no local modifications - this folder is only for build | |
lastTagCommit=$(git rev-list -n 1 $(git tag | sort -V | tail -1)) | |
git checkout $lastTagCommit | |
git fetch origin | |
git reset --hard origin/master | |
git clean -ffdx | |
### make sure we have all needed remote repos - depends on what features we want to mix into the release | |
set +e | |
git remote add k2s https://github.com/k2s/xDrip.git | |
git remote add gruoner https://github.com/gruoner/xDrip.git | |
git remote add MasterPlexus https://github.com/MasterPlexus/xDrip.git | |
git remote add karelinoleg https://github.com/karelinoleg/xDrip.git | |
set -e | |
git fetch --all | |
### | |
CONTENT=$(curl --silent "https://api.github.com/repos/NightscoutFoundation/xDrip/releases") | |
LATEST_COMMIT=$(echo "$CONTENT" | grep -m 1 '"target_commitish":' | sed -E 's/.*"([^"]+)".*/\1/') | |
LATEST_URL=$(echo "$CONTENT" | grep -m 1 '"html_url":' | sed -E 's/.*"([^"]+)".*/\1/') | |
git checkout $LATEST_COMMIT | |
### create the release branch from master and merge the other pull-requests | |
git checkout -b k2s-release | |
# https://github.com/NightscoutFoundation/xDrip/pull/880 | |
git merge --no-edit karelinoleg/feature/NotificationGraph | |
git merge --no-edit k2s/customUpdater | |
# git merge --no-edit k2s/patch-1027 not done yet, see https://github.com/NightscoutFoundation/xDrip/issues/1027 | |
git merge --no-edit k2s/widget | |
# next branch has conflict with k2s/slovak ... which we know how to fix | |
# https://github.com/NightscoutFoundation/xDrip/pull/973 | |
# set +e | |
# git merge --no-edit gruoner/more_insulin_types | |
# set -e | |
# sed -i '/^<<<<<<</ d' app/src/main/res/values/strings.xml; sed -i '/^=======/ d' app/src/main/res/values/strings.xml;sed -i '/^>>>>>>>/ d' app/src/main/res/values/strings.xml;git add app/src/main/res/values/strings.xml;git commit --no-edit | |
# https://github.com/NightscoutFoundation/xDrip/pull/1080 | |
set +e | |
git merge --no-edit origin/insulin-types-merge | |
set -e | |
sed -i '/^<<<<<<</ d' app/src/main/res/values/strings.xml; sed -i '/^=======/ d' app/src/main/res/values/strings.xml;sed -i '/^>>>>>>>/ d' app/src/main/res/values/strings.xml;git add app/src/main/res/values/strings.xml;git commit --no-edit | |
# git merge --no-edit k2s/patch-5 # temporary | |
# !!! you have to build in Studio until https://github.com/NightscoutFoundation/xDrip/issues/1012 | |
### build APK | |
#chmod +x ./gradlew | |
#sed -i "s|^distributionUrl=.*|distributionUrl=https\\://services.gradle.org/distributions/gradle-5.4.1-all.zip|g" gradle/wrapper/gradle-wrapper.properties | |
echo "XDRIP_UPDATER_URL=$UPDATE_URL" >> local.properties | |
echo "XDRIP_BUILD_ON=$LATEST_URL" >> local.properties | |
#./gradlew tasks | |
#./gradlew bundleXdripcustom | |
### to reset back | |
# git reset --hard origin/master; git checkout master; git branch -D k2s-release | |
# /home/k2s/Android/Sdk/build-tools/27.0.3/aapt dump badging /tmp/xdrip-build/app/xdripcustom/release/app-xdripcustom-release.apk | grep version | |
# adb install /tmp/xdrip-build/app/xdripcustom/release/app-xdripcustom-release.apk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment