Skip to content

Commit b4d7b31

Browse files
committed
add action script and support build number
1 parent 2069c49 commit b4d7b31

File tree

4 files changed

+109
-158
lines changed

4 files changed

+109
-158
lines changed

.github/workflows/build.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: build packages
2+
#https://learn.microsoft.com/en-us/windows/apps/package-and-deploy/ci-for-winui3?pivots=winui3-packaged-csharp
3+
4+
on:
5+
workflow_dispatch:
6+
7+
env:
8+
BUILD_CONFIGURATION: Release
9+
10+
jobs:
11+
build:
12+
strategy:
13+
matrix:
14+
platform: [x64, ARM64]
15+
package: [CMC_GITHUB_RELEASE, CMC_DEV_RELEASE, CMC_ANY]
16+
17+
runs-on: windows-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
ref: dev
23+
24+
- name: Add MSBuild to PATH
25+
uses: microsoft/setup-msbuild@v2
26+
27+
- name: Decode Cert
28+
working-directory: ${{env.GITHUB_WORKSPACE}}
29+
run: |
30+
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
31+
$certificatePath = "${{github.workspace}}\GitHubActionsWorkflow.pfx"
32+
[IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte)
33+
34+
- name: Restore NuGet packages
35+
working-directory: ${{env.GITHUB_WORKSPACE}}
36+
run: nuget.exe restore ContextMenuCustom -SolutionDirectory ContextMenuCustom
37+
38+
- name: Restore NuGet packages
39+
working-directory: ${{env.GITHUB_WORKSPACE}}
40+
run: |
41+
msbuild -t:restore ContextMenuCustom\ContextMenuCustomApp\ContextMenuCustomApp.csproj
42+
43+
- name: Update Version Build Number
44+
working-directory: ${{env.GITHUB_WORKSPACE}}
45+
run: |
46+
$env:VERSION_BUILD_NUMBER = "${{github.run_number}}"
47+
.\update-version.ps1
48+
49+
- name: Build ContextMenuCustomHost
50+
working-directory: ${{env.GITHUB_WORKSPACE}}
51+
run: msbuild ContextMenuCustom\ContextMenuCustomHost\ContextMenuCustomHost.vcxproj /m /p:configuration="release" /p:SolutionDir=../ /p:platform="${{ matrix.platform }}" /p:packageType="${{ matrix.package }}"
52+
53+
- name: Build ContextMenuCustomGithubPackage
54+
if: matrix.package == 'CMC_GITHUB_RELEASE'
55+
working-directory: ${{env.GITHUB_WORKSPACE}}
56+
run: msbuild ContextMenuCustom\ContextMenuCustomGithubPackage\ContextMenuCustomGithubPackage.wapproj /m /p:configuration="release" /p:platform="${{ matrix.platform }}" /p:AppxBundlePlatforms="${{ matrix.platform }}" /p:UapAppxPackageBuildMode=SideloadOnly /p:PackageCertificateKeyFile="${{github.workspace}}\GitHubActionsWorkflow.pfx" /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} /p:AppxPackageDir="${{github.workspace}}\Packages\"
57+
58+
- name: Build ContextMenuCustomDevPackage
59+
if: matrix.package == 'CMC_DEV_RELEASE'
60+
working-directory: ${{env.GITHUB_WORKSPACE}}
61+
run: msbuild ContextMenuCustom\ContextMenuCustomDevPackage\ContextMenuCustomDevPackage.wapproj /m /p:configuration="release" /p:platform="${{ matrix.platform }}" /p:AppxBundlePlatforms="${{ matrix.platform }}" /p:UapAppxPackageBuildMode=SideloadOnly /p:PackageCertificateKeyFile="${{github.workspace}}\GitHubActionsWorkflow.pfx" /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} /p:AppxPackageDir="${{github.workspace}}\Packages\"
62+
63+
- name: Build ContextMenuCustomAnyPackage
64+
if: matrix.package == 'CMC_ANY'
65+
working-directory: ${{env.GITHUB_WORKSPACE}}
66+
run: msbuild ContextMenuCustom\ContextMenuCustomAnyPackage\ContextMenuCustomAnyPackage.wapproj /m /p:configuration="release" /p:platform="${{ matrix.platform }}" /p:AppxBundlePlatforms="${{ matrix.platform }}" /p:UapAppxPackageBuildMode=SideloadOnly /p:PackageCertificateKeyFile="${{github.workspace}}\GitHubActionsWorkflow.pfx" /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} /p:AppxPackageDir="${{github.workspace}}\Packages\"
67+
68+
- name: Remove Cert
69+
run: Remove-Item -path "${{github.workspace}}\GitHubActionsWorkflow.pfx"
70+
71+
- name: Upload Packages
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: ContextMenuCustom-${{ matrix.package }}-${{ matrix.platform }}
75+
path: |
76+
${{github.workspace}}\Packages\**\*.msixbundle
77+
${{github.workspace}}\Packages\**\*.msix
78+
${{github.workspace}}\Packages\**\*.cer
79+
${{github.workspace}}\Packages\**\Dependencies\${{ matrix.platform }}\*

.github/workflows/msbuild-ARM64.yml

Lines changed: 0 additions & 79 deletions
This file was deleted.

.github/workflows/msbuild.yml

Lines changed: 0 additions & 79 deletions
This file was deleted.

update-version.ps1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
if ($env:VERSION_BUILD_NUMBER) {
2+
$manifestPaths = @(
3+
".\ContextMenuCustom\ContextMenuCustomDevPackage\Package.appxmanifest",
4+
".\ContextMenuCustom\ContextMenuCustomGithubPackage\Package.appxmanifest",
5+
".\ContextMenuCustom\ContextMenuCustomAnyPackage\Package.appxmanifest",
6+
".\ContextMenuCustom\ContextMenuCustomPackage\Package.appxmanifest"
7+
)
8+
9+
foreach ($manifestPath in $manifestPaths) {
10+
if (-not (Test-Path -LiteralPath $manifestPath)) {
11+
Write-Warning "Manifest not found: $manifestPath"
12+
continue
13+
}
14+
15+
$appxManifestPath = Convert-Path $manifestPath
16+
[xml]$manifest = Get-Content -Path $appxManifestPath
17+
$version = $manifest.Package.Identity.Version
18+
$versionParts = $version -split '\.'
19+
20+
if ($versionParts.Length -ne 4) {
21+
Write-Error "Version format error: $version ($appxManifestPath)"
22+
exit 1
23+
}
24+
25+
$versionParts[3] = $env:VERSION_BUILD_NUMBER
26+
$manifest.Package.Identity.Version = $versionParts -join "."
27+
Write-Host "package new version ($appxManifestPath): $($manifest.Package.Identity.Version)"
28+
$manifest.Save($appxManifestPath)
29+
}
30+
}

0 commit comments

Comments
 (0)