|
4 | 4 | if [[ $CIRCLE_BRANCH != pull* ]]
|
5 | 5 | then
|
6 | 6 | export PUBLISH_BRANCH=${PUBLISH_BRANCH:-master}
|
| 7 | + export DEPLOY_BRANCH=${DEPLOY_BRANCH:-development} |
7 | 8 |
|
8 | 9 | git config --global user.name "Travis CI"
|
9 | 10 | git config --global user.email "[email protected]"
|
10 | 11 |
|
| 12 | + ./gradlew bundlePlayStoreRelease |
| 13 | + |
11 | 14 | git clone --quiet --branch=apk https://fossasia:$GITHUB_API_KEY@github.com/fossasia/susi_android apk > /dev/null
|
12 | 15 | ls
|
13 | 16 | cd apk
|
| 17 | + |
14 | 18 | if [ "$CIRCLE_BRANCH" == "$PUBLISH_BRANCH" ]; then
|
15 | 19 | /bin/rm -f *
|
16 | 20 | else
|
17 |
| - /bin/rm -f app-fdroid-debug.apk app-playStore-debug.apk app-playStore-release.apk app-fdroid-release.apk |
18 |
| - fi |
19 |
| - \cp -r ../app/build/outputs/apk/fdroid/*/**.apk . |
20 |
| - \cp -r ../app/build/outputs/apk/playStore/*/**.apk . |
21 |
| - \cp -r ../app/build/outputs/apk/fdroid/debug/output.json fdroidDebug-output.json |
22 |
| - \cp -r ../app/build/outputs/apk/fdroid/release/output.json fdroidRelease-output.json |
23 |
| - \cp -r ../app/build/outputs/apk/playStore/debug/output.json playStoreDebug-output.json |
24 |
| - \cp -r ../app/build/outputs/apk/playStore/release/output.json playStoreRelease-output.json |
25 |
| - |
26 |
| - # Signing App |
27 |
| - if [ "$CIRCLE_BRANCH" == "$PUBLISH_BRANCH" ]; then |
28 |
| - echo "Push to master branch detected, signing the app..." |
29 |
| - \cp app-playStore-release-unsigned.apk app-playStore-release-unaligned.apk |
30 |
| - jarsigner -verbose -tsa http://timestamp.comodoca.com/rfc3161 -sigalg SHA1withRSA -digestalg SHA1 -keystore ../exec/key.jks -storepass $STORE_PASS -keypass $KEY_PASS app-playStore-release-unaligned.apk $ALIAS |
31 |
| - ${ANDROID_HOME}/build-tools/27.0.3/zipalign -vfp 4 app-playStore-release-unaligned.apk app-playStore-release.apk |
| 21 | + /bin/rm -f susiai-dev-* |
32 | 22 | fi
|
33 | 23 |
|
34 |
| - if [ "$CIRCLE_BRANCH" == "$PUBLISH_BRANCH" ]; then |
35 |
| - for file in app*; do |
36 |
| - cp $file susi-ai-master-${file%%} |
37 |
| - done |
38 |
| - fi |
39 |
| - # Create a new branch that will contain only latest apk |
| 24 | + find ../app/build/outputs -type f -name '*.apk' -exec cp -v {} . \; |
| 25 | + find ../app/build/outputs -type f -name '*.aab' -exec cp -v {} . \; |
| 26 | + |
| 27 | + for file in app*; do |
| 28 | + if [ "$CIRCLE_BRANCH" == "$PUBLISH_BRANCH" ]; then |
| 29 | + if [[ ${file} =~ ".aab" ]]; then |
| 30 | + mv $file susiai-master-${file} |
| 31 | + else |
| 32 | + mv $file susiai-master-${file:4} |
| 33 | + fi |
| 34 | + |
| 35 | + elif [ "$CIRCLE_BRANCH" == "$DEPLOY_BRANCH" ]; then |
| 36 | + if [[ ${file} =~ ".aab" ]]; then |
| 37 | + mv $file susiai-dev-${file} |
| 38 | + else |
| 39 | + mv $file susiai-dev-${file:4} |
| 40 | + fi |
| 41 | + |
| 42 | + fi |
| 43 | + done |
| 44 | + |
| 45 | + # Create a new branch that will contain only latest apk |
40 | 46 | git checkout --orphan workaround
|
41 | 47 |
|
42 | 48 | # Add generated APK
|
43 | 49 | git add -A
|
44 |
| - git commit -am "[Circle CI] Update Susi Apk" |
| 50 | + git commit -am "[Circle CI] Update Susi Apk ($(date +%Y-%m-%d.%H:%M:%S))" |
45 | 51 |
|
46 | 52 | # Delete current apk branch
|
47 | 53 | git branch -D apk
|
48 | 54 | # Rename current branch to apk
|
49 |
| - git branch -m apk |
| 55 | + git branch -m apk |
50 | 56 |
|
51 | 57 | # Force push to origin since histories are unrelated
|
52 | 58 | git push origin apk --force --quiet > /dev/null
|
|
57 | 63 | if [ "$CIRCLE_BRANCH" == "$PUBLISH_BRANCH" ]; then
|
58 | 64 | echo "Publishing app to Play Store"
|
59 | 65 | gem install fastlane
|
60 |
| - fastlane supply --apk app-playStore-release.apk --track alpha --json_key ../exec/fastlane.json --package_name $PACKAGE_NAME |
| 66 | + fastlane supply --aab susiai-master-app.aab --skip_upload_apk true --track alpha --json_key ../exec/fastlane.json --package_name $PACKAGE_NAME |
61 | 67 | fi
|
62 | 68 | fi
|
0 commit comments