Skip to content

Commit 442b467

Browse files
authored
Add arch-specific Windows presets and update CI actions (#197)
1 parent 2d950e1 commit 442b467

2 files changed

Lines changed: 111 additions & 46 deletions

File tree

.github/workflows/main.yml

Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -31,42 +31,51 @@ jobs:
3131
- arch: arm64
3232

3333
steps:
34-
- name: "Set Build Type"
34+
- name: "Set Build Type and Presets"
3535
id: build_type
3636
shell: pwsh
3737
run: |
38-
if ("${{ github.ref }}".StartsWith("refs/tags/")) {
39-
echo "BUILD_TYPE=Release" >> $env:GITHUB_OUTPUT
40-
} else {
41-
echo "BUILD_TYPE=Debug" >> $env:GITHUB_OUTPUT
38+
$buildType = if ("${{ github.ref }}".StartsWith("refs/tags/")) { "Release" } else { "Debug" }
39+
echo "BUILD_TYPE=$buildType" >> $env:GITHUB_OUTPUT
40+
41+
$arch = "${{ matrix.arch }}"
42+
switch ($arch) {
43+
"x64" {
44+
$configurePreset = "windows-msvc-vs17"
45+
$buildDir = [System.IO.Path]::GetFullPath((Join-Path $env:GITHUB_WORKSPACE "..\..\_temp\windows-x64")).Replace('\', '/')
46+
}
47+
"x86" {
48+
$configurePreset = "windows-msvc-vs17-x86"
49+
$buildDir = [System.IO.Path]::GetFullPath((Join-Path $env:GITHUB_WORKSPACE "..\..\_temp\windows-x86")).Replace('\', '/')
50+
}
51+
"arm64" {
52+
$configurePreset = "windows-msvc-vs17-arm64"
53+
$buildDir = [System.IO.Path]::GetFullPath((Join-Path $env:GITHUB_WORKSPACE "..\..\_temp\windows-arm64")).Replace('\', '/')
54+
}
55+
default {
56+
throw "Unsupported matrix.arch: $arch"
57+
}
4258
}
4359
44-
if ("${{ matrix.arch }}" -eq "x64") {
45-
echo "Arch:x64";
46-
echo "::set-output name=BUILD_ARCH::x64";
47-
} elseif ("${{ matrix.arch }}" -eq "arm64") {
48-
echo "Arch:ARM64";
49-
echo "::set-output name=BUILD_ARCH::ARM64";
50-
} else {
51-
echo "Arch:Win32";
52-
echo "::set-output name=BUILD_ARCH::Win32";
53-
}
54-
60+
$buildPreset = if ($buildType -eq "Release") { "${configurePreset}-release" } else { $configurePreset }
61+
echo "CONFIGURE_PRESET=$configurePreset" >> $env:GITHUB_OUTPUT
62+
echo "BUILD_PRESET=$buildPreset" >> $env:GITHUB_OUTPUT
63+
echo "BUILD_DIR=$buildDir" >> $env:GITHUB_OUTPUT
5564
5665
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
57-
- uses: actions/checkout@v4
66+
- uses: actions/checkout@v6
5867
with:
5968
submodules: true
6069

6170
# - name: Install MSVC problem matcher
6271
# uses: ammaraskar/msvc-problem-matcher@master
6372

6473
# Install latest CMake
65-
- uses: lukka/get-cmake@v3.31.6
74+
- uses: lukka/get-cmake@v4.2.0
6675

6776
# Restore from cache the previously built ports
6877
- name: Restore artifacts, or setup vcpkg
69-
uses: lukka/run-vcpkg@v10
78+
uses: lukka/run-vcpkg@v11
7079
with:
7180
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
7281

@@ -80,14 +89,14 @@ jobs:
8089
uses: lukka/run-cmake@v10
8190
continue-on-error: false
8291
with:
83-
configurePreset: 'windows-msvc-vs17'
84-
buildPreset: ${{ startsWith(github.ref, 'refs/tags/') && 'windows-msvc-vs17-release' || 'windows-msvc-vs17' }}
92+
configurePreset: ${{ steps.build_type.outputs.CONFIGURE_PRESET }}
93+
buildPreset: ${{ steps.build_type.outputs.BUILD_PRESET }}
8594

8695
- name: "Check file existence"
8796
uses: andstor/file-existence-action@v3
8897
with:
8998
allow_failure: true
90-
files: "${{ github.workspace }}/../../_temp/windows/src/${{ steps.build_type.outputs.BUILD_TYPE }}/simple.dll, ${{ github.workspace }}/../../_temp/windows/cppjieba/src/cppjieba/dict/jieba.dict.utf8"
99+
files: "${{ steps.build_type.outputs.BUILD_DIR }}/src/${{ steps.build_type.outputs.BUILD_TYPE }}/simple.dll, ${{ steps.build_type.outputs.BUILD_DIR }}/cppjieba/src/cppjieba/dict/jieba.dict.utf8"
91100

92101
# can't build
93102
# npm run
@@ -120,7 +129,7 @@ jobs:
120129
mkdir libsimple-windows-${{ matrix.arch }}
121130
Copy-Item -Path src/${{ steps.build_type.outputs.BUILD_TYPE }}/simple.dll,cppjieba/src/cppjieba/dict/ -Destination libsimple-windows-${{ matrix.arch }}/ -Recurse
122131
Compress-Archive -Path libsimple-windows-${{ matrix.arch }} -DestinationPath "$outputDir\libsimple-windows-${{ matrix.arch }}.zip"
123-
working-directory: "${{ github.workspace }}/../../_temp/windows/"
132+
working-directory: "${{ steps.build_type.outputs.BUILD_DIR }}"
124133
- name: Release
125134
if: startsWith(github.ref, 'refs/tags/')
126135
uses: softprops/action-gh-release@v2
@@ -146,7 +155,7 @@ jobs:
146155
if: startsWith(github.ref, 'refs/tags/') != true
147156
run: echo "BUILD_TYPE=Debug" >> $GITHUB_ENV
148157

149-
- uses: actions/checkout@v4
158+
- uses: actions/checkout@v6
150159
with:
151160
fetch-depth: 0
152161
submodules: true
@@ -161,19 +170,14 @@ jobs:
161170
sudo apt-get install -y gcc g++
162171
163172
- name: Restore artifacts, or setup vcpkg
164-
uses: lukka/run-vcpkg@v10
173+
uses: lukka/run-vcpkg@v11
165174
with:
166175
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
167176

168177
- name: Install lcov
169178
if: startsWith(github.ref, 'refs/tags/') != true
170179
run: sudo apt-get install lcov
171180

172-
- name: Install codecov
173-
if: startsWith(github.ref, 'refs/tags/') != true
174-
shell: bash
175-
run: sudo pip install codecov
176-
177181
- run: |
178182
echo "RUNVCPKG_NO_CACHE=1" >> $GITHUB_ENV
179183
if: ${{ failure() || cancelled() }}
@@ -210,7 +214,12 @@ jobs:
210214
run: lcov --list coverage_filter.info
211215
- name: Code coverage - Upload to CodeCov
212216
if: ${{ startsWith(github.ref, 'refs/tags/') != true && matrix.os == 'ubuntu-latest' }}
213-
run: bash <(curl -s https://codecov.io/bash) -f coverage_filter.info || echo "Codecov did not collect coverage reports"
217+
uses: codecov/codecov-action@v5
218+
with:
219+
files: coverage_filter.info
220+
token: ${{ secrets.CODECOV_TOKEN }}
221+
fail_ci_if_error: false
222+
verbose: true
214223

215224
- name: "Check file existence"
216225
uses: andstor/file-existence-action@v3
@@ -219,7 +228,7 @@ jobs:
219228
files: "${{ github.workspace }}/build/src/libsimple.so, ${{ github.workspace }}/build/test/dict/jieba.dict.utf8"
220229

221230
# npm run
222-
- uses: actions/setup-node@v4
231+
- uses: actions/setup-node@v6
223232
if: startsWith(github.ref, 'refs/tags/') != true
224233
with:
225234
node-version: '20'
@@ -232,7 +241,7 @@ jobs:
232241
npm run b -- --ext_path="${{ github.workspace }}/build/src/" --dict_path="${{ github.workspace }}/build/test/dict/"
233242
234243
# python run
235-
- uses: actions/setup-python@v5
244+
- uses: actions/setup-python@v6
236245
if: startsWith(github.ref, 'refs/tags/') != true
237246
with:
238247
python-version: '3.13' # Version range or exact version of a Python version to use, using SemVer's version range syntax
@@ -245,7 +254,7 @@ jobs:
245254
- name: "Build Changelog"
246255
id: build_changelog
247256
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest' }}
248-
uses: mikepenz/release-changelog-builder-action@v1
257+
uses: mikepenz/release-changelog-builder-action@v6
249258
env:
250259
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
251260
- name: Package
@@ -265,7 +274,7 @@ jobs:
265274
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
266275
- name: Release
267276
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest' }}
268-
uses: softprops/action-gh-release@v1
277+
uses: softprops/action-gh-release@v2
269278
with:
270279
draft: true
271280
files: ${{ github.workspace }}/build/libsimple-linux-${{ matrix.os }}.zip
@@ -291,7 +300,7 @@ jobs:
291300
if: startsWith(github.ref, 'refs/tags/') != true
292301
run: echo "BUILD_TYPE=Debug" >> $GITHUB_ENV
293302

294-
- uses: actions/checkout@v4
303+
- uses: actions/checkout@v6
295304
with:
296305
submodules: true
297306

@@ -301,7 +310,7 @@ jobs:
301310

302311
# Restore from cache the previously built ports
303312
- name: Restore artifacts, or setup vcpkg
304-
uses: lukka/run-vcpkg@v10
313+
uses: lukka/run-vcpkg@v11
305314
with:
306315
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
307316

@@ -327,11 +336,11 @@ jobs:
327336
allow_failure: true
328337
files: "${{ github.workspace }}/../../_temp/macos/src/libsimple.dylib, ${{ github.workspace }}/../../_temp/macos/test/dict/jieba.dict.utf8"
329338

330-
- uses: actions/setup-node@v4
339+
- uses: actions/setup-node@v6
331340
with:
332341
node-version: '20'
333342

334-
# - uses: actions/setup-python@v5
343+
# - uses: actions/setup-python@v6
335344
# with:
336345
# python-version: '3.12' # Version range or exact version of a Python version to use, using SemVer's version range syntax
337346
# npm run
@@ -361,7 +370,7 @@ jobs:
361370

362371
- name: Release
363372
if: startsWith(github.ref, 'refs/tags/')
364-
uses: softprops/action-gh-release@v1
373+
uses: softprops/action-gh-release@v2
365374
with:
366375
draft: true
367376
files: "${{ github.workspace }}/../../_temp/macos/libsimple-osx-x64.zip"

CMakePresets.json

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": 8,
33
"cmakeMinimumRequired": {
44
"major": 3,
5-
"minor": 21,
5+
"minor": 28,
66
"patch": 0
77
},
88
"configurePresets": [
@@ -73,13 +73,10 @@
7373
}
7474
},
7575
{
76-
"name": "windows-msvc-vs17",
77-
"displayName": "Visual Studio 17 2022",
78-
"description": "Configure with VS17 and vcpkg toolchain",
76+
"name": "windows-msvc-vs17-base",
77+
"hidden": true,
7978
"generator": "Visual Studio 17 2022",
80-
"architecture": "x64",
8179
"toolset": "v143",
82-
"binaryDir": "${sourceDir}/../../_temp/windows",
8380
"cacheVariables": {
8481
"CMAKE_TOOLCHAIN_FILE": {
8582
"type": "FILEPATH",
@@ -107,6 +104,39 @@
107104
"lhs": "${hostSystemName}",
108105
"rhs": "Windows"
109106
}
107+
},
108+
{
109+
"name": "windows-msvc-vs17",
110+
"displayName": "Visual Studio 17 2022 (x64)",
111+
"description": "Configure with VS17 and vcpkg toolchain (x64)",
112+
"inherits": "windows-msvc-vs17-base",
113+
"architecture": "x64",
114+
"binaryDir": "${sourceDir}/../../_temp/windows-x64",
115+
"cacheVariables": {
116+
"VCPKG_TARGET_TRIPLET": "x64-windows"
117+
}
118+
},
119+
{
120+
"name": "windows-msvc-vs17-x86",
121+
"displayName": "Visual Studio 17 2022 (Win32)",
122+
"description": "Configure with VS17 and vcpkg toolchain (Win32)",
123+
"inherits": "windows-msvc-vs17-base",
124+
"architecture": "Win32",
125+
"binaryDir": "${sourceDir}/../../_temp/windows-x86",
126+
"cacheVariables": {
127+
"VCPKG_TARGET_TRIPLET": "x86-windows"
128+
}
129+
},
130+
{
131+
"name": "windows-msvc-vs17-arm64",
132+
"displayName": "Visual Studio 17 2022 (ARM64)",
133+
"description": "Configure with VS17 and vcpkg toolchain (ARM64)",
134+
"inherits": "windows-msvc-vs17-base",
135+
"architecture": "ARM64",
136+
"binaryDir": "${sourceDir}/../../_temp/windows-arm64",
137+
"cacheVariables": {
138+
"VCPKG_TARGET_TRIPLET": "arm64-windows"
139+
}
110140
}
111141
],
112142
"buildPresets": [
@@ -148,6 +178,32 @@
148178
"displayName": "Build Windows VS17 (Release)",
149179
"description": "Build with VS17 (Release)",
150180
"configuration": "Release"
181+
},
182+
{
183+
"name": "windows-msvc-vs17-x86",
184+
"configurePreset": "windows-msvc-vs17-x86",
185+
"displayName": "Build Windows VS17 (Win32)",
186+
"description": "Build with VS17 (Win32)"
187+
},
188+
{
189+
"name": "windows-msvc-vs17-x86-release",
190+
"configurePreset": "windows-msvc-vs17-x86",
191+
"displayName": "Build Windows VS17 (Win32, Release)",
192+
"description": "Build with VS17 (Win32, Release)",
193+
"configuration": "Release"
194+
},
195+
{
196+
"name": "windows-msvc-vs17-arm64",
197+
"configurePreset": "windows-msvc-vs17-arm64",
198+
"displayName": "Build Windows VS17 (ARM64)",
199+
"description": "Build with VS17 (ARM64)"
200+
},
201+
{
202+
"name": "windows-msvc-vs17-arm64-release",
203+
"configurePreset": "windows-msvc-vs17-arm64",
204+
"displayName": "Build Windows VS17 (ARM64, Release)",
205+
"description": "Build with VS17 (ARM64, Release)",
206+
"configuration": "Release"
151207
}
152208
]
153209
}

0 commit comments

Comments
 (0)