Skip to content

Commit 5e34f9f

Browse files
authored
Merge pull request #1903 from fossasia/development
chore: updated build script to generate bundles (#1902)
2 parents 2c25bc1 + 514f1ad commit 5e34f9f

File tree

3 files changed

+33
-35
lines changed

3 files changed

+33
-35
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ before_script:
3030
- bash scripts/prep-key.sh
3131

3232
script:
33-
- ./gradlew build --stacktrace
33+
- ./gradlew assemblePlayStoreRelease
34+
- ./gradlew assembleFdroidRelease
3435

3536
after_success:
3637
- bash scripts/upload-apk.sh

scripts/prep-key.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
set -e
33

44
export DEPLOY_BRANCH=${DEPLOY_BRANCH:-master}
5-
export DEV_BRANCH=${DEV_BRANCH:-development}
65

7-
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "fossasia/pslab-android" ] || ! [ "$TRAVIS_BRANCH" == "$DEPLOY_BRANCH" -o "$TRAVIS_BRANCH" == "$DEV_BRANCH" ]; then
6+
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "fossasia/pslab-android" -o "$TRAVIS_BRANCH" != "$DEPLOY_BRANCH" ]; then
87
echo "We decrypt key only for pushes to the master branch and not PRs. So, skip."
98
exit 0
109
fi

scripts/upload-apk.sh

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,57 @@ export DEVELOPMENT_BRANCH=${DEVELOPMENT_BRANCH:-development}
88
git config --global user.email "noreply@travis.com"
99
git 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
1220
git clone --quiet --branch=apk https://fossasia:$GITHUB_API_KEY@github.com/fossasia/pslab-android apk > /dev/null
1321
cd apk
1422

1523
if [ "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]; then
16-
rm -rf *
17-
else
24+
rm -rf pslab-master*
25+
else
1826
rm -rf pslab-dev*
1927
fi
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

5048
git checkout --orphan temporary
5149
# Push generated apk files to apk branch
5250
git 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
5654
git branch -D apk
5755
# Rename current branch to apk
5856
git 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
6361
if [ "$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
6664
fi

0 commit comments

Comments
 (0)