Skip to content

Commit af6bdfd

Browse files
atm1504iamareebjamal
authored andcommitted
chore: Update apk generation and naming convention (#2293)
* chore: Remove unwanted apks and json * make suggested changes * prevent copy of json files * Automatise renaming of files * fix typo * suggested changes * fix: Make suggested changes
1 parent 6327e4a commit af6bdfd

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

exec/apk-gen.sh

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,55 @@ set -e
44
if [[ $CIRCLE_BRANCH != pull* ]]
55
then
66
export PUBLISH_BRANCH=${PUBLISH_BRANCH:-master}
7+
export DEPLOY_BRANCH=${DEPLOY_BRANCH:-development}
78

89
git config --global user.name "Travis CI"
910
git config --global user.email "[email protected]"
1011

12+
./gradlew bundlePlayStoreRelease
13+
1114
git clone --quiet --branch=apk https://fossasia:$GITHUB_API_KEY@github.com/fossasia/susi_android apk > /dev/null
1215
ls
1316
cd apk
17+
1418
if [ "$CIRCLE_BRANCH" == "$PUBLISH_BRANCH" ]; then
1519
/bin/rm -f *
1620
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-*
3222
fi
3323

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
4046
git checkout --orphan workaround
4147

4248
# Add generated APK
4349
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))"
4551

4652
# Delete current apk branch
4753
git branch -D apk
4854
# Rename current branch to apk
49-
git branch -m apk
55+
git branch -m apk
5056

5157
# Force push to origin since histories are unrelated
5258
git push origin apk --force --quiet > /dev/null
@@ -57,6 +63,6 @@ then
5763
if [ "$CIRCLE_BRANCH" == "$PUBLISH_BRANCH" ]; then
5864
echo "Publishing app to Play Store"
5965
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
6167
fi
6268
fi

0 commit comments

Comments
 (0)