-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (170 loc) · 7.42 KB
/
android-build.yml
File metadata and controls
194 lines (170 loc) · 7.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
name: Android Build
# These jobs are to be triggered by ar.yml
on:
workflow_dispatch:
workflow_call:
inputs:
compiler:
required: true
type: string
config:
required: true
type: string
image:
required: true
type: string
platform:
required: true
type: string
type:
required: true
type: string
last_artifact:
required: false
type: boolean
run-name: ${{ inputs.platform }} - ${{ inputs.type }}
# Activate compiler cache
env:
O3DE_ENABLE_COMPILER_CACHE: true
O3DE_COMPILER_CACHE_PATH: 'C:\ProgramData\Chocolatey\bin\ccache.exe'
NDK_VERSION: 25.1.8937393
# Note: All 3P Github Actions use the commit hash for security reasons
# Avoid using the tag version, which is vulnerable to supply chain attacks
jobs:
Build:
strategy:
fail-fast: false
runs-on: ${{ inputs.image }}
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
show-progress: false
- name: Git LFS pull
# Minimal pull for profile builds, otherwise pull all
run: |
git lfs install
if ("${{ inputs.type }}" -eq "profile") { git lfs pull --include "*.ico,*.bmp" } else { git lfs pull }
- name: Setup 3p, user, and build folders
# Symlink the .o3de folder to the github workspace to avoid permission issues
run: |
"3rdParty", "build", ".o3de" | % {New-Item "${{ github.workspace }}\$_" -ItemType 'Directory' -Force}
".o3de" | % {New-Item -Path $env:USERPROFILE\$_ -ItemType SymbolicLink -Target ${{ github.workspace }}\$_ -Force}
"AutomatedTesting\Cache", "AutomatedTesting\user" | % {New-Item "${{ github.workspace }}\$_" -ItemType 'Directory' -Force}
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@f84f86840109403e0fe0ded8b0766c9633affa16 # v1.4.7
continue-on-error: true
if: always()
with:
windows_compile_environment: msvc
prepend_symlinks_to_path: false
store_cache: false
restore_cache: false
ccache_options: |
max_size=15G
cache_dir=${{ github.workspace }}\.ccache
- name: Get last run
# Get the last runid of the target branch of a PR or the current branch
uses: dawidd6/action-download-artifact@07ab29fd4a977ae4d2b275087cf67563dfdf0295 # v9
id: last-run-id
if: ${{ inputs.last_artifact }}
continue-on-error: true
with:
workflow_search: true
workflow_conclusion: ""
branch: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.ref_name }}
search_artifacts: true
name: O3DE-${{ inputs.platform }}-${{ inputs.config }}-build
dry_run: true
- name: Set artifact run ID
# Set the run ID of the artifact to be used for the download step
id: set-artifact-run-id
if: steps.last-run-id.outcome == 'success' && inputs.last_artifact == true
run: |
$runId = ${{ fromJSON(steps.last-run-id.outputs.artifacts)[0].workflow_run.id }}
echo "artifact_run_id=$runId" >> $env:GITHUB_OUTPUT
echo "Using artifacts from previous run: $runId"
- name: Restore artifact cache
# Restore the artifact from the "Get last run" step or from the current run
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
id: restore-artifact-cache
continue-on-error: true
with:
name: O3DE-${{ inputs.platform }}-${{ inputs.config }}-build
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ steps.set-artifact-run-id.outputs.artifact_run_id || github.run_id }}
- name: Extract artifact
# Extract the tar file from the artifact
id: extract-artifact
if: ${{ steps.restore-artifact-cache.outcome == 'success' }}
continue-on-error: true
run: |
if (Test-Path ${{ github.workspace }}\cache.tar) {
tar -xvpf ${{ github.workspace }}\cache.tar
rm ${{ github.workspace }}\cache.tar
}
- name: Setup cmake
# Pin the version of cmake
uses: lukka/get-cmake@56d043d188c3612951d8755da8f4b709ec951ad6 # v3.31.6
with:
cmakeVersion: "~3.30.0"
- name: Set MSBuild options
# Configuire VS environment variables through the developer command prompt for MSVC
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
- name: Configure environment
# Install dependencies for gradle and clang builds from the NDK
continue-on-error: true
run: |
echo "Installing dependencies"
echo "Getting python..."
python\get_python.bat
echo "Installing NDK ${{ env.NDK_VERSION }}..."
& "$env:ANDROID_HOME\cmdline-tools\latest\bin\sdkmanager.bat" --install 'ndk;${{ env.NDK_VERSION }}' --sdk_root=$env:ANDROID_HOME
echo "LY_NDK_DIR=$env:ANDROID_HOME\ndk\${{ env.NDK_VERSION }}" >> $env:GITHUB_ENV
echo "JDK_HOME=$env:JAVA_HOME_17_X64" >> $env:GITHUB_ENV
echo "JAVA_HOME=$env:JAVA_HOME_17_X64" >> $env:GITHUB_ENV
echo "GRADLE_BUILD_HOME=$env:GRADLE_HOME" >> $env:GITHUB_ENV
- name: Build ${{ inputs.type }}
# Builds with presets in ../scripts/build/Platform/Android/build_config.json
env:
LY_3RDPARTY_PATH: ${{ github.workspace }}\3rdParty
USE_CCACHE: 1
NDK_CCACHE: ${{ env.O3DE_COMPILER_CACHE_PATH }}
CMAKE_C_COMPILER_LAUNCHER: ${{ env.O3DE_COMPILER_CACHE_PATH }}
CMAKE_CXX_COMPILER_LAUNCHER: ${{ env.O3DE_COMPILER_CACHE_PATH }}
run: |
scripts\o3de.bat register --this-engine # Resolves registration issue with gradle build
python\python.cmd -u scripts\build\ci_build.py --platform ${{ inputs.platform }} --type ${{ inputs.type }}
- name: Compress artifacts
# Compress with posix format to preserve permissions and timestamps at nanosecond precision
id: compress-artifacts
if: ${{ (steps.extract-artifact.outcome == 'success' || steps.extract-artifact.outcome == 'skipped') && !cancelled() && !contains(inputs.type, 'test') }}
continue-on-error: true
run: |
try {
tar --format=posix -cvpf ${{ github.workspace }}\cache.tar `
python `
3rdParty\packages `
AutomatedTesting\Cache `
AutomatedTesting\user `
.ccache
} catch {
echo "Warning: Error during tar compression"
}
- name: Save artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: ${{ steps.compress-artifacts.conclusion == 'success' && !cancelled() && !contains(inputs.type, 'test') }}
continue-on-error: true
with:
name: O3DE-${{ inputs.platform }}-${{ inputs.config }}-build
compression-level: 1
overwrite: true
path: |
${{ github.workspace }}\cache.tar