Search Unity

Unity Addressables Post Build Script to upload to a server

Discussion in 'Unity Build Automation' started by Cjericho4, Jul 30, 2021.

  1. Cjericho4

    Cjericho4

    Joined:
    Feb 8, 2020
    Posts:
    1
    I have been trying (without success) to use a post build script to automate uploading the addressables for our project to the server that we have them hosted on.
    I was wondering if anyone had any ideas as to how to include a public key to the project so that after the build it could upload to the server without having to enter a password because you can't enter a password in through the command line.

    Or if anyone has an example of a .sh script that would be very helpful as the Unity Cloud Build addressables page only has the path that is needed to find the addressables on the machine it was built on.
     
    unity_666-SoFIj1SQrw likes this.
  2. c_andrews

    c_andrews

    Joined:
    Jan 26, 2015
    Posts:
    106
    Hey CJ, I've got a .sh script which uploads the Addressables to an S3 bucket if that helps. I've responded to your private message so I will try to add this to a repo as well.
     
  3. c_andrews

    c_andrews

    Joined:
    Jan 26, 2015
    Posts:
    106
    @Cjericho4 here is two repos for you:

    The first is a SH script which can be run with Cloud Build as a Post build script and it will take the compiled Addressable assets for iOS or Android and push them up to an Amazon S3 bucket.
    https://bitbucket.org/sweettoothgames/unitycloudbuilds3upload/

    Here are my config settings for my Advanced options. I've got a Pre-Export Method setup in there too which injects the Addressable variables used in the other repo:

    Screenshot 2021-08-02 at 11.49.04.png


    For the SH script to work the S3_BUCKET and S3_FOLDER need to be set in the environment variables as well as your AWS_ACCESS_KEY and AWS_SECRET_KEY. I've also got a shell script which pushes my build over to Google Play and the App Store.

    Screenshot 2021-08-02 at 11.48.41.png


    The other repo is a dummy project which should show you how I have setup a Scriptable Object to store the Addressable properties, this gets updated during the pre-export in cloud build.
    https://bitbucket.org/sweettoothgames/unitycloudbuildintegration/

    I did them both at the beginning of the year so any questions please ask. Hopefully I can answer them and hopefully the scripts still work after any updates to Cloud Build.
     
    kaushalJoshi and Kujo87 like this.
  4. roy_unity509

    roy_unity509

    Joined:
    Nov 16, 2020
    Posts:
    1
    Hello, thanks a lot for your help with the shell script!
    I just have one question - what should I do with the WORKSPACE variable?
    I left it as is and got a `No such file or directory` error.
    Thanks again!
     
  5. c_andrews

    c_andrews

    Joined:
    Jan 26, 2015
    Posts:
    106
    Glad you found it useful.
    The WORKSPACE variable should always be set by Cloud Builds CLI.
    Try adding env at the top of the script to see what environment variables are being set.