Buildalon Action Builder #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Buildalon Unity Build | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
branches: | |
- '*' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
clean: | |
type: boolean | |
default: false | |
required: false | |
description: 'cleans the library folder and deletes cached items' | |
# Cancels any ongoing builds when a new commit is pushed to the same branch | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ ( github.event_name == 'pull_request' || github.event.action == 'synchronize' ) }} | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: buildalon-windows | |
build-target: StandaloneWindows64 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
clean: ${{ github.event.inputs.clean == 'true' }} | |
# Installs the Unity Editor based on your project version text file | |
# sets -> env.UNITY_EDITOR_PATH | |
# sets -> env.UNITY_PROJECT_PATH | |
- uses: buildalon/unity-setup@v1 | |
with: | |
build-targets: ${{ matrix.build-target }} | |
version-file: 'ServiceLocator/ProjectSettings/ProjectVersion.txt' | |
# Activates the installation with the provided credentials | |
# https:/XRTK/activate-unity-license | |
- uses: buildalon/activate-unity-license@v1 | |
with: | |
license: 'Personal' # Chooses license type to use [ Personal, Professional ] | |
username: ${{ secrets.UNITY_USERNAME }} | |
password: ${{ secrets.UNITY_PASSWORD }} | |
# serial: ${{ secrets.UNITY_SERIAL }} # Used for pro license activations | |
# Open the project to check for any issues like script compilation errors | |
- uses: buildalon/unity-action@v1 | |
name: Project Validation | |
with: | |
log-name: 'project-validation' | |
args: '-quit -batchmode -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject' | |
# Build the project | |
- uses: buildalon/unity-action@v1 | |
name: '${{ matrix.build-target }}-Build' | |
with: | |
log-name: '${{ matrix.build-target }}-Build' | |
build-target: '${{ matrix.build-target }}' | |
args: '-quit -batchmode -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild' | |
# Upload the build artifacts to Github | |
- uses: actions/upload-artifact@v4 | |
name: Upload Artifacts | |
with: | |
compression-level: 0 # None | |
retention-days: 1 # How long to keep the artifacts | |
name: '${{ github.run_number }}.${{ github.run_attempt }}-${{ matrix.os }}-${{ matrix.build-target }}-Artifacts' | |
path: | | |
${{ env.UNITY_PROJECT_PATH }}/**/*.log | |
${{ env.UNITY_PROJECT_PATH }}/Builds/${{ matrix.build-target }}/ | |
!${{ env.UNITY_PROJECT_PATH }}/Library/**/* | |
!${{ env.UNITY_PROJECT_PATH }}/Builds/${{ matrix.build-target }}/*_BackUpThisFolder_ButDontShipItWithYourGame/** | |
!${{ env.UNITY_PROJECT_PATH }}/Builds/${{ matrix.build-target }}/*_BurstDebugInformation_DoNotShip/** | |
# Clean up the build artifacts for the next run | |
- name: Clean Artifacts | |
shell: pwsh | |
run: | | |
# Clean Logs | |
Get-ChildItem -Path "${{ env.UNITY_PROJECT_PATH }}" -File -Filter "*.log" -Recurse | Remove-Item -Force | |
$artifacts = "${{ env.UNITY_PROJECT_PATH }}/Builds" | |
Write-Host "::debug::Build artifacts path: $artifacts" | |
if (Test-Path -Path $artifacts) { | |
try { | |
Remove-Item $artifacts -Recurse -Force | |
} catch { | |
Write-Warning "Failed to delete artifacts folder file: $_" | |
} | |
} else { | |
Write-Host "::debug::Artifacts folder not found." | |
} | |
# Initially created using the Buildalon Action Builder |