Skip to content

Commit e4a677b

Browse files
committed
CI: parallelize inside the ps1 script
1 parent 0976b5d commit e4a677b

File tree

5 files changed

+81
-54
lines changed

5 files changed

+81
-54
lines changed

.github/workflows/jackpot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- name: Publish
2121
shell: pwsh
22-
run: .\src\Publish-Release.ps1
22+
run: .\src\Publish-MsixBundle.ps1
2323

2424
- name: Upload
2525
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@
88
bin/
99
downloads/
1010
obj/
11-
publish/
11+
x64/
12+
arm64/
13+
publish/
14+
bundle/

src/J.App/J.App.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
1010
<AssemblyName>Jackpot</AssemblyName>
1111
<ApplicationIcon>Resources\App.ico</ApplicationIcon>
12+
<PublishReadyToRun>true</PublishReadyToRun>
1213
<Version>0.2.0</Version>
1314
</PropertyGroup>
1415

src/Publish-Release.ps1 renamed to src/Publish-Msix.ps1

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1+
param
2+
(
3+
[Parameter(Mandatory = $true)] [string] $Arch
4+
)
5+
16
$ErrorPreference = 'Stop'
27
$ProgressPreference = 'SilentlyContinue'
38
Add-Type -AssemblyName System.IO.Compression, System.IO.Compression.FileSystem
49

10+
Write-Host "=== Start $Arch ==="
11+
512
$root = Split-Path -Path $PSScriptRoot -Parent
613

7-
$publishDir = "$root\publish"
14+
$publishDir = "$root\$Arch"
815
if (Test-Path $publishDir) {
916
[System.IO.Directory]::Delete($publishDir, $true) | Out-Null
1017
}
1118

12-
$buildDir = "$root\publish\build"
13-
14-
function Start-Publish
15-
{
16-
if (Test-Path $buildDir) {
17-
[System.IO.Directory]::Delete($buildDir, $true) | Out-Null
18-
}
19-
[System.IO.Directory]::CreateDirectory($buildDir) | Out-Null
19+
$buildDir = "$root\$Arch\build"
20+
if (Test-Path $buildDir) {
21+
[System.IO.Directory]::Delete($buildDir, $true) | Out-Null
2022
}
23+
[System.IO.Directory]::CreateDirectory($buildDir) | Out-Null
2124

2225
$downloadsDir = "$root\downloads"
2326
[System.IO.Directory]::CreateDirectory($downloadsDir) | Out-Null
2427

25-
$bundleDir = "$root\publish\bundle"
26-
if (Test-Path $bundleDir) {
27-
[System.IO.Directory]::Delete($bundleDir, $true) | Out-Null
28-
}
28+
$bundleDir = "$root\bundle"
2929
[System.IO.Directory]::CreateDirectory($bundleDir) | Out-Null
3030

3131
# Windows SDK
@@ -52,11 +52,6 @@ if (Test-Path $makepri) {
5252

5353
function Publish-App
5454
{
55-
param
56-
(
57-
[Parameter(Mandatory = $true)] [string] $Arch
58-
)
59-
6055
Write-Host "Publishing $Arch."
6156
dotnet publish "$root/src/J.App/J.App.csproj" --output "$buildDir" --self-contained --runtime "win-$Arch" --configuration Release --verbosity quiet
6257
Remove-Item -Path "$dir\*.pdb" -Force
@@ -76,7 +71,7 @@ function Get-FfmpegX64
7671
}
7772

7873
Write-Host "Extracting ffmpeg/x64."
79-
$dstDir = "$buildDir\x64\ffmpeg\"
74+
$dstDir = "$buildDir\ffmpeg\"
8075
[System.IO.Directory]::CreateDirectory($dstDir) | Out-Null
8176
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipFilePath, $dstDir)
8277

@@ -107,7 +102,7 @@ function Get-FfmpegArm64
107102
}
108103

109104
Write-Host "Extracting ffmpeg/arm64."
110-
$dstDir = "$buildDir\arm64\ffmpeg\"
105+
$dstDir = "$buildDir\ffmpeg\"
111106
[System.IO.Directory]::CreateDirectory($dstDir) | Out-Null
112107
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipFilePath, $dstDir)
113108

@@ -117,11 +112,6 @@ function Get-FfmpegArm64
117112

