-
Notifications
You must be signed in to change notification settings - Fork 79
146 lines (123 loc) · 4.15 KB
/
python-module.yml
File metadata and controls
146 lines (123 loc) · 4.15 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
name: Build Python Module
on:
push:
branches:
- master
- develop
- "release/*"
tags:
- "*.*.*"
pull_request:
branches:
- master
- develop
- "release/*"
workflow_dispatch:
env:
DRY_RUN: ${{ !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) }}
jobs:
build-wheels:
name: Build Wheels
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
python-version: ["3.11", "3.12", "3.13", "3.14"]
outputs:
dist-paths: ${{ steps.upload-artifacts.outputs.dist-paths }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install system dependencies
if: runner.os != 'Windows'
run: |
sudo apt-get update || brew update
sudo apt-get install -y libsamplerate0-dev || brew install libsamplerate
- name: Install vcpkg dependencies
if: runner.os == 'Windows'
run: |
git clone https://github.com/microsoft/vcpkg.git vcpkg
.\vcpkg\bootstrap-vcpkg.bat
.\vcpkg\vcpkg install libsamplerate:x64-windows
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade build tools
run: |
python -m pip install --upgrade pip setuptools wheel twine build scikit-build-core pybind11 numpy
# ---------------------------
# Dry-run version bump
# ---------------------------
- name: Bump version for Test PyPI
if: env.DRY_RUN == 'true'
working-directory: plugins/python-module
shell: bash
run: |
python - <<EOF
from pathlib import Path
import re, tomllib
path = Path("pyproject.toml")
data = tomllib.loads(path.read_text())
base = data["project"]["version"]
new = f"{base}.post0.dev{${{ github.run_number }}}"
text = re.sub(r'version\\s*=\\s*".*"', f'version = "{new}"', path.read_text())
path.write_text(text)
EOF
- name: Build distributions (Windows)
if: runner.os == 'Windows'
working-directory: plugins/python-module
run: |
python -m build --wheel --sdist
env:
CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}\vcpkg\scripts\buildsystems\vcpkg.cmake
- name: Build distributions
if: runner.os != 'Windows'
working-directory: plugins/python-module
run: |
python -m build --wheel --sdist
- name: Install built wheel
working-directory: plugins/python-module
run: |
python -m pip install dist/*.whl
- name: Run Python sanity tests
working-directory: plugins/python-module
run: |
python -m pip install pytest
pytest -q
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: btrack-wheels-${{ matrix.os }}-py${{ matrix.python-version }}
path: plugins/python-module/dist/*
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: build-wheels
if: >
startsWith(github.ref, 'refs/heads/release/') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
steps:
- name: Download all built wheels
uses: actions/download-artifact@v4
with:
path: dist/
- name: Flatten wheel artifacts
run: |
mkdir -p files-to-upload
find dist -type f \( -name "*.whl" -o -name "*.tar.gz" \) -exec mv {} files-to-upload/ \;
- name: Install twine
run: |
python -m pip install --upgrade pip twine
- name: Publish to Test PyPI
if: env.DRY_RUN == 'true'
run: python -m twine upload --repository testpypi files-to-upload/* --verbose
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
- name: Publish to Production PyPI
if: env.DRY_RUN == 'false'
run: python -m twine upload files-to-upload/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}