-
Notifications
You must be signed in to change notification settings - Fork 2
213 lines (193 loc) · 7.96 KB
/
Copy pathbuild-source.yml
File metadata and controls
213 lines (193 loc) · 7.96 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
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
name: Build QuantLibAddin source archives
# Manually-triggered build of the downloadable QuantLibAddin SOURCE archives
# (a .zip for Windows users and a .tar.gz for Linux users).
#
# The key feature is that gensrc is run BEFORE the archive is created, so the
# autogenerated sources are already present. That lets an end user compile the
# "Basic" build straight from the archive without having to install Python and
# run gensrc themselves.
#
# gensrc is pure Python: it needs Python 3 only - no C++ compiler, no Boost and
# no QuantLib clone. Two commands are run, mirroring gensrc/CMakeLists.txt:
# ObjectHandler : python gensrc/gensrc.py -xdlv --oh_dir=.. (cwd ObjectHandler/gensrc)
# QuantLibAddin : python gensrc/gensrc.py -a --oh_dir=../../ObjectHandler (cwd QuantLibAddin/gensrc)
# Both platforms use the full "-a" generation (Option A): the archives contain
# identical files and differ only in line endings (CRLF in the zip, LF in the
# tarball).
#
# QuantLib itself is NOT bundled - users obtain the matching QuantLib release
# separately.
on:
workflow_dispatch:
inputs:
make_release:
description: "Publish the source archives as GitHub Release assets"
required: true
type: boolean
default: false
release_tag:
description: "Tag of the GitHub Release to attach the archives to (e.g. v1.42.0). Required when publishing."
required: false
default: "v1.42.0"
permissions:
contents: write
env:
# Release/package version. Matches the version used by the XLL/docs workflows.
QLXL_VERSION: "1.42.0"
jobs:
# ---------------------------------------------------------------------------
# Windows source zip (CRLF line endings).
# ---------------------------------------------------------------------------
source-zip:
runs-on: windows-latest
steps:
- name: Checkout QuantLibAddin
uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Run gensrc (generate sources)
shell: bash
run: |
set -e
echo "::group::ObjectHandler gensrc"
( cd ObjectHandler/gensrc && python "$GITHUB_WORKSPACE/gensrc/gensrc.py" -xdlv --oh_dir=.. )
echo "::endgroup::"
echo "::group::QuantLibAddin gensrc"
( cd QuantLibAddin/gensrc && python "$GITHUB_WORKSPACE/gensrc/gensrc.py" -a --oh_dir=../../ObjectHandler )
echo "::endgroup::"
- name: Stage source tree
shell: bash
run: |
set -e
root="dist/QuantLibAddin-${QLXL_VERSION}"
mkdir -p "$root"
# Copy the working tree into the staging root, excluding VCS metadata,
# the separate QuantLib clone and any build/IDE artifacts. rsync is
# not available on windows-latest (Git Bash), so use tar, which is.
tar \
--exclude='./.git' \
--exclude='./dist' \
--exclude='./QuantLib' \
--exclude='./build' \
--exclude='./build*' \
--exclude='./out' \
--exclude='./.vs' \
--exclude='__pycache__' \
--exclude='*.pyc' \
-cf - . | tar -xf - -C "$root"
echo "Staged top-level entries:"
ls -a "$root"
- name: Normalize line endings to CRLF
shell: bash
run: |
set -e
root="dist/QuantLibAddin-${QLXL_VERSION}"
# Convert LF -> CRLF on text sources so Windows users get native
# line endings. Binary files are left untouched.
find "$root" -type f \
\( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.c' \
-o -name '*.py' -o -name '*.txt' -o -name '*.docs' -o -name '*.md' \
-o -name '*.xml' -o -name '*.vcxproj' -o -name '*.sln' -o -name '*.filters' \
-o -name '*.props' -o -name '*.cmake' -o -name '*.yml' -o -name '*.yaml' \
-o -name '*.i' -o -name '*.idl' -o -name '*.bas' -o -name '*.cls' \) \
-print0 | while IFS= read -r -d '' f; do
sed -i 's/\r*$/\r/' "$f"
done
- name: Create source zip
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$zip = "QuantLibAddin-$env:QLXL_VERSION.zip"
Compress-Archive -Path "dist/QuantLibAddin-$env:QLXL_VERSION" -DestinationPath $zip -Force
"ZIP_NAME=$zip" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "Created $zip"
- name: Upload source zip
uses: actions/upload-artifact@v4
with:
name: QuantLibAddin-${{ env.QLXL_VERSION }}-zip
path: QuantLibAddin-${{ env.QLXL_VERSION }}.zip
if-no-files-found: error
- name: Attach source zip to GitHub Release
if: ${{ inputs.make_release }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.release_tag }}
files: ${{ env.ZIP_NAME }}
# ---------------------------------------------------------------------------
# Linux source tarball (LF line endings).
# ---------------------------------------------------------------------------
source-tar:
runs-on: ubuntu-latest
steps:
- name: Checkout QuantLibAddin
uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Run gensrc (generate sources)
shell: bash
run: |
set -e
echo "::group::ObjectHandler gensrc"
( cd ObjectHandler/gensrc && python "$GITHUB_WORKSPACE/gensrc/gensrc.py" -xdlv --oh_dir=.. )
echo "::endgroup::"
echo "::group::QuantLibAddin gensrc"
( cd QuantLibAddin/gensrc && python "$GITHUB_WORKSPACE/gensrc/gensrc.py" -a --oh_dir=../../ObjectHandler )
echo "::endgroup::"
- name: Stage source tree
shell: bash
run: |
set -e
root="dist/QuantLibAddin-${QLXL_VERSION}"
mkdir -p "$root"
rsync -a \
--exclude '.git' \
--exclude 'dist' \
--exclude 'QuantLib' \
--exclude 'build' \
--exclude 'build*' \
--exclude 'out' \
--exclude '.vs' \
--exclude '__pycache__' \
--exclude '*.pyc' \
./ "$root/"
echo "Staged top-level entries:"
ls -a "$root"
- name: Normalize line endings to LF
shell: bash
run: |
set -e
root="dist/QuantLibAddin-${QLXL_VERSION}"
# Strip any CR so Linux users get LF-only text sources.
find "$root" -type f \
\( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.c' \
-o -name '*.py' -o -name '*.txt' -o -name '*.docs' -o -name '*.md' \
-o -name '*.xml' -o -name '*.vcxproj' -o -name '*.sln' -o -name '*.filters' \
-o -name '*.props' -o -name '*.cmake' -o -name '*.yml' -o -name '*.yaml' \
-o -name '*.i' -o -name '*.idl' -o -name '*.bas' -o -name '*.cls' \) \
-print0 | while IFS= read -r -d '' f; do
sed -i 's/\r$//' "$f"
done
- name: Create source tarball
shell: bash
run: |
set -e
tar_name="QuantLibAddin-${QLXL_VERSION}.tar.gz"
( cd dist && tar czf "../${tar_name}" "QuantLibAddin-${QLXL_VERSION}" )
echo "TAR_NAME=${tar_name}" >> "$GITHUB_ENV"
echo "Created ${tar_name}"
- name: Upload source tarball
uses: actions/upload-artifact@v4
with:
name: QuantLibAddin-${{ env.QLXL_VERSION }}-tar
path: QuantLibAddin-${{ env.QLXL_VERSION }}.tar.gz
if-no-files-found: error
- name: Attach source tarball to GitHub Release
if: ${{ inputs.make_release }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.release_tag }}
files: ${{ env.TAR_NAME }}