Skip to content

Commit 049fc8f

Browse files
authored
Merge pull request #9 from fossasia/development
chore: merge dev branch into master
2 parents 0c077eb + bbcb3bf commit 049fc8f

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ install:
2626

2727
script:
2828
- 'if [ "$TRAVIS_BRANCH" != "apk" ]; then ./gradlew build --stacktrace; fi'
29+
30+
after_success:
31+
- bash scripts/prep-key.sh
32+
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then bash scripts/upload-apk.sh; fi'
33+

scripts/prep-key.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
set -e
3+
4+
export DEPLOY_BRANCH=${DEPLOY_BRANCH:-master}
5+
6+
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "fossasia/neurolab-android" -o "$TRAVIS_BRANCH" != "$DEPLOY_BRANCH" ]; then
7+
echo "We decrypt key only for pushes to the master branch and not PRs. So, skip."
8+
exit 0
9+
fi
10+
11+
# TODO: Settle signing keys
12+
# openssl aes-256-cbc -K $encrypted_d4de000c59f7_key -iv $encrypted_d4de000c59f7_iv -in ./scripts/secrets.tar.enc -out ./scripts/secrets.tar -d
13+
# tar xvf ./scripts/secrets.tar -C scripts/

scripts/upload-apk.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/sh
2+
set -e
3+
4+
export PUBLISH_BRANCH=${PUBLISH_BRANCH:-master}
5+
export DEVELOPMENT_BRANCH=${DEVELOPMENT_BRANCH:-development}
6+
7+
#setup git
8+
git config --global user.email "[email protected]"
9+
git config --global user.name "Travis CI"
10+
11+
#clone the repository
12+
git clone --quiet --branch=apk https://fossasia:$GITHUB_API_KEY@github.com/fossasia/neurolab-android apk > /dev/null
13+
14+
cd apk
15+
16+
\cp -r ../app/build/outputs/apk/*/**.apk .
17+
\cp -r ../app/build/outputs/apk/debug/output.json debug-output.json
18+
\cp -r ../app/build/outputs/apk/release/output.json release-output.json
19+
\cp -r ../README.md .
20+
21+
# Signing Apps
22+
23+
if [ "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]; then
24+
echo "Push to master branch detected, signing the app..."
25+
# Retain apk files for testing
26+
mv app-debug.apk app-master-debug.apk
27+
# Generate temporary apk for signing
28+
cp app-release-unsigned.apk app-release-unaligned.apk
29+
# TODO: Sign APK
30+
# jarsigner -tsa http://timestamp.comodoca.com/rfc3161 -sigalg SHA1withRSA -digestalg SHA1 -keystore ../scripts/key.jks -storepass $STORE_PASS -keypass $KEY_PASS app-release-unaligned.apk $ALIAS
31+
# Remove previous release-apk file
32+
\rm -f app-release.apk
33+
# Generate new release-apk file
34+
${ANDROID_HOME}/build-tools/28.0.3/zipalign -v -p 4 app-release-unaligned.apk app-release.apk
35+
# Rename unsigned release apk to master
36+
rm -f app-release-unaligned.apk
37+
mv app-release-unsigned.apk app-master-release.apk
38+
# Push generated apk files to apk branch
39+
git checkout apk
40+
git add -A
41+
git commit -am "Travis build pushed [master]"
42+
git push origin apk --force --quiet> /dev/null
43+
fi
44+
45+
if [ "$TRAVIS_BRANCH" == "$DEVELOPMENT_BRANCH" ]; then
46+
echo "Push to development branch detected, generating apk..."
47+
# Rename apks with dev prefixes
48+
mv app-debug.apk app-dev-debug.apk
49+
mv app-release-unsigned.apk app-dev-release.apk
50+
# Push generated apk files to apk branch
51+
git checkout apk
52+
git add -A
53+
git commit -am "Travis build pushed [development]"
54+
git push origin apk --force --quiet> /dev/null
55+
fi
56+
57+
# TODO: Publish App to Play Store
58+
if [ "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]; then
59+
# gem install fastlane
60+
# fastlane supply --apk app-release.apk --track alpha --json_key ../scripts/fastlane.json --package_name $PACKAGE_NAME
61+
fi
62+

0 commit comments

Comments
 (0)