-
Notifications
You must be signed in to change notification settings - Fork 1
314 lines (303 loc) · 10.6 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
name: "Build"
on:
push:
branches: [ main ]
schedule:
- cron: '18 13 * * 6'
jobs:
determine_version:
name: Determine the major.minor.patch version.
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Git Version
id: version
uses: codacy/[email protected]
- name: Use the version
run: |
echo ${{ steps.version.outputs.version }} > version.txt
g++ src/python-module/fix-version.cpp -O3
./a.out version.txt
echo ${{ steps.version.outputs.version }}
- uses: actions/upload-artifact@v3
with:
name: version-info
path: version.txt
make-linux:
name: Make libarithmetica for Linux.
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
steps:
- name: Set up NASM
uses: ilammy/[email protected]
- name: Checkout repo.
uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- run: |
git submodule update --init --recursive
git submodule update --remote
cmake --no-warn-unused-cli -DARITHMETICA_BUILD_SHARED=ON -DBUILD_BMO=ON -DENABLE_TESTS=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++ -S . -B build -G "Unix Makefiles"
cmake --build build --config Release --target all -j 10 --
mkdir linux-build
mv build/src/library/libarithmetica.a linux-build/libarithmetica.a
mv build/src/library/libarithmetica.so linux-build/libarithmetica.so
cp src/library/arithmetica.h linux-build/arithmetica.h
cp src/library/arithmetica.hpp linux-build/arithmetica.hpp
cd linux-build
zip -r libarithmetica-linux.zip ./
- uses: actions/upload-artifact@v3
with:
name: linux-build
path: linux-build/libarithmetica-linux.zip
- uses: actions/upload-artifact@v3
with:
name: linux-bmo
path: build/build/_deps/bmo-src/src/library/libbasic_math_operations.a
make-windows:
name: Make libarithmetica-windows.a
runs-on: windows-latest
permissions:
actions: write
contents: write
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
steps:
- name: Set up NASM
uses: ilammy/[email protected]
- name: Set up MinGW
uses: egor-tensin/setup-mingw@v2
with:
platform: x64
- name: Checkout repo.
uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- run: |
git submodule update --init --recursive
cmake --no-warn-unused-cli -DARITHMETICA_BUILD_SHARED=ON -DBUILD_BMO=ON -DENABLE_TESTS=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Release -S . -B build -G "MinGW Makefiles"
cmake --build build --config Release --target all -j 10 --
cd "build/src/library"
ren libarithmetica.a libarithmetica-windows.a
- uses: actions/upload-artifact@v3
with:
name: windows-build
path: build/src/library/libarithmetica-windows.a
- uses: actions/upload-artifact@v3
with:
name: windows-bmo
path: build/build/_deps/bmo-src/src/library/libbasic_math_operations.a
make-wheel-windows:
needs:
- make-windows
runs-on: windows-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: dist/artifacts
- name: Move version info
run: |
cp dist/artifacts/version-info/version.txt version.txt
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: dist/artifacts
- name: Build wheel
run: |
python setup.py bdist_wheel
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: windows-whl
path: dist/*.whl
make-wheel-linux:
needs:
- make-linux
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: dist/artifacts
- name: Git Version
id: version
uses: codacy/[email protected]
- name: Use the version
run: |
echo ${{ steps.version.outputs.version }} > version.txt
g++ src/python-module/fix-version.cpp -O3
./a.out version.txt
echo ${{ steps.version.outputs.version }}
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: dist/artifacts
- name: Build wheel
run: |
python setup.py bdist_wheel
pip3 install auditwheel
auditwheel repair dist/*.whl --plat manylinux2014_x86_64
rm dist/*linux_x86_64.whl
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: linux-whl
path: wheelhouse/*.whl
release:
needs:
- make-linux
- make-wheel-linux
- make-windows
- make-wheel-windows
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Download all git history and tags
- name: Declare github short hash.
id: vars
shell: bash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: dist/artifacts
- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.vars.outputs.sha_short }}
release_name: arithmetica ${{ steps.vars.outputs.sha_short }}
draft: false
prerelease: false
- name: Upload asset for Linux.
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/artifacts/linux-build/libarithmetica-linux.zip
asset_name: libarithmetica-linux.zip
asset_content_type: application/zip
- name: Upload asset for Windows.
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/artifacts/windows-build/libarithmetica-windows.a
asset_name: libarithmetica-windows.a
asset_content_type: application/octet-stream
- name: Get Linux and Windows wheel name
run: |
cd dist/artifacts/linux-whl/
echo "LINUX_WHEEL=$(ls *.whl)" >> $GITHUB_ENV
cd ../windows-whl/
echo "WIN_WHEEL=$(ls *.whl)" >> $GITHUB_ENV
cd ../..
- name: Upload wheel for Linux.
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/artifacts/linux-whl/${{ env.LINUX_WHEEL }}
asset_name: ${{ env.LINUX_WHEEL }}
asset_content_type: application/octet-stream
- name: Upload wheel for Windows.
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/artifacts/windows-whl/${{ env.WIN_WHEEL }}
asset_name: ${{ env.WIN_WHEEL }}
asset_content_type: application/octet-stream
pypi-upload:
needs:
- make-wheel-linux
- make-wheel-windows
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: dist/artifacts
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10.x'
- name: Git Version
id: version
uses: codacy/[email protected]
- name: Use the version
run: |
echo ${{ steps.version.outputs.version }} > version.txt
g++ src/python-module/fix-version.cpp -O3
./a.out version.txt
echo ${{ steps.version.outputs.version }}
- name: Install Twine and create SDIST
run: |
sudo apt-get install rename -y
python -m pip install twine
python setup.py sdist --formats=gztar
mkdir -p build/dist/ && mv dist/artifacts build/dist
mv build/dist/artifacts/windows-whl/* dist/
mv build/dist/artifacts/linux-whl/* dist/
echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Run Twine
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload --verbose dist/*