是否有任何部署工具可以弥补 Unity Cloud Build 和 Google Play 商店之间的差距,以便将生成的 APK 持续部署到商店?
问问题
1472 次
1 回答
6
这是一个老问题,但仍然非常有效。我已经搞砸了一段时间。曾经为此有一个非常复杂的 bash 脚本,直到我意识到安装了 fastlane,并且您可以在构建后事件的 bash 脚本中轻松使用它。现在它实际上是一个 4 行脚本(减去注释),这里是:
#!/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
因此,只需将其放在“upload.sh”文件中,将其添加为构建配置中的构建后文件。以 json 格式获取您的 google 密钥并将其作为环境变量“PLAYSTORE_KEY”放入。不需要额外的 fastlane 配置,这是一个惊喜,它实际上只需要传入正确的参数即可。
于 2021-11-12T13:33:41.970 回答