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

Add project_id to Android sign script #967

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
9 changes: 6 additions & 3 deletions site/static/scripts/sign-android
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,16 @@ if [ "$PACKAGE_ID" != "" ]; then
if [ "$GOOGLE_SERVICES_PATH" != "" ]; then
echo "Replacing Google Services values"
GOOGLE_SERVICES=$(jq . "$GOOGLE_SERVICES_PATH")
PROJECT_ID=$(echo "$GOOGLE_SERVICES" | jq -r .project_info.project_id)
PROJECT_NUMBER=$(echo "$GOOGLE_SERVICES" | jq -r .project_info.project_number)
FIREBASE_URL=$(echo "$GOOGLE_SERVICES" | jq -r .project_info.firebase_url)
FIREBASE_URL="https://$PROJECT_ID.firebaseio.com"
echo "Setting FIREBASE_URL to: $FIREBASE_URL"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sadohert maybe remove this echo ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I left the echo in as a bit of a breadcrumb in case the logic picked something up incorrectly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alright

FIREBASE_STORAGE_BUCKET=$(echo "$GOOGLE_SERVICES" | jq -r .project_info.storage_bucket)
FIREBASE_CLIENT=$(echo "$GOOGLE_SERVICES" | jq ".client[] | select(. | .client_info.android_client_info.package_name == \"$PACKAGE_ID\")")
FIREBASE_API_KEY=$(echo "$FIREBASE_CLIENT" | jq -r .api_key[].current_key)
FIREBASE_SDK_APP_ID=$(echo "$FIREBASE_CLIENT" | jq -r .client_info.mobilesdk_app_id)

xmlstarlet ed -L -u "/resources/string[@name='project_id']" -v "$PROJECT_ID" "$STRINGS_VALUES_PATH"
xmlstarlet ed -L -u "/resources/string[@name='firebase_database_url']" -v "$FIREBASE_URL" "$STRINGS_VALUES_PATH"
xmlstarlet ed -L -u "/resources/string[@name='gcm_defaultSenderId']" -v "$PROJECT_NUMBER" "$STRINGS_VALUES_PATH"
xmlstarlet ed -L -u "/resources/string[@name='google_api_key']" -v "$FIREBASE_API_KEY" "$STRINGS_VALUES_PATH"
Expand All @@ -178,8 +181,8 @@ if [ "$MATTERMOST_RELEASE_STORE_FILE" != "" ] && [ "$MATTERMOST_RELEASE_KEY_ALIA
echo "Signing APK"
ALIGNED_APK="$OUTPUT/$APP_NAME-aligned.apk"
SIGNED_APK="$OUTPUT/$NEW_FILE.apk"
ZIPALIGN=$(find "$ANDROID" -name zipalign)
APKSIGNER=$(find "$ANDROID" -name apksigner)
ZIPALIGN=$(find "$ANDROID" -name zipalign | tail -1)
APKSIGNER=$(find "$ANDROID" -name apksigner | tail -1)
$ZIPALIGN -v -p 4 "$REPACK_APK" "$ALIGNED_APK"
$APKSIGNER sign --ks "$MATTERMOST_RELEASE_STORE_FILE" --ks-key-alias "$MATTERMOST_RELEASE_KEY_ALIAS" --ks-pass "pass:$MATTERMOST_RELEASE_PASSWORD" --out "$SIGNED_APK" "$ALIGNED_APK"
rm "$ALIGNED_APK"
Expand Down