-
Notifications
You must be signed in to change notification settings - Fork 42
152 lines (138 loc) · 4.74 KB
/
publish.yml
File metadata and controls
152 lines (138 loc) · 4.74 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
name: Publish quantcpp to PyPI
on:
push:
tags:
- 'v*'
- 'pypi-v*'
workflow_dispatch:
inputs:
target:
description: 'Where to publish'
required: true
default: 'testpypi'
type: choice
options:
- testpypi
- pypi
jobs:
# ---------------------------------------------------------------------
# Build platform-specific wheels via cibuildwheel
# ---------------------------------------------------------------------
build_wheels:
name: Wheels on ${{ matrix.os }} (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: x86_64
- os: ubuntu-24.04-arm # Native ARM runner (free, no QEMU)
arch: aarch64
- os: macos-14 # Apple Silicon (M-series). Intel macs deferred.
arch: arm64
# Windows mingw64 wheel is deferred — quant.h's clock_gettime shim
# conflicts with mingw's native one. Windows users install via sdist
# with MSVC for now. Tracked for v0.8.x.
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# cibuildwheel mounts only the package-dir into Linux build containers,
# so quant.h must already live inside bindings/python/ before invoke.
# We stage it as bindings/python/quant.h (NOT inside quantcpp/, which
# is .gitignore'd and would be excluded by isolated source copies).
- name: Bundle quant.h into package
shell: bash
run: cp quant.h bindings/python/quant.h
- name: Build wheels
uses: pypa/cibuildwheel@v2.21.3
with:
package-dir: bindings/python
output-dir: wheelhouse
env:
CIBW_ARCHS: ${{ matrix.arch }}
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.arch }}
path: ./wheelhouse/*.whl
if-no-files-found: error
# ---------------------------------------------------------------------
# Build the source distribution
# ---------------------------------------------------------------------
build_sdist:
name: Source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Bundle quant.h into package
shell: bash
run: cp quant.h bindings/python/quant.h
- name: Build sdist
run: |
cd bindings/python
python -m pip install --upgrade pip build
python -m build --sdist
- name: Smoke-test sdist install (clean venv)
run: |
python -m venv /tmp/sdist-test
/tmp/sdist-test/bin/pip install bindings/python/dist/quantcpp-*.tar.gz
cd /tmp
/tmp/sdist-test/bin/python -c "import quantcpp; from quantcpp._binding import get_lib; print('sdist OK:', quantcpp.__version__, get_lib().quant_version().decode())"
- uses: actions/upload-artifact@v4
with:
name: sdist
path: bindings/python/dist/*.tar.gz
if-no-files-found: error
# ---------------------------------------------------------------------
# Publish — Trusted Publishing (OIDC), no API token needed
# ---------------------------------------------------------------------
publish_testpypi:
name: Publish to TestPyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'testpypi'
environment:
name: testpypi
url: https://test.pypi.org/p/quantcpp
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List artifacts
run: ls -la dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
publish_pypi:
name: Publish to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
# Auto-publish on tag push, OR manual dispatch with target=pypi
if: |
startsWith(github.ref, 'refs/tags/') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'pypi')
environment:
name: pypi
url: https://pypi.org/p/quantcpp
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List artifacts
run: ls -la dist/
- uses: pypa/gh-action-pypi-publish@release/v1