118113
function Copy-MiscFiles
119114
{
120-
param
121-
(
122-
[Parameter(Mandatory = $true)] [string] $Arch
123-
)
124-
125115
Copy-Item -Path "$root\COPYING" -Destination "$buildDir\COPYING"
126116
Copy-Item -Path "$root\NOTICE" -Destination "$buildDir\NOTICE"
127117

@@ -167,11 +157,6 @@ function Copy-MiscFiles
167157

168158
function New-Msix
169159
{
170-
param
171-
(
172-
[Parameter(Mandatory = $true)] [string] $Arch
173-
)
174-
175160
Write-Host "Creating MSIX package."
176161
$msixFilePath = "$bundleDir\Jackpot-$Arch.msix"
177162
if (Test-Path $msixFilePath) { Remove-Item -Path $msixFilePath -Force }
@@ -183,26 +168,13 @@ function New-Msix
183168
Write-Host "--- End: MakeAppx pack ---`n"
184169
}
185170

186-
Write-Host "=== x64 build ==="
187-
Start-Publish
188-
Copy-MiscFiles -Arch "x64"
189-
Publish-App -Arch "x64"
190-
Get-FfmpegX64
191-
New-Msix -Arch "x64"
192-
193-
Write-Host "=== arm64 build ==="
194-
Start-Publish
195-
Copy-MiscFiles -Arch "arm64"
196-
Publish-App -Arch "arm64"
197-
Get-FfmpegArm64
198-
New-Msix -Arch "arm64"
199-
200-
Write-Host "=== msixbundle ==="
201-
$msixBundleFilePath = "$root\publish\Jackpot.msixbundle"
202-
if (Test-Path $msixBundleFilePath) { Remove-Item -Path $msixBundleFilePath -Force }
203-
Write-Host "`n--- Start: MakeAppx bundle ---"
204-
& "$makeappx" bundle /p "$msixBundleFilePath" /d "$bundleDir"
205-
if ($LastExitCode -ne 0) {
206-
throw "Failed to create MSIX bundle."
171+
Copy-MiscFiles
172+
Publish-App
173+
if ($Arch -eq "x64") {
174+
Get-FfmpegX64
175+
} elseif ($Arch -eq "arm64") {
176+
Get-FfmpegArm64
207177
}
208-
Write-Host "--- End: MakeAppx bundle ---`n"
178+
New-Msix
179+
180+
Write-Host "=== End $Arch ==="

src/Publish-MsixBundle.ps1

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
$ErrorPreference = 'Stop'
2+
$ProgressPreference = 'SilentlyContinue'
3+
4+
$root = Split-Path -Path $PSScriptRoot -Parent
5+
6+
$bundleDir = "$root\bundle"
7+
if (Test-Path $bundleDir) {
8+
[System.IO.Directory]::Delete($bundleDir, $true) | Out-Null
9+
}
10+
11+
# Windows SDK
12+
$windowsSdkBaseDir = "C:\Program Files (x86)\Windows Kits\10\Redist"
13+
$windowsSdkVersion = `
14+
Get-ChildItem -Path $windowsSdkBaseDir |
15+
Where-Object { $_.Name -match '^10\.0\.\d+\.\d+$' } |
16+
Sort-Object Name -Descending |
17+
Select-Object -First 1 -ExpandProperty Name
18+
19+
$makeappx = "C:\Program Files (x86)\Windows Kits\10\bin\$windowsSdkVersion\x64\makeappx.exe"
20+
if (Test-Path $makeappx) {
21+
Write-Output "MakeAppx: $makeappx"
22+
} else {
23+
throw "MakeAppx not found!"
24+
}
25+
26+
# Restore for both architectures
27+
dotnet restore "$root/src/J.App/J.App.csproj" --runtime "win-x64" --verbosity quiet
28+
dotnet restore "$root/src/J.App/J.App.csproj" --runtime "win-arm64" --verbosity quiet
29+
30+
# Make arch-specific msix installers
31+
$x64job = Start-Job -Name "x64" -ScriptBlock {
32+
param($root)
33+
& "$root\src\Publish-Msix.ps1" -Arch "x64"
34+
} -ArgumentList $root
35+
36+
$arm64job = Start-Job -Name "arm64" -ScriptBlock {
37+
param($root)
38+
& "$root\src\Publish-Msix.ps1" -Arch "arm64"
39+
} -ArgumentList $root
40+
41+
Receive-Job -Job $x64job -Wait -AutoRemoveJob
42+
Receive-Job -Job $arm64job -Wait -AutoRemoveJob
43+
44+
# Make bundle
45+
$msixBundleFilePath = "$root\publish\Jackpot.msixbundle"
46+
if (Test-Path $msixBundleFilePath) { Remove-Item -Path $msixBundleFilePath -Force }
47+
48+
& "$makeappx" bundle /p "$msixBundleFilePath" /d "$bundleDir"
49+
if ($LastExitCode -ne 0) {
50+
throw "Failed to create MSIX bundle."
51+
}

0 commit comments

Comments
 (0)