Skip to content

Commit 9342b48

Browse files
unity-xcode-builder@v1.3.4 (#24)
- updated xcode version handling - refactored action to be more robust and reliable
1 parent 9716df2 commit 9342b48

File tree

11 files changed

+1566
-1242
lines changed

11 files changed

+1566
-1242
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"os": [
3+
"macos-latest"
4+
],
5+
"unity-version": [
6+
"2021.x",
7+
"2022.x",
8+
"6000.0.x",
9+
"6000.1.x",
10+
"6000.2.x"
11+
],
12+
"build-target": [
13+
"StandaloneOSX",
14+
"iOS",
15+
"VisionOS"
16+
],
17+
"xcode-version": [
18+
"16.3",
19+
"16.4"
20+
],
21+
"exclude": [
22+
{
23+
"unity-version": "2021.x",
24+
"build-target": "VisionOS"
25+
},
26+
{
27+
"unity-version": "2022.x",
28+
"build-target": "VisionOS"
29+
}
30+
]
31+
}

.github/workflows/build.yml

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
name: build
2+
permissions:
3+
contents: read
4+
on:
5+
workflow_call:
6+
inputs:
7+
matrix:
8+
required: true
9+
type: string
10+
secrets:
11+
UNITY_USERNAME:
12+
required: true
13+
UNITY_PASSWORD:
14+
required: true
15+
jobs:
16+
build:
17+
name: ${{ matrix.name }}
18+
strategy:
19+
matrix: ${{ fromJSON(inputs.matrix) }}
20+
fail-fast: false
21+
runs-on: ${{ matrix.os }}
22+
permissions:
23+
contents: read
24+
env:
25+
VERSION: ''
26+
EXPORT_OPTION: ''
27+
BUILD_DIRECTORY: ''
28+
UNITY_PROJECT_PATH: ${{ github.workspace }}/UnityProject
29+
steps:
30+
- uses: actions/checkout@v4
31+
- run: 'npm install -g openupm-cli'
32+
- uses: buildalon/unity-setup@v1
33+
with:
34+
version-file: 'None'
35+
build-targets: ${{ matrix.build-target }}
36+
unity-version: ${{ matrix.unity-version }}
37+
- name: Set Build Args
38+
shell: bash
39+
run: |
40+
set -e
41+
# Read version from package.json instead of git tags
42+
package_json_path="${{ github.workspace }}/package.json"
43+
version=$(jq -r .version "$package_json_path")
44+
45+
if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
46+
echo "Version from package.json: $version"
47+
else
48+
echo "Version: $version is not a valid version string"
49+
exit 1
50+
fi
51+
echo "VERSION=$version" >> "$GITHUB_ENV"
52+
53+
# Only set export option to app-store-connect if unity-version is 6000.2.x AND xcode-version is 16.4
54+
if [[ "${{ matrix.unity-version }}" == "6000.2.x" && "${{ matrix.xcode-version }}" == "16.2" ]]; then
55+
echo "EXPORT_OPTION=app-store-connect" >> "$GITHUB_ENV"
56+
else
57+
if [[ "${{ matrix.build-target }}" == "StandaloneOSX" ]]; then
58+
if [[ "${{ matrix.unity-version }}" == "2022.x" ]]; then
59+
echo "EXPORT_OPTION=steam" >> "$GITHUB_ENV"
60+
else
61+
echo "EXPORT_OPTION=developer-id" >> "$GITHUB_ENV"
62+
fi
63+
else
64+
echo "EXPORT_OPTION=development" >> "$GITHUB_ENV"
65+
fi
66+
fi
67+
68+
# set BUILD_DIRECTORY to a path in the root of the workspace named ./Builds/<build-target>/
69+
build_directory="${{ github.workspace }}/Builds/${{ matrix.build-target }}"
70+
echo "Creating build directory at $build_directory"
71+
mkdir -p "$build_directory"
72+
echo "BUILD_DIRECTORY=$build_directory" >> "$GITHUB_ENV"
73+
- uses: buildalon/activate-unity-license@v1
74+
with:
75+
license: 'Personal'
76+
username: ${{ secrets.UNITY_USERNAME }}
77+
password: ${{ secrets.UNITY_PASSWORD }}
78+
- uses: buildalon/create-unity-project@v1
79+
name: Create Test Project
80+
with:
81+
project-name: UnityProject
82+
template-name: com.unity.template.3d(-cross-platform)?
83+
- run: openupm add com.virtualmaker.buildalon
84+
name: Add Build Pipeline Package
85+
working-directory: ${{ env.UNITY_PROJECT_PATH }}
86+
- uses: buildalon/unity-action@v1
87+
name: '${{ matrix.build-target }}-Validate'
88+
with:
89+
build-target: ${{ matrix.build-target }}
90+
log-name: '${{ matrix.build-target }}-Validate'
91+
args: '-quit -nographics -batchmode -executeMethod Buildalon.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject -importTMProEssentialsAsset'
92+
- uses: buildalon/unity-action@v1
93+
name: '${{ matrix.build-target }}-Build'
94+
with:
95+
build-target: ${{ matrix.build-target }}
96+
log-name: '${{ matrix.build-target }}-Build'
97+
args: '-quit -nographics -batchmode -executeMethod Buildalon.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild -sceneList Assets/Scenes/SampleScene.unity -export -enableAppleAutomaticSigning -bundleIdentifier com.test.buildalon.xcode -versionName ${{ env.VERSION }} -buildOutputDirectory ${{ env.BUILD_DIRECTORY }}'
98+
- name: Update Info.Plist with encryption compliance
99+
shell: bash
100+
run: |
101+
set -e
102+
BUILD_DIRECTORY="${{ env.BUILD_DIRECTORY }}"
103+
104+
if [ -z "$BUILD_DIRECTORY" ]; then
105+
echo "env.BUILD_DIRECTORY is not set!"
106+
exit 1
107+
fi
108+
109+
# recursively list build output files
110+
echo "::group::Build Output Directory: ${BUILD_DIRECTORY}/com.test.buildalon.xcode"
111+
ls -alR "${BUILD_DIRECTORY}/com.test.buildalon.xcode"
112+
echo "::endgroup::"
113+
114+
# find the Info.plist file in the build directory
115+
# MacOSStandalone Info.plist path: /Users/runner/work/unity-xcode-builder/unity-xcode-builder/UnityProject/Builds/StandaloneOSX/com.test.buildalon.xcode/UnityProject/UnityProject/Info.plist
116+
# all others: /Users/runner/work/unity-xcode-builder/unity-xcode-builder/UnityProject/Builds/iOS/com.test.buildalon.xcode/Info.plist
117+
EXPORT_OPTION="${{ env.EXPORT_OPTION }}"
118+
119+
if [ "$EXPORT_OPTION" != "app-store-connect" ]; then
120+
exit 0
121+
fi
122+
123+
TARGET_PLATFORM="${{ matrix.build-target }}"
124+
125+
INFO_PLIST_PATH="${BUILD_DIRECTORY}/com.test.buildalon.xcode/UnityProject/UnityProject/Info.plist"
126+
127+
if [ ! -f "$INFO_PLIST_PATH" ]; then
128+
INFO_PLIST_PATH="${BUILD_DIRECTORY}/com.test.buildalon.xcode/Info.plist"
129+
fi
130+
131+
# test path exists
132+
if [ ! -f "$INFO_PLIST_PATH" ]; then
133+
echo "Info.plist not found at path: $INFO_PLIST_PATH"
134+
exit 1
135+
fi
136+
137+
# make sure plist buddy is installed
138+
if ! command -v /usr/libexec/PlistBuddy &> /dev/null
139+
then
140+
echo "PlistBuddy could not be found"
141+
# list build output files recursively
142+
ls -alR "${BUILD_DIRECTORY}/com.test.buildalon.xcode"
143+
exit 1
144+
fi
145+
146+
# set ITSAppUsesNonExemptEncryption to false in Info.plist using PlistBuddy
147+
/usr/libexec/PlistBuddy -c "Add :ITSAppUsesNonExemptEncryption bool false" "$INFO_PLIST_PATH"
148+
- uses: ./ # buildalon/unity-xcode-builder
149+
id: xcode-build
150+
with:
151+
xcode-version: ${{ matrix.xcode-version }}
152+
project-path: ${{ env.BUILD_DIRECTORY }}/**/*.xcodeproj
153+
app-store-connect-key: ${{ secrets.APP_STORE_CONNECT_KEY }}
154+
app-store-connect-key-id: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
155+
app-store-connect-issuer-id: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
156+
team-id: ${{ secrets.APPLE_TEAM_ID }}
157+
export-option: ${{ env.EXPORT_OPTION }}
158+
notarize: ${{ env.EXPORT_OPTION != 'app-store-connect' }}
159+
archive-type: pkg
160+
test-groups: Beta
161+
developer-id-application-certificate: ${{ secrets.DEVELOPER_ID_APPLICATION_CERT }}
162+
developer-id-application-certificate-password: ${{ secrets.SIGNING_CERT_PASSWORD }}
163+
developer-id-installer-certificate: ${{ secrets.DEVELOPER_ID_INSTALLER_CERT }}
164+
developer-id-installer-certificate-password: ${{ secrets.SIGNING_CERT_PASSWORD }}
165+
- name: print outputs
166+
run: |
167+
set -e
168+
169+
EXECUTABLE="${{ steps.xcode-build.outputs.executable }}"
170+
171+
if [ -z "${EXECUTABLE}" ]; then
172+
echo "No executable found in outputs"
173+
exit 1
174+
fi
175+
176+
echo "Executable: ${EXECUTABLE}"
177+
OUTPUT_DIRECTORY="${{ steps.xcode-build.outputs.output-directory }}"
178+
179+
if [ -z "${OUTPUT_DIRECTORY}" ]; then
180+
echo "No output directory found in outputs"
181+
exit 1
182+
fi
183+
184+
echo "::group::Output Directory: ${OUTPUT_DIRECTORY}"
185+
ls -R "${OUTPUT_DIRECTORY}"
186+
echo "::endgroup::"

