Skip to content

Commit 8582414

Browse files
authored
GHA to build EDM4U on x64 Mac (googlesamples#634)
Add GHA to build EDM4U on macOS
1 parent ebfa213 commit 8582414

File tree

3 files changed

+236
-12
lines changed

3 files changed

+236
-12
lines changed

.github/workflows/build.yaml

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,74 @@
1-
name: EDM4U build
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Workflow to build EDM4U packages and compute their hash
16+
name: Build
17+
18+
on:
19+
schedule:
20+
- cron: "0 10 * * *" # 10am UTC = 2am PST
21+
22+
pull_request:
23+
types: [ labeled, closed ]
224

3-
on:
425
workflow_dispatch:
526
inputs:
627
unity_version:
728
description: 'Unity version'
829
default: '2019'
9-
required: true
1030
type: string
31+
required: true
1132

1233
env:
13-
pythonVersion: '3.7'
14-
15-
34+
# Use SHA256 for hashing files.
35+
hashCommand: "sha256sum"
36+
1637
jobs:
17-
build_desktop:
18-
name: build-macOS-unity${{ inputs.unity_version}}
19-
runs-on: macos-latest
38+
build_macos:
39+
name: build-macos-unity${{ inputs.unity_version}}
40+
uses: ./.github/workflows/build_macos.yaml
41+
with:
42+
unity_version: ${{ inputs.unity_version}}
43+
44+
finalizing:
45+
# Only compute SHA hash for macOS build
46+
name: finalizing-macOS-unity${{ inputs.unity_version}}
47+
needs: [build_macos]
48+
runs-on: ubuntu-latest
2049
steps:
21-
- uses: actions/checkout@v3
22-
- run: python -v
23-
- run: sysctl -n machdep.cpu.brand_string
50+
- name: Fetch All builds
51+
uses: actions/download-artifact@v3
52+
with:
53+
path: built_artifact
54+
55+
- name: Compute Plugin Hash
56+
shell: bash
57+
run: |
58+
# Compute hash for .tgz package
59+
pushd built_artifact/TarballPackage_macOS
60+
tgz_files_list=$(find -type f -name '*.tgz')
61+
for tgz_file in "${tgz_files_list[@]}"; do
62+
echo tgz_file
63+
${{ env.hashCommand }} --tag ${tgz_file} >> edm4u_hash.txt
64+
done
65+
echo "::warning ::$(cat edm4u_hash.txt)"
66+
popd
67+
68+
# Compute hash for .unitypackage package
69+
pushd built_artifact/AssetPackage_macOS
70+
${{ env.hashCommand }} --tag external-dependency-manager.unitypackage >> edm4u_hash.txt
71+
echo "::warning ::$(cat edm4u_hash.txt)"
72+
popd
73+
74+

.github/workflows/build_macos.yaml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Workflow to build EDM4U packages on macOS
16+
name: Build macOS (SubWorkflow)
17+
18+
on:
19+
workflow_call:
20+
inputs:
21+
unity_version:
22+
description: 'Unity version'
23+
default: '2019'
24+
type: string
25+
required: true
26+
27+
env:
28+
pythonVersion: '3.7'
29+
artifactRetentionDays: 2
30+
assetPackageArtifactName: "AssetPackage_macOS"
31+
tarballPackageArtifactName: "TarballPackage_macOS"
32+
33+
jobs:
34+
build_desktop:
35+
name: build-macOS-unity${{ inputs.unity_version}}
36+
runs-on: macos-latest
37+
strategy:
38+
fail-fast: false
39+
40+
steps:
41+
- uses: actions/checkout@v3
42+
43+
- id: build_setup
44+
uses: ./gha/build_setup
45+
timeout-minutes: 30
46+
with:
47+
unity_version: ${{ inputs.unity_version }}
48+
platform: macOS
49+
python_version: ${{ env.pythonVersion }}
50+
unity_username: ${{ secrets.UNITY_USERNAME }}
51+
unity_password: ${{ secrets.UNITY_PASSWORD }}
52+
unity_serial_ids: ${{ secrets.SERIAL_ID }}
53+
54+
- name: Set Unity Env for EDM4U build script
55+
shell: bash
56+
run: echo "UNITY_EXE=${{ env.UNITY_ROOT_DIR }}/Unity.app/Contents/MacOS/Unity" >> $GITHUB_ENV
57+
58+
# Build .unitypackage
59+
- run: ./gradlew buildPlugin --info
60+
61+
# Build .tgz
62+
- run: ./gradlew buildUpmPlugin --info
63+
64+
- name: Return Unity license
65+
if: always()
66+
uses: firebase/firebase-unity-sdk/gha/unity@main
67+
with:
68+
version: ${{ inputs.unity_version }}
69+
release_license: "true"
70+
71+
- name: Check build files
72+
shell: bash
73+
run: |
74+
if [ -f build/external-dependency-manager.unitypackage ]; then
75+
echo "external-dependency-manager.unitypackage zip created."
76+
else
77+
echo "Fail to create external-dependency-manager.unitypackage."
78+
exit 1
79+
fi
80+
if ls build/com.google.external-dependency-manager*.tgz 1> /dev/null 2>&1; then
81+
echo "com.google.external-dependency-manager.tgz created."
82+
else
83+
echo "Fail to create com.google.external-dependency-manager.tgz ."
84+
exit 1
85+
fi
86+
87+
- name: Upload build results artifact
88+
uses: actions/upload-artifact@v3
89+
if: ${{ !cancelled() }}
90+
with:
91+
name: ${{ env.assetPackageArtifactName }}
92+
path: build/external-dependency-manager.unitypackage
93+
retention-days: ${{ env.artifactRetentionDays }}
94+
95+
- name: Upload build results artifact
96+
uses: actions/upload-artifact@v3
97+
if: ${{ !cancelled() }}
98+
with:
99+
name: ${{ env.tarballPackageArtifactName }}
100+
path: build/com.google.external-dependency-manager-*.tgz
101+
retention-days: ${{ env.artifactRetentionDays }}

gha/build_setup/action.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Reusable cross-platform workflow to setup for the build environment.
16+
# * Install Python and required Python packages
17+
# * Install Unity, platform build support, and register license if
18+
# username, password and serial id are provided
19+
name: 'Build Setup'
20+
21+
inputs:
22+
unity_version:
23+
required: true
24+
platform:
25+
description: 'Platform to install Unity on (Windows,macOS,Linux)'
26+
type: choice
27+
options:
28+
- Windows
29+
- macOS
30+
- Linux
31+
required: true
32+
unity_username:
33+
required: false
34+
unity_password:
35+
required: false
36+
unity_serial_id:
37+
required: false
38+
python_version:
39+
required: true
40+
41+
runs:
42+
using: 'composite'
43+
steps:
44+
# Download GHA tools and requirements from Firebase Unity SDK repo
45+
- uses: actions/checkout@v3
46+
with:
47+
repository: firebase/firebase-unity-sdk
48+
path: external/firebase-unity-sdk
49+
sparse-checkout: |
50+
scripts/gha/requirements.txt
51+
sparse-checkout-cone-mode: false
52+
53+
- name: Setup python
54+
uses: actions/setup-python@v4
55+
with:
56+
python-version: ${{ inputs.python_version }}
57+
58+
- name: Install python deps
59+
shell: bash
60+
run: |
61+
pip install -r ./external/firebase-unity-sdk/scripts/gha/requirements.txt
62+
63+
- name: Install Unity and get a license
64+
uses: firebase/firebase-unity-sdk/gha/unity@main
65+
with:
66+
version: ${{ inputs.unity_version }}
67+
# iOS build support is always required to build EDM4U
68+
platforms: "${{ inputs.platform }},iOS"
69+
username: ${{ inputs.unity_username }}
70+
password: ${{ inputs.unity_password }}
71+
serial_ids: ${{ inputs.unity_serial_id }}
72+

0 commit comments

Comments
 (0)