I would like to write a script in editor build process to just upload apk/ipa to another service that can distribute our app (HockeyApp specifically)
I don’t want to have another machine that just listen to webhook to download ipa/apk from your link and upload to another service. I would like to have upload those from the cloud build directly
I believe you can create your own post build script (with [PostProcessBuild] attribute). I think it should be ok and you should be able to do whatever you need. never tested it myself though.
See the docs for PostProcessBuildAttribute - it’s passed the path of the exported build. For Android that will be the APK. For iOS however, it’s the exported Xcode project since Xcode needs to run separately to build the actual IPA.
Yes. There should be some examples of others doing that in threads on the forums here.
Ya there isn’t a way to get the IPA with the PostProcessBuildAttribute or post-export method in UCB right now. I think the webhook method is probably the right answer for now.
@dannyd This is so sad what we have to spend our money to launch unity build machine that actually can upload IPA directly but we need to waste more money to create a server listening to webhook that really do nothing but download IPA from the link to upload it another place
Pease fix this. If you could have webhook to ping 3rd party service. I think you should have a way to make a ping on localhost cloud machine that still running when the IPA was finished built
Here are the shell scripts I use to automatically push builds to HockeyApp. Put these in your repo, then, under “Advanced Options”, put in the appropriate script as a “Post-build script”.
For Android devices:
#!/bin/bash
# Instructions:
#
# 1) Replace the ____ on line 14 with your corresponding HockeyApp App Token. https://rink.hockeyapp.net/manage/auth_tokens
# 2) Replace the ____ on line 15 with the file name of your APK. (This should be the same as your Build Target name, e.g. "Android Development")
# 3) Commit this script to the Assets/Editor/ folder.
# 4) In Cloud Build, edit the Advanced Settings for the build target for which you want to run the script, and add the relative path to the "Post Build Script Path" entry.
# 5) For further details, or if API does not respond as expected, check HockeyApp documentation:
# https://support.hockeyapp.net/kb/api/api-apps#upload-app
# 6) If HockeyApp responds "the app could not be created" confirm that the BundleID/package name output by UCB
# matches that in the project you are publishing to.
APP_TOKEN=____
BUILD_TARGET="____"
curl \
-F "ipa=@$2/${BUILD_TARGET}.apk" \
-F "notes_type=1" \
-F "status=2" \
-F "notify=0" \
-F "mandatory=0" \
-H "X-HockeyAppToken: ${APP_TOKEN}" \
https://rink.hockeyapp.net/api/2/apps/upload
For Apple devices:
#!/bin/bash
# Instructions:
#
# 1) Replace the ____ on line 13 with your corresponding HockeyApp App Token. https://rink.hockeyapp.net/manage/auth_tokens
# 2) Commit this script to the Assets/Editor/ folder.
# 3) In Cloud Build, edit the Advanced Settings for the build target for which you want to run the script, and add the relative path to the "Post Build Script Path" entry.
# 4) For further details, or if API does not respond as expected, check HockeyApp documentation:
# https://support.hockeyapp.net/kb/api/api-apps#upload-app
# 5) If HockeyApp responds "the app could not be created" confirm that the BundleID/package name output by UCB
# matches that in the project you are publishing to.
APP_TOKEN=____
curl \
-F "ipa=@$2/build.ipa" \
-F "dsym=@$2/build.app.dSYM.zip" \
-F "notes_type=1" \
-F "status=2" \
-F "notify=0" \
-F "mandatory=0" \
-F "tags=dev" \
-H "X-HockeyAppToken: ${APP_TOKEN}" \
https://rink.hockeyapp.net/api/2/apps/upload
EDIT: one other thing to note: if you are using Unity 5.x or earlier, change the line -F "dsym=@$2/build.app.dSYM.zip" \ so it reads -F "dsym=@$2/build.dSYM.zip" \ instead.
@sam_ettinger_sm Thanks for this! I’m trying to setup auto-deployment to Deploygate and your example is very helpful. How did you figure out the “@$2” bit for the build path? Is there some documentation for that somewhere?
For number 2, I have a lot of trouble finding information about doing HTTP requests in post build processes. Is the shell script with cURL above the way to go? I had UnityWebRequests working in Editor, but am having trouble with them in post build stuff.