This section assumes that you are familiar with the Treasure Management Console (TMC).

While developers can manually upload their game builds via the TMC we offer the ability to automate this process via CI/CD. We offer a GitHub Action that can be used to automate this process (recommended) as well as a set of APIs that can be used directly.

The treasureproject/build-uploader@v1 GitHub Action is a simple workflow that can be added to your GitHub repository. It will automatically upload your game builds to the TMC.

If you are already using GitHub Actions to build your game this is a simple addition to your workflow. All that is needed is to add the following step to your workflow:

- name: Upload builds
  uses: treasureproject/build-uploader@v1
  with:
    apiKey: ${{ env.API_KEY }}
    apiBaseUrl: ${{ env.API_BASE_URL }}
    gameId: ${{ env.GAME_ID }}
    windowsBuildPath: PATH_TO_WINDOWS_BUILD
    macosBuildPath: PATH_TO_MAC_BUILD

In this example, the values you should use are:

  • API_KEY: This is your Treasure API key. Please reach out to the Treasure team to get one.
  • API_BASE_URL: This is the base URL of the API. Please reach out to the Treasure team to get one.
  • GAME_ID: This is your game’s slug. This can be found in either the URL when you click on your game in the TMC or in the Game Metadata section when creating an update.
  • PATH_TO_WINDOWS_BUILD: This is the path to your Windows build. This is optional, but you must include this value or the next one.
  • PATH_TO_MAC_BUILD: This is the path to your Mac build. This is optional, but you must include this value or the previous one.

Note: The files you upload must follow the guidelines described in Uploading Builds.

Example (macOS + Windows)

Here is a snippet from an actual example workflow for uploading both a macOS and Windows build to the TMC. This example game is a Snake game created using Tauri.

Setting up the workflow

In the beginning of the workflow we set it up to run on both macOS and Windows.

jobs:
  build-apps:
    permissions:
      contents: write
    strategy:
      fail-fast: true
      matrix:
        include:
          - platform: "macos-latest"
            target: "universal-apple-darwin"
            platform_name: "macos"
          - platform: "windows-latest"
            target: "x86_64-pc-windows-msvc"
            platform_name: "windows"

    runs-on: ${{ matrix.platform }}

We’ve omitted the actual building steps to avoid the example being too long. We built the application and then zipped it, following the guidelines described in Uploading Builds.

Preparing the artifacts

At the end of the build-apps job we upload the build artifacts. This will allow our final step in the workflow to download all of the artifacts and then upload them to the TMC.

- name: Upload build artifact
  uses: actions/upload-artifact@v3
  with:
    name: snake-${{ matrix.platform_name }}
    path: apps/snake/platform_artifacts/${{ matrix.platform_name }}/snake.zip

Uploading the builds

At the end of the workflow we define a step that will run on Ubuntu and upload the previously built artifacts to the TMC. We first check to make sure that the build-apps job has completed successfully. We also will need to load the API_KEY from our secrets and the API_BASE_URL and GAME_ID from the variables.

upload-builds:
  needs: build-apps
  runs-on: ubuntu-latest
  environment: dev
  steps:
    - uses: actions/checkout@v4
    - run: corepack enable
    - name: Download all artifacts
      uses: actions/download-artifact@v3
      with:
        path: artifacts
    - name: Upload builds
      uses: treasureproject/build-uploader@v1
      with:
        apiKey: ${{ secrets.API_KEY }}
        apiBaseUrl: ${{ vars.API_BASE_URL }}
        gameId: ${{ vars.GAME_ID }}
        windowsBuildPath: artifacts/snake-windows/snake.zip
        macosBuildPath: artifacts/snake-macos/snake.zip

APIs

The GitHub Action outlined above is the recommended approach for automating the uploading of your game builds. However, if you are not using GitHub Actions to build your game you can still use the APIs to upload your game builds.

There are two APIs that need to be used to upload your game builds:

  • POST /v3/dashboard/games/${gameId}/builds
  • POST /v3/dashboard/games/${gameId}/builds/${buildId}/complete

Both APIs require passing in your Treasure API key in the x-api-key header. Reach out to the Treasure team to get your API key and the base URL of the API.

Creating a build

To create a build you need to send a POST request to /v3/dashboard/games/${gameId}/builds. This request will return a buildId that you can use to upload your game build.

You will need to provide the following information:

  • windowsChunkTotal: The total number of 10MB chunks that will be uploaded for the Windows build. This is optional, but you must include this value or the next one.
  • macChunkTotal: The total number of 10MB chunks that will be uploaded for the macOS build. This is optional, but you must include this value or the previous one.
  • chunkNumber: This must be 0 for this first call to create the build. For subsequent calls you must increment this value by 1.
  • windowsGameName: The name of the Windows build. In the case that the uploaded file is snake.zip this value should be snake with no file extension. This is optional, but you must include this value or the next one.
  • macGameName: The name of the macOS build. In the case that the uploaded file is snake.zip this value should be snake with no file extension. This is optional, but you must include this value or the previous one.

For an example of how to create a build, please see this example in the GitHub Action.

Uploading a build

To upload a build you need to send a POST request to /v3/dashboard/games/${gameId}/builds. On success this will return the same buildId that you received when you created the build.

You will need to provide the following information:

  • chunkNumber: Starting from 1, this number must be incremented by 1 for each subsequent call to upload a chunk.
  • buildId: The build ID that you received when you created the build.
  • buildChunk: The chunk of 10MB bytes that you want to upload.
  • platform: The platform that you want to upload the chunk for. This can be either windows or mac.

For an example of how to upload a build, please see this example in the GitHub Action.

Completing a build

To complete a build you need to send a POST request to /v3/dashboard/games/${gameId}/builds/${buildId}/complete.

No arguments are required for this request, except for the header and the url parameters.

Note: This endpoint will only fail if authentication fails. To check to see if your build has completed successfully, you will need to check the Builds section of the TMC.

For an example of how to complete a build, please see this example in the GitHub Action.