Skip to content

Commit 7e1811d

Browse files
authored
Create build_dev.yml
1 parent 8caf6cd commit 7e1811d

File tree

1 file changed

+230
-0
lines changed

1 file changed

+230
-0
lines changed

.github/workflows/build_dev.yml

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
name: Build [test]
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
build_type:
6+
description: 'Type of build to run'
7+
required: true
8+
default: 'all'
9+
type: choice
10+
options:
11+
- all
12+
- wheels
13+
- sdist
14+
create_release:
15+
description: 'Create a new release'
16+
required: true
17+
type: boolean
18+
default: false
19+
upload_to_pypi:
20+
description: 'Upload to PyPI'
21+
required: true
22+
type: boolean
23+
default: false
24+
25+
permissions:
26+
contents: read
27+
28+
jobs:
29+
extract_version:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
version: ${{ steps.get_version.outputs.VERSION }}
33+
permissions:
34+
contents: read
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Set up Python
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: '3.12'
41+
- name: Install dependencies
42+
run: |
43+
python -m pip install --upgrade pip
44+
python -m pip install toml
45+
- name: Get version from pyproject.toml
46+
id: get_version
47+
run: |
48+
VERSION=$(python -c "
49+
import toml
50+
import sys
51+
try:
52+
data = toml.load('pyproject.toml')
53+
if 'tool' in data and 'poetry' in data['tool']:
54+
version = data['tool']['poetry']['version']
55+
elif 'project' in data:
56+
version = data['project']['version']
57+
else:
58+
raise KeyError('Unable to find version in pyproject.toml')
59+
print(version)
60+
except Exception as e:
61+
print(f'Error: {str(e)}', file=sys.stderr)
62+
sys.exit(1)
63+
")
64+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
65+
66+
build_wheels:
67+
name: Build wheel ${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}
68+
runs-on: ${{ matrix.buildplat[0] }}
69+
permissions:
70+
contents: read
71+
if: github.event.inputs.build_type == 'all' || github.event.inputs.build_type == 'wheels'
72+
strategy:
73+
fail-fast: false
74+
matrix:
75+
buildplat:
76+
- [ubuntu-22.04, manylinux_x86_64, ""]
77+
- [ubuntu-22.04, musllinux_x86_64, ""]
78+
- [macos-13, macosx_x86_64, openblas]
79+
- [macos-13, macosx_x86_64, accelerate]
80+
- [macos-14, macosx_arm64, accelerate]
81+
- [windows-2019, win_amd64, ""]
82+
- [windows-2019, win32, ""]
83+
python: ["cp310", "cp311", "cp312", "pp310", "cp313", "cp313t"]
84+
exclude:
85+
- buildplat: [windows-2019, win32, ""]
86+
python: "pp310"
87+
- buildplat: [ ubuntu-22.04, musllinux_x86_64, "" ]
88+
python: "pp310"
89+
- buildplat: [ macos-14, macosx_arm64, accelerate ]
90+
python: "pp310"
91+
- buildplat: [ windows-2019, win_amd64, "" ]
92+
python: "cp313t"
93+
- buildplat: [ windows-2019, win32, "" ]
94+
python: "cp313t"
95+
- buildplat: [ macos-13, macosx_x86_64, openblas]
96+
python: "cp313t"
97+
98+
steps:
99+
- uses: actions/checkout@v4
100+
101+
- name: Setup MSVC (32-bit)
102+
if: ${{ matrix.buildplat[1] == 'win32' }}
103+
uses: bus1/cabuild/action/msdevshell@e22aba57d6e74891d059d66501b6b5aed8123c4d # v1
104+
with:
105+
architecture: 'x86'
106+
107+
- name: Set up Python
108+
uses: actions/setup-python@v3
109+
with:
110+
python-version: '3.x'
111+
112+
113+
- name: Install cibuildwheel
114+
run: |
115+
python -m pip install --upgrade pip
116+
python -m pip install cibuildwheel==2.22.0
117+
118+
- name: Build wheel
119+
uses: pypa/cibuildwheel@ee63bf16da6cddfb925f542f2c7b59ad50e93969 # 2.22
120+
env:
121+
CIBW_PRERELEASE_PYTHONS: True
122+
CIBW_FREE_THREADED_SUPPORT: True
123+
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
124+
125+
- name: install wheel
126+
shell: bash
127+
run: |
128+
python -m pip install ./wheelhouse/*-${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}.whl
129+
130+
- name: Test package import and basic functionality
131+
shell: python
132+
run: |
133+
import sudio
134+
from sudio import Master
135+
136+
# Example basic tests
137+
print("Sudio version:", sudio.__version__)
138+
139+
# Attempt to create a Master instance
140+
master = Master()
141+
print("Master instance created successfully")
142+
143+
- uses: actions/upload-artifact@v3
144+
with:
145+
name: ${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}
146+
path: ./wheelhouse/*.whl
147+
148+
build_sdist:
149+
name: Build sdist
150+
runs-on: ubuntu-latest
151+
permissions:
152+
contents: read
153+
if: github.event.inputs.build_type == 'all' || github.event.inputs.build_type == 'sdist'
154+
155+
steps:
156+
- uses: actions/checkout@v4
157+
- name: Set up Python
158+
uses: actions/setup-python@v3
159+
with:
160+
python-version: '3.11'
161+
162+
- name: Build sdist
163+
run: |
164+
python -m pip install -U pip build
165+
python -m build --sdist -Csetup-args=-Dallow-noblas=true
166+
167+
- name: Check README rendering for PyPI
168+
run: |
169+
python -m pip install twine
170+
twine check dist/*
171+
172+
- uses: actions/upload-artifact@v3
173+
with:
174+
path: ./dist/*
175+
176+
upload_pypi:
177+
needs: [build_wheels, build_sdist]
178+
runs-on: ubuntu-latest
179+
permissions:
180+
id-token: write
181+
if: github.event.inputs.upload_to_pypi == 'true'
182+
steps:
183+
- uses: actions/download-artifact@v3
184+
with:
185+
name: artifact
186+
path: dist
187+
188+
- name: List Build contents
189+
run: ls -l dist
190+
191+
- uses: pypa/gh-action-pypi-publish@release/v1
192+
with:
193+
user: __token__
194+
password: ${{ secrets.PYPI_TOKEN }}
195+
skip_existing: true
196+
197+
create_release:
198+
needs: [extract_version, build_wheels, build_sdist, upload_pypi]
199+
runs-on: ubuntu-latest
200+
permissions:
201+
contents: write
202+
if: github.event.inputs.create_release == 'true'
203+
steps:
204+
- uses: actions/checkout@v4
205+
- name: Download all artifacts
206+
uses: actions/download-artifact@v3
207+
with:
208+
name: artifact
209+
path: dist
210+
- name: Create and push tag
211+
run: |
212+
git config user.name github-actions
213+
git config user.email [email protected]
214+
git tag v${{ needs.extract_version.outputs.version }}
215+
git push origin v${{ needs.extract_version.outputs.version }}
216+
- name: Create Release
217+
id: create_release
218+
uses: softprops/action-gh-release@v1
219+
with:
220+
tag_name: v${{ needs.extract_version.outputs.version }}
221+
name: Release v${{ needs.extract_version.outputs.version }}
222+
draft: false
223+
prerelease: false
224+
generate_release_notes: true
225+
files: |
226+
dist/**/*.whl
227+
dist/**/*.tar.gz
228+
env:
229+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
230+

0 commit comments

Comments
 (0)