Buildalon Auto Start #2
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
# Generated by Buildalon Auto Start. Generate another Unity build workflow at buildalon.com | |
# Feel free to edit this workflow to update build targets or add additional steps. | |
# Check out the Buildalon open source actions at github.com/buildalon | |
name: Buildalon Unity Build | |
on: | |
push: | |
branches: | |
- 'master' | |
pull_request: | |
branches: | |
- 'master' | |
# 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: Android | |
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: 'ProjectSettings/ProjectVersion.txt' | |
# Activates the installation with the provided credentials | |
# https://github.com/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 Buildalon.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 Buildalon.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild' | |
# Upload the build artifacts to Github | |
- uses: actions/upload-artifact@v4 | |
name: Upload Artifacts | |
if: success() || failure() | |
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 }}/**/*.xml | |
${{ env.UNITY_PROJECT_PATH }}/**/*.log | |
${{ env.UNITY_PROJECT_PATH }}/Builds/${{ matrix.build-target }}/ | |
!${{ env.UNITY_PROJECT_PATH || github.workspace }}/Library/**/* | |
!/**/*_BackUpThisFolder_ButDontShipItWithYourGame/** | |
!/**/*_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." | |
} |