-
Notifications
You must be signed in to change notification settings - Fork 105
Build Pipeline (Github Action)
You can create installation files for all different operating systems locally on your computer using the build.bat file or instead you can also run it using a GitHub action.
As a project contributor go to this page and hit Run workflow
button. Afterwards select the branch you want to build for and click Run workflow
(green button).
The pipeline usually needs about 30 minutes to finish. Main reason why it is so slow is that one action is necessary to cleanup old android versions using PowerShell by using Get-ChildItem command.
Once the pipeline has finished you can find the installation files in the artifact section of your run:
The .yml
file that defines the build process can be found here.
This build.yml file is a GitHub Actions workflow configuration for building "Valkyrie". Here's a detailed breakdown of what each part of the file does:
- Checkout Repository: Uses the actions/checkout action to pull the repository's source code.
- Extract Build Version: Reads the version of the build from a file located in unity/Assets/Resources/version.txt and stores it in the Build_Version environment variable for later use.
- Set Up Java Development Kit (JDK): Installs JDK 8 using the actions/setup-java action with the Corretto distribution.
- Add MSBuild: Adds MSBuild to the system PATH using the microsoft/setup-msbuild action, which is essential for building Windows projects.
- Install Unity and Modules: Installs Unity version 2018.4.20f1 along with modules required for building applications on Linux, macOS, Android, and iOS using the kuler90/setup-unity action. Unity is later renamed to a location expected by the build script.
- Unity Activation: Activates Unity using credentials stored in GitHub Secrets (e.g., username, password, and an authenticator key).
- Clean Android SDK: Removes unnecessary Android SDK build tools and platform versions, retaining only specific versions required for the build.
-
Run Build Script: Executes a batch script (build.bat) to compile the project.
⚠️ This is the most complex and important step in the pipeline. If something goes wrong have a look at the build.bat file and try to understand in which step it fails.
- Log Archiving: Archives build logs for different platforms (Windows, macOS, Linux, Android) as artifacts for debugging and reference.
- Build Output Archiving: Archives build outputs (e.g., executables, compressed archives, and installation files) for various platforms, naming them appropriately based on the Build_Version.
-
Action:
actions/checkout@v4
- Purpose: Retrieves the source code from the repository to the workflow environment.
-
Command:
echo "Build_Version=${${{ github.workspace }}/unity/Assets/Resources/version.txt}" | Out-File -FilePath $env:GITHUB_ENV -Append
-
Purpose:
- Reads the
version.txt
file fromunity/Assets/Resources/
. - Stores the build version in the
Build_Version
environment variable for consistent artifact naming.
- Reads the
-
Output: Adds
Build_Version
to the GitHub environment variables.
-
Action:
actions/setup-java@v3
-
Configuration:
java-version: '8'
distribution: 'corretto'
- Purpose: Installs JDK 8, required for Unity's Android build pipeline.
-
Action:
microsoft/[email protected]
- Purpose: Adds MSBuild to the system PATH, ensuring it is available for building Windows projects.
-
Action:
kuler90/[email protected]
-
Configurations:
- Installs Unity version
2018.4.20f1
. - Modules:
-
Linux Module:
linux
-
Mac Module:
mac-mono
-
Android Module:
android
-
iOS Module:
ios
-
Linux Module:
- Installation Path:
C:/Program Files
- Installs Unity version
- Purpose: Sets up Unity for building applications on all supported platforms.
-
Action:
kuler90/activate-unity@v1
-
Configurations:
-
unity-username
: (from GitHub Secrets) -
unity-password
: (from GitHub Secrets) -
unity-authenticator-key
: (from GitHub Secrets)
-
- Purpose: Activates Unity using credentials stored in GitHub Secrets, enabling a valid license checkout.
This step uses repository secrets to hand over the credential data. If there is problems with this step (e.g. HTTP 403) please contact the repostory owner Bruce in the Valkyrie Discord (channel #app-development
).
-
Command:
Rename-Item "C:/Program Files/2018.4.20f1" Unity
- Purpose: Renames Unity's installation directory to match the expected path for the custom build script.
-
Commands:
- Remove unused Android SDK build tools:
Get-ChildItem -Path "C:/Android/android-sdk/build-tools" -Exclude 28.0.3,29.0.2 | Remove-Item -Recurse -Force
- Remove unused Android SDK platforms:
Get-ChildItem -Path "C:/Android/android-sdk/platforms" -Exclude android-29 | Remove-Item -Recurse -Force
- Remove unused Android SDK build tools:
- Purpose: Cleans up pre-installed Android SDK components to retain only necessary versions.
-
Command:
${{ github.workspace }}/build.bat
- Purpose: Executes the custom batch script to compile the Unity project for all configured platforms.
This step runs the build.bat file. If anything went wrong in the previous steps (e.g. a system variable has not been set successfully) the script will fail.
-
Action:
actions/upload-artifact@v3
-
Configuration:
- Uploads logs for each platform:
- Windows:
Editor_valkyrie-windows.log
- macOS:
Editor_valkyrie-macos.log
- Linux:
Editor_valkyrie-linux.log
- Android:
Editor_valkyrie-android.log
- Windows:
- Purpose: Stores build logs as artifacts for later debugging and review.
- Uploads logs for each platform:
-
Action:
actions/upload-artifact@v3
-
Configurations:
- Windows:
-
.zip
:valkyrie-windows-${{ env.Build_Version }}.zip
-
.7z
:valkyrie-windows-${{ env.Build_Version }}.7z
-
.exe
:valkyrie-windows-${{ env.Build_Version }}.exe
-
- macOS:
valkyrie-macos-${{ env.Build_Version }}.tar.gz
- Linux:
valkyrie-linux-${{ env.Build_Version }}.tar.gz
- Android:
Valkyrie-android-${{ env.Build_Version }}.apk
- Windows:
- Purpose: Archives build outputs for all platforms and uploads them as artifacts.