Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Improve APK Names #422

Merged
merged 1 commit into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions scripts/prep-key.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/sh
set -e

export DEPLOY_BRANCH=${DEPLOY_BRANCH:-master}
export DEPLOY_BRANCH=${DEPLOY_BRANCH:-development}
export PUBLISH_BRANCH=${PUBLISH_BRANCH:-master}

if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "fossasia/badge-magic-android" -o "$TRAVIS_BRANCH" != "$DEPLOY_BRANCH" ]; then
echo "We decrypt key only for pushes to the master branch and not PRs. So, skip."
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "fossasia/badge-magic-android" ] || ! [ "$TRAVIS_BRANCH" == "$DEPLOY_BRANCH" -o "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]; then
echo "We decrypt key only for pushes to the master or development branch and not PRs. So, skip."
exit 0
fi

Expand Down
38 changes: 16 additions & 22 deletions scripts/upload-apk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,24 @@ else
fi

\cp -r ../app/build/outputs/apk/*/**.apk .
\cp -r ../app/build/outputs/apk/debug/output.json debug-output.json
\cp -r ../app/build/outputs/apk/release/output.json release-output.json
\cp -r ../README.md .

# Signing Apps

if [[ "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]]; then
echo "Push to master branch detected, signing the app..."
cp app-release-unsigned.apk app-release-unaligned.apk
jarsigner -verbose -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
${ANDROID_HOME}/build-tools/28.0.3/zipalign -v -p 4 app-release-unaligned.apk app-release.apk
fi

if [[ "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]]; then
for file in app*; do
mv ${file} badge-magic-master-${file%%}
done
fi

if [[ "$TRAVIS_BRANCH" == "$DEPLOY_BRANCH" ]]; then
for file in app*; do
mv ${file} badge-magic-dev-${file%%}
done
fi
cp app-release-unsigned.apk app-release-unaligned.apk
jarsigner -verbose -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
${ANDROID_HOME}/build-tools/28.0.3/zipalign -v -p 4 app-release-unaligned.apk app-release.apk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fail for PRs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how?


#removing unused apps
for file in app*; do
if [[ ${file} =~ "unsigned" || ${file} =~ "unaligned" ]]; then
rm ${file}
else
if [[ "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]]; then
mv ${file} badge-magic-master-${file:4}
elif [[ "$TRAVIS_BRANCH" == "$DEPLOY_BRANCH" ]]; then
mv ${file} badge-magic-dev-${file:4}
fi
fi
done

# Create a new branch that will contains only latest apk
git checkout --orphan temporary
Expand Down