Skip to content

Instantly share code, notes, and snippets.

@russmatney
Last active August 19, 2025 18:13
Show Gist options
  • Select an option

  • Save russmatney/5db214722f7291a059341a51c387e888 to your computer and use it in GitHub Desktop.

Select an option

Save russmatney/5db214722f7291a059341a51c387e888 to your computer and use it in GitHub Desktop.

Revisions

  1. russmatney revised this gist Aug 19, 2025. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -11,4 +11,7 @@ Just noting that I abandoned using this at all b/c it ran so slow ~40 minutes.
    This could probably be mitigated if you pay for a bigger CI machine,
    but I settled for building and deploying locally via butler (itch's cli tool)

    # Via local bash script
    # Via local bash script

    This is quite hard-coded to the project i used it in, and supports windows, mac, and linux.
    It should be a reasonable starting place for a local build + deploy-to-itch script, once a few things get ironed out.
  2. russmatney revised this gist Aug 19, 2025. 2 changed files with 158 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    The tricky bit for this was getting a unity license into the secrets.
    # Via Github Actions

    The tricky bit for running in CI was getting a unity license into the secrets.
    There's some docs on this here: https://game.ci/docs/github/activation#personal-license

    I created a new unity account explicitly for this usage so i didn't need to use my own.
    @@ -8,3 +10,5 @@ I created a new unity account explicitly for this usage so i didn't need to use
    Just noting that I abandoned using this at all b/c it ran so slow ~40 minutes.
    This could probably be mitigated if you pay for a bigger CI machine,
    but I settled for building and deploying locally via butler (itch's cli tool)

    # Via local bash script
    153 changes: 153 additions & 0 deletions scripts-build_and_deploy_itch.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,153 @@
    #!/usr/bin/env bash
    # This is quite hard-coded to the project i used it in,
    # and supports windows, mac, and linux
    # but should be a reasonable starting place for a local build + deploy-to-itch script

    # exit if any command returns an error
    set -e

    # UNITY_BIN="" // swap for windows path here
    UNITY_BIN="/Applications/Unity/Hub/Editor/2022.3.36f1/Unity.app/Contents/MacOS/Unity"
    echo "UNITY_BIN: $UNITY_BIN"

    BUTLER_BIN="$(which butler)"
    echo "BUTLER_BIN: $BUTLER_BIN"

    ITCH_PROJECT_ID="moonstorm-clerics/rapid-eye-madness"
    echo "ITCH_PROJECT_ID: $ITCH_PROJECT_ID"

    PROJECT_PATH="$PWD"
    echo "PROJECT_PATH: $PROJECT_PATH"

    ###############################################################################
    ## mac builds
    ###############################################################################

    MACOS_BUILDS="Builds/MacOS/RapidEyeMadnessMacOSBuild"
    MACOS_LOG_PATH="$MACOS_BUILDS/build_log.txt"
    MACOS_BUILD_PATH="RapidEyeMadnessMacOSBuild.app"
    MACOS_ZIP_PATH="RapidEyeMadnessMacOSBuild.zip"

    function build_macos
    {
    echo "Building for macos!"
    $UNITY_BIN -quit -batchmode -projectpath $PROJECT_PATH \
    -buildOSXUniversalPlayer "$MACOS_BUILDS/$MACOS_BUILD_PATH" \
    -logFile $MACOS_LOG_PATH
    echo "Built, zipping."
    cd $MACOS_BUILDS
    rm -rf $MACOS_ZIP_PATH
    zip -r $MACOS_ZIP_PATH $MACOS_BUILD_PATH
    cd $PROJECT_PATH
    echo "Zipped."
    }

    function itch_deploy_macos
    {
    echo "Deploying macos build to itch"
    cd $MACOS_BUILDS
    "$BUTLER_BIN" push $MACOS_ZIP_PATH $ITCH_PROJECT_ID:macos
    cd $PROJECT_PATH
    echo "Deployed macos build to itch."
    }

    ###############################################################################
    ## windows builds
    ###############################################################################

    WINDOWS_BUILDS="Builds/Windows"
    WINDOWS_LOG_PATH="$WINDOWS_BUILDS/build_log.txt"
    WINDOWS_BUILD_PATH="$WINDOWS_BUILDS/RapidEyeMadnessWindowsBuild/RapidEyeMadness.exe"
    WINDOWS_TO_ZIP_PATH="RapidEyeMadnessWindowsBuild"
    WINDOWS_ZIP_PATH="RapidEyeMadnessWindowsBuild.zip"

    function build_windows
    {
    echo "Building for windows!"
    $UNITY_BIN -quit -batchmode -projectpath $PROJECT_PATH \
    -buildWindows64Player "$WINDOWS_BUILD_PATH" \
    -logFile $WINDOWS_LOG_PATH
    echo "Built, zipping."
    cd $WINDOWS_BUILDS
    rm -rf $WINDOWS_ZIP_PATH
    zip -r $WINDOWS_ZIP_PATH $WINDOWS_TO_ZIP_PATH
    cd $PROJECT_PATH
    echo "Zipped."
    }

    function itch_deploy_windows
    {
    echo "Deploying windows build to itch"
    cd $WINDOWS_BUILDS
    "$BUTLER_BIN" push $WINDOWS_ZIP_PATH $ITCH_PROJECT_ID:windows
    cd $PROJECT_PATH
    echo "Deployed windows build to itch."
    }

    ###############################################################################
    ## linux builds
    ###############################################################################

    LINUX_BUILDS="Builds/Linux"
    LINUX_LOG_PATH="$LINUX_BUILDS/build_log.txt"
    LINUX_BUILD_PATH="$LINUX_BUILDS/RapidEyeMadnessLinuxBuild/RapidEyeMadness.x86_64"
    LINUX_TO_ZIP_PATH="RapidEyeMadnessLinuxBuild"
    LINUX_ZIP_PATH="RapidEyeMadnessLinuxBuild.zip"

    function build_linux
    {
    echo "Building for linux!"
    $UNITY_BIN -quit -batchmode -projectpath $PROJECT_PATH \
    -buildLinux64Player $LINUX_BUILD_PATH \
    -logFile $LINUX_LOG_PATH
    echo "Built, zipping."
    cd $LINUX_BUILDS
    rm -rf $LINUX_ZIP_PATH
    zip -r $LINUX_ZIP_PATH $LINUX_TO_ZIP_PATH
    cd $PROJECT_PATH
    echo "Zipped."
    }

    function itch_deploy_linux
    {
    echo "Deploying linux build to itch"
    cd $LINUX_BUILDS
    "$BUTLER_BIN" push $LINUX_ZIP_PATH $ITCH_PROJECT_ID:linux
    cd $PROJECT_PATH
    echo "Deployed linux build to itch."
    }

    function build_and_deploy
    {
    if [ $(basename $PROJECT_PATH) != "rapid-eye-madness" ]
    then
    echo "Expected to run in 'rapid-eye-madness' directory, exiting."
    exit 1
    fi

    build_name=$1

    if [ $build_name == "macos" ]
    then
    build_macos
    itch_deploy_macos
    elif [ $build_name == "windows" ]
    then
    build_windows
    itch_deploy_windows
    elif [ $build_name == "linux" ]
    then
    build_linux
    itch_deploy_linux
    elif [ $build_name == "all" ]
    then
    build_and_deploy windows
    build_and_deploy macos
    build_and_deploy linux
    else
    echo "Unsupported build name: $build_name"
    fi

    }

    build_and_deploy $@
  3. russmatney created this gist Aug 19, 2025.
    82 changes: 82 additions & 0 deletions .github-workflows-itch_build_and_deploy.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,82 @@
    name: Build and Deploy for WebGL ItchIo

    on:
    workflow_dispatch: {}
    push:
    branches:
    - deploy

    jobs:
    buildWebGL:
    name: Build for WebGL 🖥️
    runs-on: ubuntu-latest
    strategy:
    fail-fast: false
    steps:
    - name: Checkout code
    uses: actions/checkout@v4
    with:
    lfs: true

    - name: Restore Library cache
    uses: actions/cache@v3
    with:
    path: Library
    key: Library-build-WebGL
    restore-keys: |
    Library-build-
    Library-
    - name: Free Disk Space (Ubuntu)
    uses: jlumbroso/free-disk-space@main

    # - uses: game-ci/unity-test-runner@v4
    # env:
    # UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
    # UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
    # UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
    # with:
    # githubToken: ${{ secrets.GITHUB_TOKEN }}

    - uses: game-ci/unity-builder@v4
    env:
    UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
    UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
    UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
    with:
    targetPlatform: WebGL

    - uses: actions/upload-artifact@v3
    with:
    name: build-WebGL
    path: build/WebGL

    deployItchIo:
    name: Upload to Itch
    needs: buildWebGL
    runs-on: ubuntu-latest
    strategy:
    fail-fast: true
    matrix:
    channel:
    - webgl
    steps:
    - uses: actions/download-artifact@v2.0.8
    with:
    name: build-WebGL
    path: build

    - uses: KikimoraGames/itch-publish@v0.0.3
    with:
    butlerApiKey: ${{ secrets.BUTLER_API_KEY }}
    gameData: ./build/${{ matrix.template }}
    itchUsername: ${{ vars.ITCH_USERNAME }}
    itchGameId: ${{ vars.ITCH_GAME_ID }}
    buildChannel: ${{ matrix.channel }}
    buildNumber: ${{ needs.version.outputs.version_hash }}

    - name: Cleanup to avoid storage limit
    if: always()
    uses: geekyeggo/delete-artifact@v1
    with:
    name: build-WebGL
    10 changes: 10 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    The tricky bit for this was getting a unity license into the secrets.
    There's some docs on this here: https://game.ci/docs/github/activation#personal-license

    I created a new unity account explicitly for this usage so i didn't need to use my own.

    --

    Just noting that I abandoned using this at all b/c it ran so slow ~40 minutes.
    This could probably be mitigated if you pay for a bigger CI machine,
    but I settled for building and deploying locally via butler (itch's cli tool)