Skip to content

Commit aea5a0c

Browse files
committed
Add CI workflows for build testing and PyPI publishing
- build.yml: Test building on Python 3.10-3.13, verify installation - publish.yml: Publish to PyPI on GitHub releases using trusted publishing
1 parent 8a9d7d7 commit aea5a0c

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
name: Build on Python ${{ matrix.python-version }}
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ['3.10', '3.11', '3.12', '3.13']
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install build dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install build twine
29+
30+
- name: Build package
31+
run: python -m build
32+
33+
- name: Check distribution
34+
run: twine check dist/*
35+
36+
- name: Install from wheel
37+
run: pip install dist/*.whl
38+
39+
- name: Verify installation
40+
run: |
41+
python -c "import skbuild_conditional_scripts; print('Package imported successfully')"
42+
python -c "from skbuild_conditional_scripts import dynamic_metadata; print('Function imported successfully')"
43+
44+
- name: Upload artifacts
45+
if: matrix.python-version == '3.12'
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: distributions
49+
path: dist/

.github/workflows/publish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build-and-publish:
9+
name: Build and publish to PyPI
10+
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write # Required for trusted publishing
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.12'
21+
22+
- name: Install build dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install build
26+
27+
- name: Build package
28+
run: python -m build
29+
30+
- name: Publish to PyPI
31+
uses: pypa/gh-action-pypi-publish@release/v1
32+
# This uses PyPI's trusted publisher (no token needed)
33+
# Configure at: https://pypi.org/manage/account/publishing/

0 commit comments

Comments
 (0)