Skip to content

Unity-Builder

Unity-Builder #2

Workflow file for this run

name: Unity-Builder
concurrency:
group: ci-${{ github.actor }}-${{ github.ref }}-runner
cancel-in-progress: true
env:
PROJ_DIR: GAMASimulator
PROJ_NAME: GAMASimulator
BUILD_NAME_PREFIX: Builds
BUILD_DIR: build
BUTLER_LINK: https://broth.itch.zone/butler/linux-amd64/LATEST/archive/default
ITCH_GAME_NAME: erkinseker/gama-simulator
on:
push:
branches:
- main
paths:
# Only build when these are changed by the push
# Actions doesn't support env. variables in this section...
- 'GAMASimulator/Assets/**'
- 'GAMASimulator/Packages/**'
- 'GAMASimulator/ProjectSettings/**'
workflow_dispatch:
jobs:
UnityBuilds:
runs-on: ubuntu-latest
strategy:
matrix:
targetPlatform:
- WebGL
#- StandaloneWindows64
#- StandaloneOSX
#- StandaloneLinux64
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Git Semantic Version
uses: paulhatch/[email protected]
id: semantic_version
with:
# Named version, will be used as suffix for name version tag
namespace: ${{ env.PROJ_NAME }}
# If enabled, diagnostic information will be added to the action output.
debug: true
# Automatically bump patch version
bump_each_commit: true
- name: Library Cache
uses: actions/cache@v3
with:
path: ${{env.PROJ_DIR}}/Library
key: Library-${{ env.PROJ_NAME }}-${{ matrix.targetPlatform }}-${{ hashFiles('${{env.PROJ_DIR}}/Assets/**', '${{env.PROJ_DIR}}/Packages/**', '${{env.PROJ_DIR}}/ProjectSettings/**') }}
restore-keys: |
Library-${{ env.PROJ_NAME }}-${{ matrix.targetPlatform }}-
Library-${{ env.PROJ_NAME }}-
- name: Build Unity Project
uses: game-ci/unity-builder@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
unityVersion: auto
buildName: ${{ env.PROJ_NAME }}
projectPath: ${{env.PROJ_DIR}}
buildsPath: ${{env.BUILD_PATH}}
# use existing semver
versioning: Custom
version: ${{steps.semantic_version.outputs.version}}
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: ${{env.BUILD_NAME_PREFIX}}-${{ matrix.targetPlatform }}
path: ${{env.BUILD_DIR}}/${{ matrix.targetPlatform }}
# Write some strings to env variables for reusing
- name: SaveStrings
run: |
echo "ZIP_NAME=${{env.BUILD_NAME_PREFIX}}-${{ matrix.targetPlatform }}.zip" >> $GITHUB_ENV
# Zip before uploading to itch isn't required, but lower upload size
# Rename the directory to the project name to look cleaner when downloading off itch
- name: Zip Build
run: |
cd "${{env.BUILD_DIR}}"
sudo mv "${{ matrix.targetPlatform }}" "${{ env.PROJ_NAME }}"
sudo zip -v -r "../$ZIP_NAME" "${{ env.PROJ_NAME }}"
cd ..
- name: Download Butler
run: |
curl -L -o butler.zip ${{env.BUTLER_LINK}}
unzip butler.zip
chmod +x butler
./butler -V
tree -L 4
# The zip folder name gets replaced by an itch.io generated name when uploaded, so whatever it is here doesn't matter too much
- name: Push Build to Butler
run: |
./butler push -v $ZIP_NAME ${{env.ITCH_GAME_NAME}}:${{ matrix.targetPlatform }} --userversion ${{steps.semantic_version.outputs.version}}
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}