@@ -8,59 +8,57 @@ export DEVELOPMENT_BRANCH=${DEVELOPMENT_BRANCH:-development}
88git config --global user.email " noreply@travis.com"
99git config --global user.name " Travis CI"
1010
11+ if [ " $TRAVIS_PULL_REQUEST " != " false" -o " $TRAVIS_REPO_SLUG " != " fossasia/pslab-android" ] || ! [ " $TRAVIS_BRANCH " == " $DEVELOPMENT_BRANCH " -o " $TRAVIS_BRANCH " == " $PUBLISH_BRANCH " ]; then
12+ echo " We upload apk only for changes in Development or Master"
13+ exit 0
14+ fi
15+
16+ # Generate Playstore bundle
17+ ./gradlew bundlePlaystoreRelease
18+
1119# #clone the repository
1220git clone --quiet --branch=apk https://fossasia:$GITHUB_API_KEY @github.com/fossasia/pslab-android apk > /dev/null
1321cd apk
1422
1523if [ " $TRAVIS_BRANCH " == " $PUBLISH_BRANCH " ]; then
16- rm -rf *
17- else
24+ rm -rf pslab-master *
25+ else
1826 rm -rf pslab-dev*
1927fi
2028
21- # Signing Apps
22-
23- if [ " $TRAVIS_BRANCH " == " $PUBLISH_BRANCH " ]; then
24- ./gradlew bundlePlaystoreRelease
25-
26- find ../app/build/outputs -type f \( -name " *.aab" -o -name " .apk" \) -exec cp {} . \;
29+ find ../app/build/outputs -type f -name ' *.apk' -exec cp -v {} . \;
30+ find ../app/build/outputs -type f -name ' *.aab' -exec cp -v {} . \;
2731
28- echo " Push to master branch detected, signing the app..."
29- # Retain apk files for testing
30- mv app-playstore-debug.apk pslab-master-debug.apk
31- mv app-fdroid-debug.apk pslab-master-debug-fdroid.apk
32- # Generate temporary apk for signing
33- mv app-playstore-release.apk pslab-master-release.apk
34- mv app-fdroid-release.apk pslab-master-release-fdroid.apk
35- mv app.aab pslab-master.aab
36- fi
37-
38- if [ " $TRAVIS_BRANCH " == " $DEVELOPMENT_BRANCH " ]; then
39- find ../app/build/outputs -type f -name " *.apk" -exec cp {} . \;
40-
41- echo " Push to development branch detected, generating apk..."
42- # Rename apks with dev prefixes
43- mv app-playstore-debug.apk pslab-dev-debug.apk
44- mv app-fdroid-debug.apk pslab-dev-debug-fdroid.apk
45-
46- mv app-playstore-release.apk pslab-dev-release.apk
47- mv app-fdroid-release.apk pslab-dev-release-fdroid.apk
48- fi
32+ for file in app* ; do
33+ if [ " $TRAVIS_BRANCH " == " $PUBLISH_BRANCH " ]; then
34+ if [[ ${file} =~ " .aab" ]]; then
35+ mv $file pslab-master-${file}
36+ else
37+ mv $file pslab-master-${file: 4}
38+ fi
39+ elif [ " $TRAVIS_BRANCH " == " $DEVELOPMENT_BRANCH " ]; then
40+ if [[ ${file} =~ " .aab" ]]; then
41+ mv $file pslab-dev-${file}
42+ else
43+ mv $file pslab-dev-${file: 4}
44+ fi
45+ fi
46+ done
4947
5048git checkout --orphan temporary
5149# Push generated apk files to apk branch
5250git add .
53- git commit -am " Travis build pushed [$TRAVIS_BRANCH ]"
51+ git commit -m " Travis build pushed to [$TRAVIS_BRANCH ]"
5452
5553# Delete current apk branch
5654git branch -D apk
5755# Rename current branch to apk
5856git branch -m apk
5957
60- git push origin apk --force --quiet > /dev/null
58+ git push origin apk -f --quiet > /dev/null
6159
6260# Publish App to Play Store
6361if [ " $TRAVIS_BRANCH " == " $PUBLISH_BRANCH " ]; then
6462 gem install fastlane
65- fastlane supply --aab pslab-master.aab --track alpha --json_key ../scripts/fastlane.json --package_name $PACKAGE_NAME
63+ fastlane supply --aab pslab-master-app .aab --track alpha --json_key ../scripts/fastlane.json --package_name $PACKAGE_NAME
6664fi
0 commit comments