-
Notifications
You must be signed in to change notification settings - Fork 64
141 lines (125 loc) · 3.96 KB
/
Copy pathpublish-to-pypi.yml
File metadata and controls
141 lines (125 loc) · 3.96 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
name: Build and publish Python 🐍 distributions 📦 to PyPI
on:
release:
types: [published]
pull_request:
branches:
- main
workflow_dispatch:
env:
LSL_RELEASE_URL: "https://github.com/sccn/liblsl/releases/download/v1.17.4"
LSL_RELEASE: "1.17.4"
defaults:
run:
shell: bash
jobs:
# Build pure Python wheel (no bundled library) as fallback
build-pure:
name: Build pure Python wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for setuptools-scm
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Build pure Python wheel
run: uv build
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-pure
path: dist/*
# Build platform-specific wheels with bundled liblsl
build-platform:
name: Build ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: "Windows x64"
os: windows-latest
arch: amd64
pyarch: x64
asset: "liblsl-${LSL_RELEASE}-Win_amd64.zip"
extract: "unzip -oj liblsl.zip '*/bin/lsl.dll' -d src/pylsl/lib"
- name: "Windows x86"
os: windows-latest
arch: i386
pyarch: x86
asset: "liblsl-${LSL_RELEASE}-Win_i386.zip"
extract: "unzip -oj liblsl.zip '*/bin/lsl.dll' -d src/pylsl/lib"
- name: "macOS universal"
os: macos-latest
arch: universal
pyarch: x64
asset: "lsl.xcframework.1.17.zip"
extract: |
unzip xcframework.zip
cp lsl.xcframework/macos-arm64_x86_64/lsl.framework/Versions/A/lsl src/pylsl/lib/liblsl.dylib
codesign -s - -f src/pylsl/lib/liblsl.dylib
- name: "Linux x86_64"
os: ubuntu-latest
arch: x86_64
pyarch: x64
asset: "liblsl-${LSL_RELEASE}-noble_amd64.tar.gz"
extract: |
tar -xzf liblsl.tar.gz
cp liblsl-${LSL_RELEASE}-noble_amd64/lib/liblsl.so* src/pylsl/lib/
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for setuptools-scm
- name: Download liblsl
run: |
ASSET="${{ matrix.config.asset }}"
ASSET="${ASSET//\$\{LSL_RELEASE\}/$LSL_RELEASE}"
if [[ "$ASSET" == *xcframework* ]]; then
curl -L "${LSL_RELEASE_URL}/${ASSET}" -o xcframework.zip
elif [[ "$ASSET" == *.zip ]]; then
curl -L "${LSL_RELEASE_URL}/${ASSET}" -o liblsl.zip
else
curl -L "${LSL_RELEASE_URL}/${ASSET}" -o liblsl.tar.gz
fi
- name: Extract liblsl
run: |
mkdir -p src/pylsl/lib
${{ matrix.config.extract }}
- name: List bundled library
run: ls -la src/pylsl/lib/
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
architecture: ${{ matrix.config.pyarch }}
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Build wheel
run: uv build --wheel
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.config.os }}-${{ matrix.config.arch }}
path: dist/*.whl
# Publish all wheels to PyPI
publish:
name: Publish to PyPI
needs: [build-pure, build-platform]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
path: dist
pattern: wheels-*
merge-multiple: true
- name: List wheels
run: ls -la dist/
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Publish to PyPI
if: github.event_name == 'release'
run: uv publish dist/*