Commit 4afc9b02 authored by Eric Eastwood's avatar Eric Eastwood
Browse files

Fix keystore invalid format errors (use propery binary encoding)

As discussed in https://gitlab.com/gitlab-org/gitter/gitter-android-app/merge_requests/5#note_122709696

We convert the jks file to hex and store in a project secret variable(environment variable).
Then when running, we take the hex varible and convert it back to a binary file via `xxd`

Binary to Hex (for storing the secret project variable)
````
xxd -p gitter-android-app.jks
```

Hex to Binary
```
echo "$signing_jks_file_hex" | xxd -r -p -
```

---

Also fix Google Play API key not being saved in place we were trying to look it up, ~/google_play_api_key.json
parent e81b90e3
......@@ -16,3 +16,4 @@ app/src/main/assets/www/
.classpath
.project
*.iml
android-signing-keystore.jks
......@@ -12,6 +12,8 @@ before_script:
# install OS packages
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 build-essential ruby ruby-dev
# We use this for xxd hex->binary
- apt-get --quiet install --yes vim-common
# install Android SDK
- wget --quiet --output-document=android-sdk.tgz https://dl.google.com/android/android-sdk_r${ANDROID_SDK_TOOLS}-linux.tgz
- tar --extract --gzip --file=android-sdk.tgz
......@@ -32,13 +34,14 @@ before_script:
- unzip artifacts.zip
- mkdir -p app/src/main/assets/www
- mv output/android/www/* app/src/main/assets/www/
# save key/keystore files
- echo $GOOGLE_PLAY_SERVICE_ACCOUNT_API_KEY_JSON > gitter_key.json
- echo "$SIGNING_JKS_FILE" > my-release-key.jks
# This is read by fastlane to access the Google Play API
- echo $google_play_service_account_api_key_json > ~/google_play_api_key.json
# Save keystore file used for signing the app
- echo "$signing_jks_file_hex" | xxd -r -p - > android-signing-keystore.jks
after_script:
- rm gitter_key.json
- rm my-release-key.jks
- rm ~/google_play_api_key.json
- rm android-signing-keystore.jks
stages:
- build_test
......@@ -80,7 +83,6 @@ publishStore:
script:
# publish to store
- bundle exec fastlane deploy
- rm ~/gitter_key.json
artifacts:
paths:
- app/build/outputs/
......
......@@ -12,9 +12,9 @@ else {
secretProperties.setProperty("oauth_client_secret", "\"${System.getenv('oauth_client_secret')}\"")
secretProperties.setProperty("oauth_redirect_uri", "\"${System.getenv('oauth_redirect_uri')}\"")
secretProperties.setProperty("google_project_id", "\"${System.getenv('google_project_id') ?: "null"}\"")
secretProperties.setProperty("signing_keystore_password", "${System.getenv('SIGNING_KEYSTORE_PASSWORD')}")
secretProperties.setProperty("signing_key_password", "${System.getenv('SIGNING_KEY_PASSWORD')}")
secretProperties.setProperty("signing_key_alias", "${System.getenv('SIGNING_KEY_ALIAS')}")
secretProperties.setProperty("signing_keystore_password", "${System.getenv('signing_keystore_password')}")
secretProperties.setProperty("signing_key_password", "${System.getenv('signing_key_password')}")
secretProperties.setProperty("signing_key_alias", "${System.getenv('signing_key_alias')}")
}
android {
......@@ -37,7 +37,7 @@ android {
release {
// You need to specify either an absolute path or include the
// keystore file in the same directory as the build.gradle file.
storeFile file("../my-release-key.jks")
storeFile file("../android-signing-keystore.jks")
storePassword "${secretProperties['signing_keystore_password']}"
keyAlias "${secretProperties['signing_key_alias']}"
keyPassword "${secretProperties['signing_key_password']}"
......
json_key_file("~/gitter_key.json") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
json_key_file("~/google_play_api_key.json") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
package_name("im.gitter.gitter") # e.g. com.krausefx.app
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment