@@ -9,170 +9,24 @@ concurrency:
99 group : ${{ github.workflow }}-${{ github.ref }}
1010 cancel-in-progress : true
1111jobs :
12+ setup :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - uses : actions/checkout@v4
16+ with :
17+ sparse-checkout : .github/
18+ - name : Setup Jobs
19+ id : setup-jobs
20+ shell : bash
21+ run : ./.github/workflows/scripts/setup-matrix.sh
22+ outputs :
23+ jobs : ${{ steps.setup-jobs.outputs.jobs }}
1224 unity-build :
13- name : ' (${{ matrix.unity-version }}) ${{ matrix.build-target }} - ${{ matrix.uwp-package-type }} - ${{ matrix.certificate-type }}'
14- env :
15- TEMPLATE_PATH : ' '
16- UNITY_PROJECT_PATH : ' ' # set by unity-setup action
25+ needs : setup
26+ name : ' (${{ matrix.unity-version }}) ${{ matrix.uwp-arch }} ${{ matrix.uwp-subtarget }} ${{ matrix.uwp-package-type }} ${{ matrix.uwp-package-format }} ${{ matrix.certificate-type }}'
1727 runs-on : ${{ matrix.os }}
1828 permissions :
1929 contents : read
2030 strategy :
2131 fail-fast : false
22- matrix :
23- os : [windows-latest]
24- build-target : [WSAPlayer]
25- unity-version : [2021.x, 2022.x, 6000.x]
26- uwp-arch : [x64, ARM64]
27- uwp-subtarget : [PC, HoloLens]
28- uwp-package-type : [sideload, upload]
29- uwp-package-format : [appx, msix]
30- certificate-type : [default, custom]
31- exclude :
32- # Only test custom certificates with sideload package type
33- # Upload packages don't use certificates in the same way
34- - uwp-package-type : upload
35- certificate-type : custom
36- steps :
37- - uses : actions/checkout@v4
38- - run : ' npm install -g openupm-cli'
39- # Installs the Unity Editor based on your project version text file
40- # sets -> env.UNITY_EDITOR_PATH
41- # sets -> env.UNITY_PROJECT_PATH
42- - uses : buildalon/unity-setup@v1
43- with :
44- version-file : ' None'
45- build-targets : ${{ matrix.build-target }}
46- unity-version : ${{ matrix.unity-version }}
47- - name : Find Unity Template Path
48- run : |
49- $rootPath = $env:UNITY_EDITOR_PATH -replace "Editor.*", ""
50- Write-Host "ROOT_PATH=$rootPath"
51- $templatePath = Get-ChildItem -Recurse -Filter "com.unity.template.3d*.tgz" -Path $rootPath | Select-Object -First 1 | Select-Object -ExpandProperty FullName
52- Write-Host "TEMPLATE_PATH=$templatePath"
53- echo "TEMPLATE_PATH=$templatePath" >> $env:GITHUB_ENV
54- $projectPath = "${{ github.workspace }}/Test Project"
55- echo "UNITY_PROJECT_PATH=$projectPath" >> $env:GITHUB_ENV
56- shell : pwsh
57- # Activates the installation with the provided credentials
58- - uses : buildalon/activate-unity-license@v1
59- with :
60- license : ' Personal'
61- username : ${{ secrets.UNITY_USERNAME }}
62- password : ${{ secrets.UNITY_PASSWORD }}
63- - uses : buildalon/unity-action@v1
64- name : Create Test Project
65- with :
66- log-name : ' create-test-project'
67- args : ' -quit -nographics -batchmode -createProject "${{ env.UNITY_PROJECT_PATH }}" -cloneFromTemplate "${{ env.TEMPLATE_PATH }}"'
68- - run : ' openupm add com.virtualmaker.buildalon'
69- name : Add Build Pipeline Package
70- working-directory : ${{ env.UNITY_PROJECT_PATH }}
71- - uses : buildalon/unity-action@v1
72- name : ' ${{ matrix.build-target }}-Validate'
73- with :
74- build-target : ${{ matrix.build-target }}
75- log-name : ' ${{ matrix.build-target }}-Validate'
76- args : ' -quit -nographics -batchmode -executeMethod Buildalon.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject -importTMProEssentialsAsset'
77- - uses : buildalon/unity-action@v1
78- name : ' ${{ matrix.build-target }}-Build'
79- with :
80- build-target : ${{ matrix.build-target }}
81- log-name : ' ${{ matrix.build-target }}-Build'
82- args : ' -quit -nographics -batchmode -executeMethod Buildalon.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild -sceneList Assets/Scenes/SampleScene.unity -arch ${{ matrix.uwp-arch }} -wsaSubtarget ${{ matrix.uwp-subtarget }} -wsaUWPSDK 10.0.22621.0'
83- - uses : microsoft/setup-msbuild@v2
84- with :
85- vs-version : ' [15.0, )'
86- # Create a test certificate for custom certificate testing
87- - name : Create Test Certificate
88- if : matrix.certificate-type == 'custom'
89- run : |
90- $certPath = "${{ github.workspace }}/TestCert.pfx"
91- $certPassword = "TestPassword123"
92-
93- # Create a self-signed certificate for testing
94- $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}")
95-
96- # Export the certificate to a PFX file
97- $pwd = ConvertTo-SecureString -String $certPassword -Force -AsPlainText
98- Export-PfxCertificate -cert "Cert:\CurrentUser\My\$($cert.Thumbprint)" -FilePath $certPath -Password $pwd
99-
100- Write-Host "Test certificate created at: $certPath"
101- shell : pwsh
102- # builds visual studio project for UWP and packages it as an appx
103- - uses : ./ # buildalon/unity-uwp-builder
104- id : uwp-build
105- with :
106- architecture : ${{ matrix.uwp-arch }}
107- project-path : ${{ env.UNITY_PROJECT_PATH }}/Builds/WSAPlayer
108- package-type : ${{ matrix.uwp-package-type }}
109- certificate-path : ${{ matrix.certificate-type == 'custom' && format('{0}/TestCert.pfx', github.workspace) || '' }}
110- certificate-password : ${{ matrix.certificate-type == 'custom' && 'TestPassword123' || '' }}
111- windows-sdk-version : ' 10.0.22621.0'
112- - name : print outputs
113- shell : bash
114- run : |
115- EXECUTABLE="${{ steps.uwp-build.outputs.executable }}"
116- if [ -z "${EXECUTABLE}" ]; then
117- echo "No executable found."
118- else
119- echo "Executable: ${EXECUTABLE}"
120- fi
121- # verify the executable file extension based on the package format
122- OUTPUT_DIR="${{ steps.uwp-build.outputs.output-directory }}"
123- if [ -z "${OUTPUT_DIR}" ]; then
124- echo "No output directory found."
125- else
126- echo "Output Directory: ${OUTPUT_DIR}"
127- fi
128- ls -R "${OUTPUT_DIR}"
129- - name : Validate Certificate Usage
130- if : matrix.certificate-type == 'custom' && matrix.uwp-package-type == 'sideload'
131- shell : pwsh
132- run : |
133- $outputDir = "${{ steps.uwp-build.outputs.output-directory }}"
134- $packageFiles = Get-ChildItem -Path $outputDir -Filter "*.appx" -Recurse
135- $packageFiles += Get-ChildItem -Path $outputDir -Filter "*.msix" -Recurse
136-
137- if ($packageFiles.Count -eq 0) {
138- Write-Host "❌ No package files found to validate certificate"
139- exit 1
140- }
141-
142- foreach ($package in $packageFiles) {
143- Write-Host "🔍 Validating certificate for package: $($package.Name)"
144-
145- # Use Get-AuthenticodeSignature to check the certificate
146- $signature = Get-AuthenticodeSignature -FilePath $package.FullName
147-
148- if ($signature.Status -eq "Valid") {
149- Write-Host "✅ Package is properly signed"
150- Write-Host "📜 Certificate Subject: $($signature.SignerCertificate.Subject)"
151- Write-Host "👤 Certificate Issuer: $($signature.SignerCertificate.Issuer)"
152- Write-Host "📅 Certificate Valid From: $($signature.SignerCertificate.NotBefore)"
153- Write-Host "📅 Certificate Valid To: $($signature.SignerCertificate.NotAfter)"
154- Write-Host "🔑 Certificate Thumbprint: $($signature.SignerCertificate.Thumbprint)"
155-
156- # Check if it's our test certificate
157- if ($signature.SignerCertificate.Subject -like "*TestPublisher*") {
158- Write-Host "✅ Confirmed: Custom test certificate was used successfully!"
159- } else {
160- Write-Host "❌ Warning: Certificate subject doesn't match expected test certificate"
161- exit 1
162- }
163- } elseif ($signature.Status -eq "NotSigned") {
164- Write-Host "❌ Package is not signed"
165- exit 1
166- } else {
167- Write-Host "❌ Package signature status: $($signature.Status)"
168- Write-Host "📝 Signature details: $($signature.StatusMessage)"
169- exit 1
170- }
171- }
172- - uses : actions/upload-artifact@v4
173- with :
174- retention-days : 1
175- name : ${{ github.run_number }}.${{ github.run_attempt }} ${{ matrix.unity-version }}-${{ matrix.build-target }}-${{ matrix.uwp-package-type }}-${{ matrix.certificate-type }}
176- path : |
177- ${{ github.workspace }}/**/*.log
178- ${{ steps.uwp-build.outputs.output-directory }}
32+ matrix : ${{ needs.setup.outputs.jobs && fromJSON(needs.setup.outputs.jobs) }}
0 commit comments