6

Are there any deployment tools that bridges the gap between Unity Cloud Build and the Google Play Store in order to continuously deploy generated APKs to the store?

Einar Egilsson
  • 3,438
  • 9
  • 36
  • 47
Jay Wick
  • 12,325
  • 10
  • 54
  • 78
  • 1
    i didn't find any direct linking. do share here if you find any. Indirect way is using https://github.com/fastlane/fastlane ( Create a github automation build from Unity Cloud and send it to fastlane )? – Amod Gokhale Nov 30 '16 at 13:55

1 Answers1

10

This is an old question, but still very valid. I've been messing with this for a while. Used to have a ridiculously complicated bash script for this, until I realized that fastlane is installed, and you can easily use it in a bash script in the post build event. Now it's literally a 4 line script (minus comments), here it is:

#!/bin/bash

# Passed in as environment variables from CI, you must get this from Google and put
# it in the environment variable PLAYSTORE_KEY in the Unity build config.
# $PLAYSTORE_KEY - The JSON file with the credentials for the Google Developer account

# You can also just hardcode your package name, e.g. com.candycrush.game or whatever here...
PACKAGE_NAME=$(cat "$WORKSPACE/build.json" | jq -j '.[].bundleid')

# Unity environment variables replace the "\n" signs from the private key with spaces for some reason,
# so we replaces spaces with "\n" signs again so it works properly.
KEY_WITH_NEWLINES=$(echo $PLAYSTORE_KEY | jq '.private_key |= sub(" (?!PRIVATE|KEY)"; "\n"; "g")' -c -j)

# You could also use shorter argument names here, but DO NOT use -e for --release-status, there's some error there where
# fastlane thinks -e should mean the -env option and fails.
# Also, you could put the "draft" and "internal" into environment variables if you want to never have to modify the script
# again and just control it with environment variables.
fastlane supply --package_name "$PACKAGE_NAME" --aab "$UNITY_PLAYER_PATH"  --json_key_data "$KEY_WITH_NEWLINES" --release-status draft --track internal

So just put that in a "upload.sh" file, add it as the post build file in the build config. Get your google key in json format and put it in as the env variable "PLAYSTORE_KEY". No additional fastlane configuration is needed, which was a pleasant surprise, it actually works with just the right parameters passed in.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Einar Egilsson
  • 3,438
  • 9
  • 36
  • 47