.github/workflows/validate.yml

Lines changed: 24 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -5,154 +5,38 @@ on:
55
pull_request:
66
types: [opened, reopened, synchronize, ready_for_review]
77
branches: ['*']
8-
# Allows you to run this workflow manually from the Actions tab
9-
workflow_dispatch:
8+
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
109
concurrency:
1110
group: ${{ github.workflow }}-${{ github.ref }}
1211
cancel-in-progress: true
1312
jobs:
14-
unity-build:
13+
setup:
1514
if: github.event.pull_request.draft == false
16-
name: '(${{ matrix.unity-version }}) ${{ matrix.build-target }}'
15+
runs-on: ubuntu-latest
1716
permissions:
1817
contents: read
19-
env:
20-
VERSION: ''
21-
TEMPLATE_PATH: ''
22-
EXPORT_OPTION: ''
23-
UNITY_PROJECT_PATH: ''
24-
runs-on: ${{ matrix.os }}
25-
strategy:
26-
fail-fast: false
27-
matrix:
28-
os: [macos-latest]
29-
unity-version: [2021.x, 2022.x, 6000.x]
30-
build-target:
31-
- iOS
32-
- StandaloneOSX
33-
- VisionOS
34-
exclude:
35-
- os: macos-latest
36-
unity-version: 2021.x
37-
build-target: VisionOS
38-
- os: macos-latest
39-
unity-version: 2022.x
40-
build-target: VisionOS
4118
steps:
4219
- uses: actions/checkout@v4
43-
- run: 'npm install -g openupm-cli'
44-
- uses: buildalon/unity-setup@v1
45-
with:
46-
version-file: 'None'
47-
build-targets: ${{ matrix.build-target }}
48-
unity-version: ${{ matrix.unity-version }}
49-
- name: Find Unity Template Path and Version
50-
run: |
51-
$rootPath = $env:UNITY_EDITOR_PATH -replace "Editor.*", ""
52-
Write-Host "ROOT_PATH=$rootPath"
53-
$templatePath = Get-ChildItem -Recurse -Filter "com.unity.template.3d*.tgz" -Path $rootPath | Select-Object -First 1 | Select-Object -ExpandProperty FullName
54-
Write-Host "TEMPLATE_PATH=$templatePath"
55-
echo "TEMPLATE_PATH=$templatePath" >> $env:GITHUB_ENV
56-
$projectPath = "${{ github.workspace }}/UnityProject"
57-
echo "UNITY_PROJECT_PATH=$projectPath" >> $env:GITHUB_ENV
58-
59-
# Read version from package.json instead of git tags
60-
$packageJsonPath = "${{ github.workspace }}/package.json"
61-
$packageJson = Get-Content -Raw -Path $packageJsonPath | ConvertFrom-Json
62-
$version = $packageJson.version
63-
64-
if ($version -match '^\d+\.\d+\.\d+$') {
65-
Write-Host "Version from package.json: $version"
66-
} else {
67-
Write-Host "Version: $version is not a valid version string"
68-
exit 1
69-
}
70-
echo "VERSION=$version" >> $env:GITHUB_ENV
71-
72-
# if the unity-version is 6000.x then set export option to app-store-connect otherwise set it to development
73-
if ('${{ matrix.unity-version }}' -eq '6000.x') {
74-
echo "EXPORT_OPTION=app-store-connect" >> $env:GITHUB_ENV
75-
} else {
76-
if ('${{ matrix.build-target }}' -eq 'StandaloneOSX') {
77-
if ('${{ matrix.unity-version }}' -eq '2022.x') {
78-
echo "EXPORT_OPTION=steam" >> $env:GITHUB_ENV
79-
} else {
80-
echo "EXPORT_OPTION=developer-id" >> $env:GITHUB_ENV
81-
}
82-
} else {
83-
echo "EXPORT_OPTION=development" >> $env:GITHUB_ENV
84-
}
85-
}
86-
shell: pwsh
87-
- uses: buildalon/activate-unity-license@v1
88-
with:
89-
license: 'Personal'
90-
username: ${{ secrets.UNITY_USERNAME }}
91-
password: ${{ secrets.UNITY_PASSWORD }}
92-
- uses: buildalon/unity-action@v1
93-
name: Create Test Project
94-
with:
95-
log-name: 'create-test-project'
96-
args: '-quit -nographics -batchmode -createProject "${{ github.workspace }}/UnityProject" -cloneFromTemplate "${{ env.TEMPLATE_PATH }}"'
97-
- run: openupm add com.virtualmaker.buildalon
98-
name: Add Build Pipeline Package
99-
working-directory: ${{ github.workspace }}/UnityProject
100-
- uses: buildalon/unity-action@v1
101-
name: '${{ matrix.build-target }}-Validate'
10220
with:
103-
build-target: ${{ matrix.build-target }}
104-
log-name: '${{ matrix.build-target }}-Validate'
105-
args: '-quit -nographics -batchmode -executeMethod Buildalon.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject -importTMProEssentialsAsset'
106-
- uses: buildalon/unity-action@v1
107-
name: '${{ matrix.build-target }}-Build'
21+
sparse-checkout: .github/
22+
- uses: RageAgainstThePixel/job-builder@v1
23+
id: setup-jobs
10824
with:
109-
build-target: ${{ matrix.build-target }}
110-
log-name: '${{ matrix.build-target }}-Build'
111-
args: '-quit -nographics -batchmode -executeMethod Buildalon.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild -sceneList Assets/Scenes/SampleScene.unity -export -enableAppleAutomaticSigning -bundleIdentifier com.test.buildalon.xcode -versionName ${{ env.VERSION }}'
112-
- name: Update Info.Plist with encryption compliance
113-
shell: bash
114-
run: |
115-
set -xe
116-
# find the Info.plist file in the build directory
117-
# MacOSStandalone Info.plist path: /Users/runner/work/unity-xcode-builder/unity-xcode-builder/UnityProject/Builds/StandaloneOSX/com.test.buildalon.xcode/UnityProject/UnityProject/Info.plist
118-
# all others: /Users/runner/work/unity-xcode-builder/unity-xcode-builder/UnityProject/Builds/iOS/com.test.buildalon.xcode/Info.plist
119-
EXPORT_OPTION=${{ env.EXPORT_OPTION }}
120-
if [ "$EXPORT_OPTION" != "app-store-connect" ]; then
121-
exit 0
122-
fi
123-
TARGET_PLATFORM=${{ matrix.build-target }}
124-
if [ "$TARGET_PLATFORM" == "StandaloneOSX" ]; then
125-
INFO_PLIST_PATH="${{ env.UNITY_PROJECT_PATH }}/Builds/${{ matrix.build-target }}/com.test.buildalon.xcode/UnityProject/UnityProject/Info.plist"
126-
else
127-
INFO_PLIST_PATH="${{ env.UNITY_PROJECT_PATH }}/Builds/${{ matrix.build-target }}/com.test.buildalon.xcode/Info.plist"
128-
fi
129-
# make sure plist buddy is installed
130-
if ! command -v /usr/libexec/PlistBuddy &> /dev/null
131-
then
132-
echo "PlistBuddy could not be found"
133-
exit 1
134-
fi
135-
# set ITSAppUsesNonExemptEncryption to false in Info.plist using PlistBuddy
136-
/usr/libexec/PlistBuddy -c "Add :ITSAppUsesNonExemptEncryption bool false" "$INFO_PLIST_PATH"
137-
- uses: ./ # buildalon/unity-xcode-builder
138-
id: xcode-build
139-
with:
140-
project-path: ${{ env.UNITY_PROJECT_PATH }}/Builds/${{ matrix.build-target }}/**/*.xcodeproj
141-
app-store-connect-key: ${{ secrets.APP_STORE_CONNECT_KEY }}
142-
app-store-connect-key-id: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
143-
app-store-connect-issuer-id: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
144-
team-id: ${{ secrets.APPLE_TEAM_ID }}
145-
export-option: ${{ env.EXPORT_OPTION }}
146-
notarize: ${{ matrix.unity-version != '6000.x' }}
147-
archive-type: pkg
148-
test-groups: Beta
149-
developer-id-application-certificate: ${{ secrets.DEVELOPER_ID_APPLICATION_CERT }}
150-
developer-id-application-certificate-password: ${{ secrets.SIGNING_CERT_PASSWORD }}
151-
developer-id-installer-certificate: ${{ secrets.DEVELOPER_ID_INSTALLER_CERT }}
152-
developer-id-installer-certificate-password: ${{ secrets.SIGNING_CERT_PASSWORD }}
153-
- name: print outputs
154-
if: always()
155-
run: |
156-
echo "Executable: ${{ steps.xcode-build.outputs.executable }}"
157-
echo "Output Directory: ${{ steps.xcode-build.outputs.output-directory }}"
158-
ls -R "${{ steps.xcode-build.outputs.output-directory }}"
25+
build-options: ./.github/workflows/build-options.json
26+
group-by: 'unity-version'
27+
outputs:
28+
jobs: ${{ steps.setup-jobs.outputs.jobs }}
29+
validate:
30+
if: ${{ needs.setup.outputs.jobs }}
31+
needs: setup
32+
name: build ${{ matrix.jobs.name }}
33+
permissions:
34+
contents: read
35+
strategy:
36+
matrix: ${{ fromJSON(needs.setup.outputs.jobs) }}
37+
fail-fast: false
38+
max-parallel: 1
39+
secrets: inherit
40+
uses: ./.github/workflows/build.yml
41+
with:
42+
matrix: ${{ toJSON(matrix.jobs.matrix) }}

0 commit comments

Comments
 (0)