|
1 | | -name: Build and test wheels |
| 1 | +name: Publish Python release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: |
6 | | - - main |
7 | | - - test |
8 | | - tags: |
9 | | - - '*' |
| 5 | + branches: [test-publish] |
10 | 6 | release: |
11 | 7 | types: [published] |
12 | 8 |
|
13 | | - |
14 | | -env: |
15 | | - FORCE_COLOR: 1 |
16 | | - |
17 | 9 | jobs: |
18 | | - OSX: |
19 | | - runs-on: macos-latest |
20 | | - strategy: |
21 | | - fail-fast: false |
22 | | - matrix: |
23 | | - python: [3.11, 3.12, 3.13, 3.14] |
24 | | - steps: |
25 | | - - name: Checkout |
26 | | - uses: actions/checkout@v6.0.2 |
27 | | - - name: Set up Python ${{ matrix.python }} |
28 | | - uses: actions/setup-python@v6.1.0 |
29 | | - with: |
30 | | - python-version: ${{ matrix.python }} |
31 | | - - name: Install deps |
32 | | - run: | |
33 | | - pip install build |
34 | | - - name: Build Wheel |
35 | | - run: | |
36 | | - cd python |
37 | | - python -m build --wheel --config-setting=--plat-name=macosx_10_9_universal2 |
38 | | - - name: Delocate to bundle dynamic libs |
39 | | - run: | |
40 | | - cd python |
41 | | - pip install delocate |
42 | | - delocate-wheel -v dist/*.whl |
43 | | - - name: Upload Wheels |
44 | | - uses: actions/upload-artifact@v6.0.0 |
45 | | - with: |
46 | | - name: osx-wheel-${{ matrix.python }} |
47 | | - path: python/dist |
| 10 | + build-wheels: |
| 11 | + uses: tskit-dev/.github/.github/workflows/build-wheels.yml@main |
| 12 | + with: |
| 13 | + pyproject-directory: python |
48 | 14 |
|
49 | | - windows: |
50 | | - runs-on: windows-latest |
51 | | - strategy: |
52 | | - fail-fast: false |
53 | | - matrix: |
54 | | - python: [3.11, 3.12, 3.13, 3.14] |
55 | | - wordsize: [64] |
56 | | - steps: |
57 | | - - name: Checkout |
58 | | - uses: actions/checkout@v6.0.2 |
59 | | - - name: Install deps |
60 | | - env: |
61 | | - PYTHON: "py -${{ matrix.python }}-${{ matrix.wordsize }}" |
62 | | - shell: bash |
63 | | - run: | |
64 | | - set -ex |
65 | | - ${PYTHON} -m pip install build |
66 | | - - name: Build Wheel |
67 | | - env: |
68 | | - PYTHON: "py -${{ matrix.python }}-${{ matrix.wordsize }}" |
69 | | - shell: bash |
70 | | - run: | |
71 | | - set -ex |
72 | | - git reset --hard |
73 | | - cd python |
74 | | - ${PYTHON} -VV |
75 | | - # For some reason I can't work out the C compiler is not following symlinks |
76 | | - rm -r lib |
77 | | - mkdir lib |
78 | | - cp -r --dereference ../c/subprojects lib/. |
79 | | - cp -r --dereference ../c/tskit lib/. |
80 | | - cp ../c/tskit.h lib/. |
81 | | - ${PYTHON} -m build --wheel |
82 | | - - name: Upload Wheels |
83 | | - uses: actions/upload-artifact@v6.0.0 |
84 | | - with: |
85 | | - name: win-wheel-${{ matrix.python }}-${{ matrix.wordsize }} |
86 | | - path: python/dist |
87 | | - |
88 | | - manylinux: |
89 | | - runs-on: ubuntu-24.04 |
90 | | - steps: |
91 | | - - name: Checkout |
92 | | - uses: actions/checkout@v6.0.2 |
93 | | - |
94 | | - - name: Set up Python 3.11 |
95 | | - uses: actions/setup-python@v6.1.0 |
96 | | - with: |
97 | | - python-version: 3.11 |
98 | | - |
99 | | - - name: Build sdist |
100 | | - shell: bash |
101 | | - run: | |
102 | | - cd python |
103 | | - python -m pip install build |
104 | | - python -m build --sdist |
105 | | -
|
106 | | - - name: Upload sdist |
107 | | - uses: actions/upload-artifact@v6.0.0 |
108 | | - with: |
109 | | - name: sdist |
110 | | - path: python/dist |
111 | | - |
112 | | - - name: Build wheels in docker |
113 | | - shell: bash |
114 | | - run: | |
115 | | - docker run --rm -v `pwd`:/project -w /project quay.io/pypa/manylinux2014_x86_64 bash .github/workflows/docker/buildwheel.sh |
116 | | -
|
117 | | - - name: Upload Wheels |
118 | | - uses: actions/upload-artifact@v6.0.0 |
119 | | - with: |
120 | | - name: linux-wheels |
121 | | - path: python/dist/wheelhouse |
122 | | - |
123 | | - OSX-test: |
124 | | - needs: ['OSX'] |
125 | | - strategy: |
126 | | - fail-fast: false |
127 | | - matrix: |
128 | | - python: [3.11, 3.12, 3.13, 3.14] |
129 | | - runner: [macos-15, macos-15-intel] |
130 | | - include: |
131 | | - - runner: macos-15 |
132 | | - arch: arm64 |
133 | | - - runner: macos-15-intel |
134 | | - arch: x86_64 |
135 | | - runs-on: ${{ matrix.runner }} |
136 | | - steps: |
137 | | - - name: Download wheels |
138 | | - uses: actions/download-artifact@v7.0.0 |
139 | | - with: |
140 | | - name: osx-wheel-${{ matrix.python }} |
141 | | - - name: Set up Python ${{ matrix.python }} |
142 | | - uses: actions/setup-python@v6.1.0 |
143 | | - with: |
144 | | - python-version: ${{ matrix.python }} |
145 | | - - name: Verify architecture |
146 | | - run: | |
147 | | - arch_name=$(uname -m) |
148 | | - echo "Running on architecture: $arch_name" |
149 | | - if [[ "$arch_name" != "${{ matrix.arch }}" ]]; then |
150 | | - echo "Error: Expected ${{ matrix.arch }} but got $arch_name" |
151 | | - exit 1 |
152 | | - fi |
153 | | - - name: Install wheel and test |
154 | | - run: | |
155 | | - python -VV |
156 | | - # Install the local wheel |
157 | | - pip install ./tskit-*.whl |
158 | | - python -c "import tskit; import platform; print(f'Running on {platform.machine()} architecture')" |
159 | | -
|
160 | | - windows-test: |
161 | | - needs: ['windows'] |
162 | | - runs-on: windows-latest |
163 | | - strategy: |
164 | | - fail-fast: false |
165 | | - matrix: |
166 | | - python: [3.11, 3.12, 3.13, 3.14] |
167 | | - wordsize: [64] |
168 | | - steps: |
169 | | - - name: Download wheels |
170 | | - uses: actions/download-artifact@v7.0.0 |
171 | | - with: |
172 | | - name: win-wheel-${{ matrix.python }}-${{ matrix.wordsize }} |
173 | | - - name: Set up Python ${{ matrix.python }} |
174 | | - uses: actions/setup-python@v6.1.0 |
175 | | - with: |
176 | | - python-version: ${{ matrix.python }} |
177 | | - - name: Install wheel and test |
178 | | - shell: bash |
179 | | - run: | |
180 | | - python -VV |
181 | | - # Install the local wheel |
182 | | - python -m pip install *.whl |
183 | | - python -c "import tskit" |
184 | | -
|
185 | | - manylinux-test: |
186 | | - runs-on: ubuntu-24.04 |
187 | | - needs: ['manylinux'] |
188 | | - strategy: |
189 | | - fail-fast: false |
190 | | - matrix: |
191 | | - python: [3.11, 3.12, 3.13, 3.14] |
192 | | - include: |
193 | | - - python: 3.11 |
194 | | - wheel: cp311 |
195 | | - - python: 3.12 |
196 | | - wheel: cp312 |
197 | | - - python: 3.13 |
198 | | - wheel: cp313 |
199 | | - - python: 3.14 |
200 | | - wheel: cp314 |
201 | | - steps: |
202 | | - - name: Download wheels |
203 | | - uses: actions/download-artifact@v7.0.0 |
204 | | - with: |
205 | | - name: linux-wheels |
206 | | - - name: Set up Python |
207 | | - uses: actions/setup-python@v6.1.0 |
208 | | - with: |
209 | | - python-version: ${{ matrix.python }} |
210 | | - - name: Install wheel and test |
211 | | - run: | |
212 | | - python -VV |
213 | | - # Install the local wheel |
214 | | - pip install ./tskit-*-${{ matrix.wheel }}-*.whl |
215 | | - python -c "import tskit" |
216 | | -
|
217 | | - PyPI_Upload: |
| 15 | + publish: |
218 | 16 | runs-on: ubuntu-24.04 |
219 | 17 | environment: release |
220 | | - needs: ['windows-test', 'OSX-test', 'manylinux-test'] |
| 18 | + needs: [ 'build-wheels' ] |
221 | 19 | permissions: |
222 | 20 | id-token: write |
223 | 21 | steps: |
224 | | - - name: Download all |
| 22 | + - name: Download artifacts |
225 | 23 | uses: actions/download-artifact@v7.0.0 |
226 | | - - name: Move to dist |
227 | | - run: | |
228 | | - mkdir dist |
229 | | - cp */*.{whl,gz} dist/. |
| 24 | + with: |
| 25 | + pattern: build-* |
| 26 | + path: dist |
| 27 | + merge-multiple: true |
| 28 | + |
| 29 | + - name: Show artifacts |
| 30 | + run: ls -lah dist |
| 31 | + |
230 | 32 | - name: Publish distribution to Test PyPI |
231 | | - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && !contains(github.event.ref, 'C_') |
| 33 | + if: github.event_name == 'push' && github.ref_name == 'test-publish' |
232 | 34 | uses: pypa/gh-action-pypi-publish@v1.13.0 |
233 | 35 | with: |
234 | | - repository_url: https://test.pypi.org/legacy/ |
235 | | - - name: Publish distribution to PRODUCTION PyPI |
236 | | - if: github.event_name == 'release' && !startsWith(github.event.release.tag_name, 'C_') |
| 36 | + repository-url: https://test.pypi.org/legacy/ |
| 37 | + verbose: true |
| 38 | + |
| 39 | + - name: Publish distribution to Production PyPI |
| 40 | + if: github.event_name == 'release' |
237 | 41 | uses: pypa/gh-action-pypi-publish@v1.13.0 |
0 commit comments