-
Notifications
You must be signed in to change notification settings - Fork 12
243 lines (200 loc) · 7.13 KB
/
Copy pathrelease.yml
File metadata and controls
243 lines (200 loc) · 7.13 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
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
# Release workflow: build wheels for all platforms and upload to PyPI
#
# Triggers:
# - On GitHub release creation
# - Manual dispatch (workflow_dispatch)
#
# To release:
# 1. Update version in src/simuPOP/_version.py
# 2. Create a GitHub release with a tag like "v1.1.18"
# 3. This workflow will automatically build and upload to PyPI
name: Release to PyPI
on:
release:
types: [published]
workflow_dispatch:
inputs:
upload_to_pypi:
description: 'Upload to PyPI (true/false)'
required: true
default: 'false'
type: choice
options:
- 'true'
- 'false'
permissions:
contents: read
jobs:
# Build source distribution (only needs to run once)
build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build sdist
run: python -m build --sdist
- name: Upload sdist artifact
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
# Build wheels on Linux
build-wheels-linux:
name: Build wheels on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install cibuildwheel
run: pip install cibuildwheel
- name: Build wheels
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp39-manylinux_x86_64 cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64 cp313-manylinux_x86_64"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_ALL_LINUX: yum install -y zlib-devel
CIBW_BEFORE_BUILD: pip install scikit-build-core cmake ninja swig
CIBW_TEST_COMMAND: python -c "import simuPOP; print(simuPOP.moduleInfo())"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux
path: wheelhouse/*.whl
# Build wheels on macOS (Intel)
build-wheels-macos-intel:
name: Build wheels on macOS (Intel)
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install system dependencies
run: brew install libomp
- name: Install cibuildwheel
run: pip install cibuildwheel
- name: Build wheels
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp39-macosx_x86_64 cp310-macosx_x86_64 cp311-macosx_x86_64 cp312-macosx_x86_64 cp313-macosx_x86_64"
CIBW_BEFORE_BUILD: pip install scikit-build-core cmake ninja swig
CIBW_ENVIRONMENT: OpenMP_ROOT=/usr/local/opt/libomp
CIBW_TEST_COMMAND: python -c "import simuPOP; print(simuPOP.moduleInfo())"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-intel
path: wheelhouse/*.whl
# Build wheels on macOS (Apple Silicon)
build-wheels-macos-arm:
name: Build wheels on macOS (Apple Silicon)
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install system dependencies
run: brew install libomp
- name: Install cibuildwheel
run: pip install cibuildwheel
- name: Build wheels
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp39-macosx_arm64 cp310-macosx_arm64 cp311-macosx_arm64 cp312-macosx_arm64 cp313-macosx_arm64"
CIBW_BEFORE_BUILD: pip install scikit-build-core cmake ninja swig
CIBW_ENVIRONMENT: OpenMP_ROOT=/opt/homebrew/opt/libomp
CIBW_TEST_COMMAND: python -c "import simuPOP; print(simuPOP.moduleInfo())"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-arm
path: wheelhouse/*.whl
# Build wheels on Windows
build-wheels-windows:
name: Build wheels on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install zlib via vcpkg (static)
run: vcpkg install zlib:x64-windows-static
- name: Install cibuildwheel
run: pip install cibuildwheel
- name: Build wheels
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp39-win_amd64 cp310-win_amd64 cp311-win_amd64 cp312-win_amd64 cp313-win_amd64"
CIBW_BEFORE_BUILD: pip install scikit-build-core cmake ninja swig
CIBW_ENVIRONMENT: CMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" CMAKE_ARGS="-DVCPKG_TARGET_TRIPLET=x64-windows-static"
CIBW_TEST_COMMAND: python -c "import simuPOP; print(simuPOP.moduleInfo())"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows
path: wheelhouse/*.whl
# Upload to PyPI
upload-pypi:
name: Upload to PyPI
needs: [build-sdist, build-wheels-linux, build-wheels-macos-intel, build-wheels-macos-arm, build-wheels-windows]
runs-on: ubuntu-latest
# Only upload on release or manual trigger with upload_to_pypi=true
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.upload_to_pypi == 'true')
environment:
name: pypi
url: https://pypi.org/project/simuPOP/
permissions:
id-token: write # Required for trusted publishing
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List distribution files
run: ls -la dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
# Optional: Upload to TestPyPI for testing
upload-testpypi:
name: Upload to TestPyPI
needs: [build-sdist, build-wheels-linux, build-wheels-macos-intel, build-wheels-macos-arm, build-wheels-windows]
runs-on: ubuntu-latest
# Only on manual trigger with upload_to_pypi=false (for testing)
if: github.event_name == 'workflow_dispatch' && github.event.inputs.upload_to_pypi == 'false'
environment:
name: testpypi
url: https://test.pypi.org/project/simuPOP/
permissions:
id-token: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List distribution files
run: ls -la dist/
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist/