Skip to content

Commit d330004

Browse files
try something new
1 parent 15ebac7 commit d330004

File tree

3 files changed

+200
-161
lines changed

3 files changed

+200
-161
lines changed

.github/workflows/build.yml

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

.github/workflows/validate.yml

Lines changed: 15 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -9,170 +9,24 @@ concurrency:
99
group: ${{ github.workflow }}-${{ github.ref }}
1010
cancel-in-progress: true
1111
jobs:
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

Comments
 (0)