-
Notifications
You must be signed in to change notification settings - Fork 0
217 lines (181 loc) · 7.01 KB
/
build.yml
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Build
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
# C:\ drive in gh action is much slower than D:\, move everything we can to D:\
DOTNET_INSTALL_DIR: D:\dotnet
# versions of dependencies needed for building and bootstrapping Pog
# these should be updated periodically with the following command:
# ```
# "VERSION_DOTNET: `"$(dotnet --version)`""
# "VERSION_PESTER: `"$((Find-Module Pester).Version)`""
# "VERSION_WIX_DARK: `"$((Find-Pog dark@ScoopInstaller).Version)`""
# "VERSION_NINJA: `"$((Find-Pog ninja-build).Version)`""
# Find-Pog ILRepack, UPX, 7zip | % {"VERSION_$($_.PackageName.ToUpperInvariant()): `"$($_.Version)`""}
# ```
VERSION_DOTNET: "9.0.101"
VERSION_PESTER: "5.7.1"
VERSION_WIX_DARK: "3.14"
VERSION_NINJA: "1.10.2"
VERSION_ILREPACK: "2.0.29"
VERSION_UPX: "4.2.3"
VERSION_7ZIP: "24.08"
jobs:
build:
runs-on: windows-latest
steps:
- name: Configure git to preserve line endings
run: git config --global core.autocrlf false
- uses: actions/checkout@v4
# needed to build Pog.dll
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{env.VERSION_DOTNET}}
cache: true
cache-dependency-path: app/Pog/lib_compiled/*/packages.lock.json
# used for PowerShell unit tests
- name: Install Pester
working-directory: ..
shell: pwsh
run: |
# this is significantly faster than `Install-Module Pester -Force`
iwr "https://www.powershellgallery.com/api/v2/package/Pester/$($env:VERSION_PESTER)" -OutFile D:\pester.nupkg
$ModuleDir = "$(Split-Path $PROFILE)\Modules"
Expand-Archive D:\pester.nupkg "$ModuleDir\Pester"
# needed to unpack vcredist packages
- name: Install WiX dark.exe
shell: pwsh
run: |
iwr "https://raw.githubusercontent.com/ScoopInstaller/Binary/master/dark/dark-$($env:VERSION_WIX_DARK).zip" -OutFile D:\dark.zip
Expand-Archive D:\dark.zip D:\dark
Add-Content $env:GITHUB_PATH D:\dark
# useful to speed up Pog.Shim build
- name: Install Ninja
shell: pwsh
run: |
iwr "https://github.com/ninja-build/ninja/releases/download/v$($env:VERSION_NINJA)/ninja-win.zip" -OutFile D:\ninja.zip
Expand-Archive D:\ninja.zip D:\ninja
Add-Content $env:GITHUB_PATH D:\ninja
# needed to build Pog.dll
- name: Install ILRepack
shell: pwsh
run: |
iwr "https://www.nuget.org/api/v2/package/ILRepack/${env:VERSION_ILREPACK}" -OutFile D:\ilrepack.nupkg
Expand-Archive D:\ilrepack.nupkg D:\ilrepack
Add-Content $env:GITHUB_PATH D:\ilrepack\tools
# needed to build PogShimTemplate.exe
- name: Install UPX
shell: pwsh
run: |
iwr "https://github.com/upx/upx/releases/download/v${env:VERSION_UPX}/upx-${env:VERSION_UPX}-win64.zip" -OutFile D:\upx.zip
Expand-Archive D:\upx.zip D:\upx_tmp
mv D:\upx_tmp\* D:\upx
rm D:\upx_tmp
# add to PATH for following steps
Add-Content $env:GITHUB_PATH D:\upx
# needed to install any Pog package (including an up-to-date 7zip)
- name: Install bootstrap 7zip
working-directory: ..
shell: pwsh
run: |
iwr "https://www.7-zip.org/a/7z$($env:VERSION_7ZIP.Replace('.', ''))-x64.exe" -OutFile D:\7zip.exe
Start-Process -Wait D:\7zip.exe -ArgumentList /S, /D=$PWD\7zip\app
# just a stub manifest, will be replaced later
Set-Content $PWD\7zip\pog.psd1 '@{Private = $true; Enable = {Export-Command "7z" "./app/7z.exe" -VcRedist}}'
- name: Verify build dependencies
shell: pwsh
run: |
[pscustomobject]@{Name = "dotnet.exe"; Version = dotnet.exe --version; Source = (gcm dotnet.exe).Source}
gmo Pester -ListAvailable | select -First 1
gcm dark.exe
gcm ilrepack.exe
gcm upx.exe
gcm ..\7zip\app\7z.exe
- name: Build Pog.dll
working-directory: app/Pog/lib_compiled
run: |
dotnet sln remove RandomTests RandomBenchmarks
dotnet restore
dotnet publish --no-restore Pog
- name: Build Pog.Shim
working-directory: app/Pog/lib_compiled
run: |
cmake -B ./Pog.Shim/cmake-build-release -S ./Pog.Shim -DCMAKE_BUILD_TYPE=Release -G Ninja
cmake --build ./Pog.Shim/cmake-build-release --config Release
gi ./PogShimTemplate.exe
- name: Download VC Redistributable
shell: pwsh
run: |
./app/Pog/_scripts/vcredist-download.ps1 -OutDir ./app/Pog/lib_compiled/vc_redist @(
# latest vcredist 140
"https://aka.ms/vs/17/release/vc_redist.x64.exe"
# fixed vcredist 120
"https://aka.ms/highdpimfc2013x64enu"
)
- name: Setup Pog
shell: pwsh
run: |
.\setup.ps1
# add to PATH for following steps
Add-Content $env:GITHUB_PATH (Resolve-Path .\data\package_bin)
pog 7zip -Force
- name: Pog.Tests
working-directory: app/Pog/lib_compiled
run: dotnet test --no-restore Pog.Tests
- name: Pester tests (PowerShell Core)
working-directory: app/Pog
shell: pwsh
run: Invoke-Pester
- name: Pester tests (PowerShell 5)
working-directory: app/Pog
shell: powershell
run: Invoke-Pester
# install a few Pog packages to check that Pog works
- name: Test Pog packages (PowerShell Core)
shell: pwsh
run: |
Write-Host "PowerShell v$($PSVersionTable.PSVersion)"
$InformationPreference = "Continue"
Import-Module ./app/Pog -Verbose
Write-Host "Available packages: $(@(Find-Pog -AllVersions).Count)"
pog fzf, zstd, Jujutsu
Get-Pog
Write-Host ""
Write-Host "fzf: $(fzf --version)"
Write-Host "zstd: $(zstd --version)"
Write-Host "Jujutsu: $(jj --version)"
Write-Host ""
Uninstall-Pog fzf, zstd, Jujutsu
Clear-PogDownloadCache -Force
# the same test in PowerShell 5, to test compatibility
- name: Test Pog packages (PowerShell 5)
shell: powershell
run: |
Write-Host "PowerShell v$($PSVersionTable.PSVersion)"
$InformationPreference = "Continue"
Import-Module ./app/Pog -Verbose
Write-Host "Available packages: $(@(Find-Pog -AllVersions).Count)"
pog fzf, zstd, Jujutsu
Get-Pog
Write-Host ""
Write-Host "fzf: $(fzf --version)"
Write-Host "zstd: $(zstd --version)"
Write-Host "Jujutsu: $(jj --version)"
Write-Host ""
Uninstall-Pog fzf, zstd, Jujutsu
Clear-PogDownloadCache -Force
- name: Generate release archive
shell: pwsh
run: |
& ./app/Pog/_scripts/release/build-release.ps1 -ReleasePath D:/PogRelease.zip
# unpack so that the generated artifact (which is always zipped) is not a nested .zip
Expand-Archive D:\PogRelease.zip D:\PogRelease
- name: Publish release archive as artifact
uses: actions/upload-artifact@v4
with:
name: Pog
path: D:/PogRelease