-
Notifications
You must be signed in to change notification settings - Fork 9
183 lines (176 loc) · 5.43 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
name: build
on:
push:
branches: [ develop ]
tags: ['**']
pull_request:
branches: [ develop ]
env:
VCPKG_HASH: 'b4624c3a701b11248d88aab08744a37ee7aea1cc'
jobs:
build-sdist:
runs-on: 'ubuntu-latest'
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: actions/checkout@v4
- name: Create sdist
run: |
python -m pip install build
python -m build -s
- name: Check sdist
run: |
python -m pip install twine
twine check dist/*
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*
if-no-files-found: error
test-ubuntu-macos:
runs-on: ${{ matrix.os }}
needs: build-sdist
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest']
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Download sdist
uses: actions/download-artifact@v4
with:
name: sdist
path: dist
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install cddlib (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y libcdd-dev libgmp-dev
- name: Install cddlib (MacOS)
if: matrix.os == 'macos-latest'
run: brew install cddlib gmp
- name: Install Python dependencies
run: python -m pip install setuptools Cython Sphinx pytest wheel numpy mypy
- name: Install tarball (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: python -m pip install $(ls dist/*.tar.gz| head -1)
- name: Install tarball (MacOS)
if: matrix.os == 'macos-latest'
run: env "CFLAGS=-I$(brew --prefix)/include -L$(brew --prefix)/lib" python -m pip install $(ls dist/*.tar.gz| head -1)
- name: Run test suite
run: |
mypy
pytest
cd docs
make doctest
build-vcpkg:
runs-on: 'windows-latest'
steps:
- uses: actions/cache@v4
id: vcpkg-installed-cache
with:
path: installed/x64-windows-static-md-release
key: vcpkg-0-${{ env.VCPKG_HASH }}
- uses: actions/checkout@v4
if: steps.vcpkg-installed-cache.outputs.cache-hit != 'true'
with:
repository: microsoft/vcpkg
ref: ${{ env.VCPKG_HASH }}
- name: Install cddlib
if: steps.vcpkg-installed-cache.outputs.cache-hit != 'true'
run: |
./bootstrap-vcpkg.bat -disableMetrics
./vcpkg.exe install cddlib:x64-windows-static-md-release
ls installed/x64-windows-static-md-release/include/ -r
ls installed/x64-windows-static-md-release/lib/ -r
- name: Upload vcpkg
uses: actions/upload-artifact@v4
with:
name: vcpkg-x64
path: installed/x64-windows-static-md-release/
if-no-files-found: error
build-test-windows:
runs-on: 'windows-latest'
needs: build-vcpkg
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Download vcpkg
uses: actions/download-artifact@v4
with:
name: vcpkg-x64
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Check Python environment
run: |
ls include/ -r
ls lib/ -r
python --version
python -c "import struct; print(struct.calcsize('P') * 8)"
- name: Install Python dependencies
run: python -m pip install Sphinx pytest numpy twine wheel build mypy
- name: Create wheel
run: |
python -m build -w -C="--global-option=build_ext" -C="--global-option=-Iinclude/" -C="--global-option=-Llib/"
- name: Check wheel
run: |
twine check dist/*
wheel unpack ((Get-ChildItem -Path dist/ -Filter *.whl)[0].FullName) --dest wheel
ls -r wheel/
If (((Get-ChildItem -Path wheel/ -Recurse -Include ("*.pyx", "*.pxi", "*.c"))).Length -Ne 0) {
throw "Wheel contains .pyx, .pxi, or .c files."
}
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: windows-wheels-${{ matrix.python-version }}
path: dist/*
if-no-files-found: error
- name: Install wheel
run: pip install ((Get-ChildItem -Path dist/ -Filter *.whl)[0].FullName)
- name: Run test suite
run: |
mypy
pytest
cd docs
make doctest
release:
if: github.repository == 'mcmtroffaes/pycddlib'
runs-on: 'ubuntu-latest'
permissions:
id-token: write
needs: [ build-sdist, test-ubuntu-macos, build-test-windows ]
steps:
- name: Download sdist
uses: actions/download-artifact@v4
with:
name: sdist
path: dist/
- name: Download wheels
uses: actions/download-artifact@v4
with:
pattern: windows-wheels-*
path: dist/
merge-multiple: true
- name: List files
run: ls -r dist/
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1