Repository navigation
183 lines (155 loc) · 6.76 KB
/
Copy pathrelease.yml
File metadata and controls
183 lines (155 loc) · 6.76 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
name: Store Release
run-name: Store release ${{ inputs.version }}
on:
workflow_dispatch:
inputs:
version:
description: Store package version, for example 1.2.3
required: true
type: string
publish:
description: Submit the package to Microsoft Store
required: true
type: boolean
default: false
permissions:
contents: read
concurrency:
group: store-release
cancel-in-progress: false
jobs:
store-release:
name: Build and optionally submit Store MSIX
runs-on: windows-latest
timeout-minutes: 45
env:
STORE_PRODUCT_ID: ${{ vars.STORE_PRODUCT_ID }}
PACKAGE_IDENTITY_NAME: ${{ vars.WINDOWS_PACKAGE_IDENTITY_NAME }}
PACKAGE_PUBLISHER: ${{ vars.WINDOWS_PACKAGE_PUBLISHER }}
steps:
- name: Check out source
uses: actions/checkout@v7
- name: Validate Store package version
id: version
shell: pwsh
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
$ErrorActionPreference = 'Stop'
$version = $env:INPUT_VERSION.Trim()
if ($version.StartsWith('v')) {
$version = $version.Substring(1)
}
$pattern = '^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)$'
if ($version -notmatch $pattern) {
throw "'$version' is not a supported Store package version. Use a stable version such as 1.2.3."
}
$major = [int] $Matches.major
$minor = [int] $Matches.minor
$patch = [int] $Matches.patch
if ($major -gt 65534 -or $minor -gt 65534 -or $patch -gt 65534) {
throw 'Each numeric version component must be between 0 and 65534 for .NET.'
}
$packageVersion = "$major.$minor.$patch.0"
"version=$version" >> $env:GITHUB_OUTPUT
"package_version=$packageVersion" >> $env:GITHUB_OUTPUT
"VERSION=$version" >> $env:GITHUB_ENV
"PACKAGE_VERSION=$packageVersion" >> $env:GITHUB_ENV
- name: Set up .NET 8
uses: actions/setup-dotnet@v6
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore WinLive.sln -p:Platform=x64
- name: Run tests
run: dotnet test WinLive.sln --configuration Release -p:Platform=x64 --no-restore
- name: Set Store package identity
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$manifestPath = Join-Path $env:GITHUB_WORKSPACE 'src\WinLive\Package.appxmanifest'
[xml] $manifest = Get-Content -LiteralPath $manifestPath -Raw
if (-not [string]::IsNullOrWhiteSpace($env:PACKAGE_IDENTITY_NAME)) {
$manifest.Package.Identity.Name = $env:PACKAGE_IDENTITY_NAME
}
if (-not [string]::IsNullOrWhiteSpace($env:PACKAGE_PUBLISHER)) {
$manifest.Package.Identity.Publisher = $env:PACKAGE_PUBLISHER
}
$manifest.Package.Identity.Version = $env:PACKAGE_VERSION
$manifest.Save($manifestPath)
- name: Build unsigned MSIX package
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$packageDir = Join-Path $env:GITHUB_WORKSPACE 'artifacts\store-release-msix\'
dotnet build 'src\WinLive\WinLive.csproj' `
--configuration Release `
--no-restore `
"-p:Version=$env:VERSION" `
"-p:AssemblyVersion=$env:PACKAGE_VERSION" `
"-p:FileVersion=$env:PACKAGE_VERSION" `
-p:Platform=x64 `
-p:GenerateAppxPackageOnBuild=true `
-p:AppxPackageSigningEnabled=false `
"-p:AppxPackageDir=$packageDir"
- name: Collect Store package
id: package
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$msixFiles = @(Get-ChildItem 'artifacts\store-release-msix' -Recurse -Filter '*.msix')
if ($msixFiles.Count -ne 1) {
throw "Expected exactly one MSIX package, found $($msixFiles.Count)."
}
$outputDir = Join-Path $env:GITHUB_WORKSPACE 'artifacts\store-release'
New-Item -ItemType Directory -Force -Path $outputDir | Out-Null
$fileName = "WinLive-$env:VERSION-store-windows-x64.msix"
$outputPath = Join-Path $outputDir $fileName
Copy-Item -LiteralPath $msixFiles[0].FullName -Destination $outputPath
$hash = (Get-FileHash -LiteralPath $outputPath -Algorithm SHA256).Hash.ToLowerInvariant()
$hashPath = "$outputPath.sha256"
"$hash *$fileName" | Set-Content -LiteralPath $hashPath -Encoding ascii
"asset_path=$outputPath" >> $env:GITHUB_OUTPUT
- name: Upload Store package artifact
uses: actions/upload-artifact@v7
with:
name: WinLive-${{ steps.version.outputs.version }}-store-windows-x64
path: artifacts/store-release/*
if-no-files-found: error
compression-level: 0
retention-days: 30
- name: Configure Microsoft Store CLI
if: ${{ inputs.publish }}
uses: microsoft/microsoft-store-apppublisher@v1.4
- name: Submit package to Microsoft Store
if: ${{ inputs.publish }}
shell: pwsh
env:
AZURE_AD_TENANT_ID: ${{ secrets.AZURE_AD_TENANT_ID }}
AZURE_AD_APPLICATION_CLIENT_ID: ${{ secrets.AZURE_AD_APPLICATION_CLIENT_ID }}
AZURE_AD_APPLICATION_SECRET: ${{ secrets.AZURE_AD_APPLICATION_SECRET }}
SELLER_ID: ${{ secrets.SELLER_ID }}
PACKAGE_PATH: ${{ steps.package.outputs.asset_path }}
run: |
$ErrorActionPreference = 'Stop'
if ([string]::IsNullOrWhiteSpace($env:STORE_PRODUCT_ID)) {
throw 'Repository variable STORE_PRODUCT_ID is required when publish is true.'
}
if ([string]::IsNullOrWhiteSpace($env:AZURE_AD_TENANT_ID)) {
throw 'Repository secret AZURE_AD_TENANT_ID is required when publish is true.'
}
if ([string]::IsNullOrWhiteSpace($env:AZURE_AD_APPLICATION_CLIENT_ID)) {
throw 'Repository secret AZURE_AD_APPLICATION_CLIENT_ID is required when publish is true.'
}
if ([string]::IsNullOrWhiteSpace($env:AZURE_AD_APPLICATION_SECRET)) {
throw 'Repository secret AZURE_AD_APPLICATION_SECRET is required when publish is true.'
}
if ([string]::IsNullOrWhiteSpace($env:SELLER_ID)) {
throw 'Repository secret SELLER_ID is required when publish is true.'
}
msstore reconfigure `
--tenantId $env:AZURE_AD_TENANT_ID `
--sellerId $env:SELLER_ID `
--clientId $env:AZURE_AD_APPLICATION_CLIENT_ID `
--clientSecret $env:AZURE_AD_APPLICATION_SECRET
msstore publish $env:PACKAGE_PATH -id $env:STORE_PRODUCT_ID