-
Notifications
You must be signed in to change notification settings - Fork 0
204 lines (190 loc) · 8.9 KB
/
Copy pathbuild.yml
File metadata and controls
204 lines (190 loc) · 8.9 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
195
196
197
198
199
200
201
202
203
204
name: build
permissions:
contents: read
on:
workflow_call:
inputs:
matrix:
required: true
type: string
secrets:
UNITY_USERNAME:
required: true
UNITY_PASSWORD:
required: true
jobs:
build:
name: ${{ matrix.name }}
strategy:
matrix: ${{ fromJSON(inputs.matrix) }}
fail-fast: false
runs-on: ${{ matrix.os }}
permissions:
contents: read
env:
BUILD_OUTPUT_PATH: ${{ github.workspace }}/Builds/${{ matrix.build-target }}
TEMPLATE_PATH: ''
UNITY_PROJECT_PATH: '' # set by unity-setup action
steps:
- uses: actions/checkout@v4
- run: 'npm install -g openupm-cli'
- uses: buildalon/unity-setup@v1
with:
version-file: 'None'
build-targets: ${{ matrix.build-target }}
unity-version: ${{ matrix.unity-version }}
- name: Find Unity Template Path
run: |
$rootPath = $env:UNITY_EDITOR_PATH -replace "Editor.*", ""
Write-Host "ROOT_PATH=$rootPath"
$templatePath = Get-ChildItem -Recurse -Filter "com.unity.template.3d*.tgz" -Path $rootPath | Select-Object -First 1 | Select-Object -ExpandProperty FullName
Write-Host "TEMPLATE_PATH=$templatePath"
echo "TEMPLATE_PATH=$templatePath" >> $env:GITHUB_ENV
$projectPath = "${{ github.workspace }}/Test Project"
echo "UNITY_PROJECT_PATH=$projectPath" >> $env:GITHUB_ENV
shell: pwsh
- uses: buildalon/activate-unity-license@v1
with:
license: 'Personal'
username: ${{ secrets.UNITY_USERNAME }}
password: ${{ secrets.UNITY_PASSWORD }}
- uses: buildalon/unity-action@v1
name: Create Test Project
with:
log-name: 'create-test-project'
args: '-quit -nographics -batchmode -createProject "${{ env.UNITY_PROJECT_PATH }}" -cloneFromTemplate "${{ env.TEMPLATE_PATH }}"'
- run: 'openupm add com.virtualmaker.buildalon'
name: Add Build Pipeline Package
working-directory: ${{ env.UNITY_PROJECT_PATH }}
- uses: buildalon/unity-action@v1
name: '${{ matrix.build-target }}-Validate'
with:
build-target: ${{ matrix.build-target }}
log-name: '${{ matrix.build-target }}-Validate'
args: '-quit -nographics -batchmode -executeMethod Buildalon.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject -importTMProEssentialsAsset'
- uses: buildalon/unity-action@v1
name: '${{ matrix.build-target }}-Build'
with:
build-target: ${{ matrix.build-target }}
log-name: '${{ matrix.build-target }}-Build'
args: '-quit -nographics -batchmode -executeMethod Buildalon.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild -buildOutputDirectory ${{ env.BUILD_OUTPUT_PATH }} -sceneList Assets/Scenes/SampleScene.unity -arch ${{ matrix.uwp-arch }} -wsaSubtarget ${{ matrix.uwp-subtarget }} -wsaUWPSDK ${{ matrix.windows-sdk-version }}'
- name: Enumerate Build Directory
shell: bash
run: |
if [ -z "${{ env.BUILD_OUTPUT_PATH }}" ]; then
echo "::error::Failed to find build output path!"
exit 1
fi
if [ ! -d "${{ env.BUILD_OUTPUT_PATH }}" ]; then
echo "::error::Build output directory does not exist: ${{ env.BUILD_OUTPUT_PATH }}"
exit 1
fi
echo "::group::Build Artifacts"
ls -R "${{ env.BUILD_OUTPUT_PATH }}"
echo "::endgroup::"
- uses: microsoft/setup-msbuild@v2
with:
vs-version: '[15.0, )'
- name: Create Test Certificate
if: matrix.certificate-type == 'custom'
shell: pwsh
run: |
$certPath = "${{ github.workspace }}/TestCert.pfx"
$certPassword = "TestPassword123"
# Create a self-signed certificate for testing
$cert = New-SelfSignedCertificate -Type Custom -Subject "CN=TestPublisher" -KeyUsage DigitalSignature -FriendlyName "Test UWP Certificate" -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")
# Export the certificate to a PFX file
$pwd = ConvertTo-SecureString -String $certPassword -Force -AsPlainText
Export-PfxCertificate -cert "Cert:\CurrentUser\My\$($cert.Thumbprint)" -FilePath $certPath -Password $pwd
# Import the certificate into Trusted Root Certification Authorities so it is trusted for validation
Import-PfxCertificate -FilePath $certPath -CertStoreLocation "Cert:\LocalMachine\Root" -Password $pwd | Out-Null
Write-Host "Test certificate imported to Trusted Root Certification Authorities."
Write-Host "Test certificate created at: $certPath"
- uses: ./ # buildalon/unity-uwp-builder
id: uwp-build
with:
platform: ${{ matrix.uwp-arch }}
project-path: ${{ env.BUILD_OUTPUT_PATH }}
package-type: ${{ matrix.uwp-package-type }}
certificate-path: ${{ matrix.certificate-type == 'custom' && format('{0}/TestCert.pfx', github.workspace) || '' }}
certificate-password: ${{ matrix.certificate-type == 'custom' && 'TestPassword123' || '' }}
windows-sdk-version: ${{ matrix.windows-sdk-version }}
- name: Validate Outputs
shell: bash
run: |
set -e
OUTPUT_DIR="${{ steps.uwp-build.outputs.output-directory }}"
if [ -z "${OUTPUT_DIR}" ]; then
echo "❌ No output directory found at ${OUTPUT_DIR}"
else
echo "✅ Output Directory: ${OUTPUT_DIR}"
fi
ls -R "${OUTPUT_DIR}"
- name: Validate Certificate Usage
if: matrix.certificate-type == 'custom' && matrix.uwp-package-type == 'sideload'
shell: pwsh
run: |
$output_dir="${{ steps.uwp-build.outputs.output-directory }}"
if (-not (Test-Path $output_dir)) {
Write-Host "❌ Output directory does not exist: $output_dir"
exit 1
}
# get .appx, .appxbundle, .appxupload, .msix, .msixbundle, .msixupload files
$bundles = Get-ChildItem -Path $output_dir -Recurse -Include *.appx, *.appxbundle, *.appxupload, *.msix, *.msixbundle, *.msixupload | Select-Object -ExpandProperty FullName
if ($bundles.Count -eq 0) {
Write-Host "❌ No bundles found in output directory: $output_dir"
exit 1
}
$allValid = $true
foreach ($bundle in $bundles) {
# Skip Microsoft dependency packages
if ($bundle -match "Microsoft\.VCLibs\..*\.appx$") {
Write-Host "⏭️ Skipping Microsoft dependency package: $bundle"
continue
}
Write-Host "::group::🔍 Validating certificate for bundle: $bundle"
if (-not (Test-Path $bundle)) {
Write-Host "❌ Bundle not found: $bundle"
Write-Host "::endgroup::"
$allValid = $false
continue
}
$signature = Get-AuthenticodeSignature -FilePath $bundle
if ($signature.Status -eq "Valid") {
Write-Host "✅ Bundle is properly signed"
Write-Host "📜 Certificate Subject: $($signature.SignerCertificate.Subject)"
Write-Host "👤 Certificate Issuer: $($signature.SignerCertificate.Issuer)"
Write-Host "📅 Certificate Valid From: $($signature.SignerCertificate.NotBefore)"
Write-Host "📅 Certificate Valid To: $($signature.SignerCertificate.NotAfter)"
Write-Host "🔑 Certificate Thumbprint: $($signature.SignerCertificate.Thumbprint)"
if ($signature.SignerCertificate.Subject -like "*TestPublisher*") {
Write-Host "✅✅ Confirmed: Custom test certificate was used successfully!"
} else {
Write-Host "❌ Warning: Certificate subject doesn't match expected test certificate"
$allValid = $false
}
} elseif ($signature.Status -eq "NotSigned") {
Write-Host "❌ Bundle is not signed"
$allValid = $false
} else {
Write-Host "❌ Bundle signature status: $($signature.Status)"
$allValid = $false
}
Write-Host "📝 Signature details: $($signature.StatusMessage)"
Write-Host "::endgroup::"
}
if (-not $allValid) {
Write-Host "❌ One or more bundles failed certificate validation."
exit 1
} else {
Write-Host "✅ All bundles passed certificate validation."
}
- uses: actions/upload-artifact@v4
if: always() || cancelled()
with:
retention-days: 1
overwrite: true
name: ${{ matrix.unity-version }} ${{ matrix.name }}
path: |
${{ github.workspace }}/**/*.log
${{ env.BUILD_OUTPUT_PATH }}