-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (144 loc) · 5.49 KB
/
Copy pathbuild.yml
File metadata and controls
163 lines (144 loc) · 5.49 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
name: Build QuantLib DLL
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
inputs:
quantlib_version:
description: "QuantLib version"
required: true
default: "1.41"
boost_version:
description: "Boost version"
required: true
default: "1.87.0"
build_tests:
description: "Build and include QuantLib test suite"
type: boolean
default: true
run_tests:
description: "Run the QuantLib test suite after building"
type: boolean
default: false
create_release:
description: "Create a GitHub Release with the zip asset"
type: boolean
default: false
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: "Build QuantLib ${{ inputs.quantlib_version || '1.41' }} DLL"
runs-on: windows-2022
env:
QL_VERSION: ${{ inputs.quantlib_version || '1.41' }}
BOOST_VERSION: ${{ inputs.boost_version || '1.87.0' }}
steps:
- uses: actions/checkout@v4
- name: Build QuantLib DLL
shell: pwsh
run: |
$buildTests = "${{ inputs.build_tests }}" -ne "false"
$runTests = "${{ inputs.run_tests }}" -eq "true"
$buildTestsFlag = if ($buildTests) { "-BuildTests" } else { "" }
$runTestsFlag = if ($runTests) { "-RunTests" } else { "" }
$cmd = "scripts/Build-QuantLibDLL.ps1" +
" -QuantLibVersion $env:QL_VERSION" +
" -BoostVersion $env:BOOST_VERSION" +
" -InstallDir ${{ runner.temp }}\quantlib-install" +
" -TempDir ${{ runner.temp }}\quantlib-build" +
" -PackageZip" +
" -ZipOutputDir ${{ github.workspace }}" +
" $buildTestsFlag $runTestsFlag"
Write-Host "Running: $cmd"
Invoke-Expression $cmd
- name: Show build errors
if: failure()
shell: pwsh
run: |
$buildDir = "${{ runner.temp }}\quantlib-build\QuantLib-${{ env.QL_VERSION }}\build"
Write-Host "==> Searching for build error logs..."
if (Test-Path $buildDir) {
foreach ($logName in @("build-library.log", "build-testsuite.log")) {
$logPath = Join-Path $buildDir $logName
if (Test-Path $logPath) {
Write-Host "`n==> $logName (last 100 lines):"
Get-Content $logPath -Tail 100 | Write-Host
}
}
}
- name: Verify zip
shell: pwsh
run: |
$zip = "QuantLib-${{ env.QL_VERSION }}-x64-dll.zip"
$size = [math]::Round((Get-Item $zip).Length / 1MB, 1)
Write-Host "==> $zip ($size MB)"
- uses: actions/upload-artifact@v4
with:
name: "QuantLib-${{ env.QL_VERSION }}-x64-dll"
path: "QuantLib-${{ env.QL_VERSION }}-x64-dll.zip"
release:
name: Create GitHub Release
needs: build
if: >-
github.event_name == 'workflow_dispatch' &&
inputs.create_release
runs-on: ubuntu-24.04
permissions:
contents: write
env:
QL_VERSION: ${{ inputs.quantlib_version || '1.41' }}
steps:
- uses: actions/checkout@v4
- name: Move tag to current commit
run: |
TAG="v${{ env.QL_VERSION }}"
git tag -f "$TAG"
git push origin "$TAG" --force
- uses: actions/download-artifact@v4
with:
name: "QuantLib-${{ env.QL_VERSION }}-x64-dll"
- name: Delete existing release assets
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="v${{ env.QL_VERSION }}"
echo "Checking for existing release with tag $TAG..."
RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/$TAG \
--jq '.id' 2>/dev/null || true)
if [ -n "$RELEASE_ID" ]; then
echo "Found release $RELEASE_ID — deleting existing assets..."
gh api repos/${{ github.repository }}/releases/$RELEASE_ID/assets \
--jq '.[].id' | while read ASSET_ID; do
echo " Deleting asset $ASSET_ID"
gh api -X DELETE repos/${{ github.repository }}/releases/assets/$ASSET_ID
done
else
echo "No existing release for $TAG — nothing to clean up."
fi
- name: Create or update release
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ env.QL_VERSION }}"
name: "QuantLib ${{ env.QL_VERSION }} (Windows x64 DLL)"
body: |
Pre-built QuantLib ${{ env.QL_VERSION }} as a Windows x64 DLL.
**Contents of `QuantLib-${{ env.QL_VERSION }}-x64-dll.zip`:**
- `QuantLib-${{ env.QL_VERSION }}/bin/QuantLib-x64-mt.dll` — Runtime DLL
- `QuantLib-${{ env.QL_VERSION }}/lib/QuantLib-x64-mt.lib` — Import library
- `QuantLib-${{ env.QL_VERSION }}/include/ql/` — QuantLib headers (patched for DLL)
- `boost_${{ inputs.boost_version }}/` — Boost ${{ inputs.boost_version }} headers
**Build details:**
- Visual Studio 2022 (MSVC)
- `BUILD_SHARED_LIBS=ON`, `CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON`
- MSVC DLL CRT (`/MD`)
**Usage:**
```powershell
Expand-Archive QuantLib-${{ env.QL_VERSION }}-x64-dll.zip -DestinationPath C:\quantlib-deps
```
files: "QuantLib-${{ env.QL_VERSION }}-x64-dll.zip"
draft: false
prerelease: false