Skip to content

Commit 8b6bf04

Browse files
committed
build: Improvements around build NativeShims
Set version in vcpkg and CMakeLists.txt on Github Actions build Robustness in creating directories for macOs and Windows
1 parent b194db5 commit 8b6bf04

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

.github/workflows/build-nativeshims.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ jobs:
3939
echo 'Running build script: Windows'
4040
cd Yubico.NativeShims
4141
& ./build-windows.ps1
42+
- name: Set version
43+
if: github.event.inputs.version
44+
shell: pwsh
45+
run: |
46+
$version = "${{ github.event.inputs.version }}"
47+
# Update CMakeLists.txt
48+
(Get-Content Yubico.NativeShims/CMakeLists.txt) -replace 'project\(Yubico.NativeShims VERSION [^)]+\)', "project(Yubico.NativeShims VERSION $version)" | Set-Content Yubico.NativeShims/CMakeLists.txt
49+
# Update vcpkg.json
50+
$vcpkg = Get-Content Yubico.NativeShims/vcpkg.json -Raw | ConvertFrom-Json
51+
$vcpkg.version = $version
52+
$vcpkg | ConvertTo-Json | Set-Content Yubico.NativeShims/vcpkg.json
53+
echo "Set version to $version"
4254
- uses: actions/upload-artifact@v4
4355
with:
4456
name: win-x64
@@ -71,6 +83,15 @@ jobs:
7183
echo 'Running build script: Linux (amd64)'
7284
cd Yubico.NativeShims
7385
sh ./build-linux-amd64.sh
86+
- name: Set version
87+
if: github.event.inputs.version
88+
run: |
89+
VERSION=${{ github.event.inputs.version }}
90+
# Update CMakeLists.txt
91+
sed -i "s/project(Yubico.NativeShims VERSION [^)]*)/project(Yubico.NativeShims VERSION $VERSION)/" Yubico.NativeShims/CMakeLists.txt
92+
# Update vcpkg.json
93+
jq --arg v "$VERSION" '.version = $v' Yubico.NativeShims/vcpkg.json > tmp.json && mv tmp.json Yubico.NativeShims/vcpkg.json
94+
echo "Set version to $VERSION"
7495
- uses: actions/upload-artifact@v4
7596
with:
7697
name: linux-x64
@@ -85,6 +106,15 @@ jobs:
85106
echo 'Running build script: Linux (arm64)'
86107
cd Yubico.NativeShims
87108
sh ./build-linux-arm64.sh
109+
- name: Set version
110+
if: github.event.inputs.version
111+
run: |
112+
VERSION=${{ github.event.inputs.version }}
113+
# Update CMakeLists.txt
114+
sed -i "s/project(Yubico.NativeShims VERSION [^)]*)/project(Yubico.NativeShims VERSION $VERSION)/" Yubico.NativeShims/CMakeLists.txt
115+
# Update vcpkg.json
116+
jq --arg v "$VERSION" '.version = $v' Yubico.NativeShims/vcpkg.json > tmp.json && mv tmp.json Yubico.NativeShims/vcpkg.json
117+
echo "Set version to $VERSION"
88118
- uses: actions/upload-artifact@v4
89119
with:
90120
name: linux-arm64
@@ -99,6 +129,15 @@ jobs:
99129
echo 'Running build script: macOS'
100130
cd Yubico.NativeShims
101131
sh ./build-macOS.sh
132+
- name: Set version
133+
if: github.event.inputs.version
134+
run: |
135+
VERSION=${{ github.event.inputs.version }}
136+
# Update CMakeLists.txt
137+
sed -i "s/project(Yubico.NativeShims VERSION [^)]*)/project(Yubico.NativeShims VERSION $VERSION)/" Yubico.NativeShims/CMakeLists.txt
138+
# Update vcpkg.json
139+
jq --arg v "$VERSION" '.version = $v' Yubico.NativeShims/vcpkg.json > tmp.json && mv tmp.json Yubico.NativeShims/vcpkg.json
140+
echo "Set version to $VERSION"
102141
- uses: actions/upload-artifact@v4
103142
with:
104143
name: osx-x64

Yubico.NativeShims/build-macOS.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ cmake \
1414
-DCMAKE_OSX_ARCHITECTURES=x86_64
1515

1616
cmake --build ./build64
17-
mkdir osx-x64
17+
mkdir -p osx-x64
1818
cp ./build64/libYubico.NativeShims.dylib ./osx-x64
1919

2020
cmake \
@@ -26,5 +26,5 @@ cmake \
2626
-DCMAKE_OSX_ARCHITECTURES=arm64
2727

2828
cmake --build ./buildarm
29-
mkdir osx-arm64
29+
mkdir -p osx-arm64
3030
cp ./buildarm/libYubico.NativeShims.dylib ./osx-arm64

Yubico.NativeShims/build-windows.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ Pop-Location
77
# 32-bit builds
88
cmake -S . -B build32 -A Win32 -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x86-windows-static
99
cmake --build build32 --config Release
10-
mkdir win-x86
10+
New-Item -ItemType Directory -Path win-x86 -Force
1111
Copy-Item build32\Release\Yubico.NativeShims.dll win-x86
1212

1313
# 64-bit builds
1414
cmake -S . -B build64 -A x64 -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows-static
1515
cmake --build build64 --config Release
16-
mkdir win-x64
16+
New-Item -ItemType Directory -Path win-x64 -Force
1717
Copy-Item build64\Release\Yubico.NativeShims.dll win-x64
1818

1919
# ARM64 builds
2020
cmake -S . -B buildarm -A arm64 -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=arm64-windows-static
2121
cmake --build buildarm --config Release
22-
mkdir win-arm64
22+
New-Item -ItemType Directory -Path win-arm64 -Force
2323
Copy-Item buildarm\Release\Yubico.NativeShims.dll win-arm64

0 commit comments

Comments
 (0)