Skip to content

Commit 1cc7801

Browse files
committed
CI: build, validate & release Python package
Rename workflow and split into a build/validate job and a gated publish job. Add a Python matrix (3.10–3.12), cache keyed by matrix python-version, and update checkout/setup/cache action usages. Build sdist/wheel, run twine check, inspect dist contents, and perform a smoke install from the built wheel (with a best-effort CLI check). Publish step now runs only for tag pushes like vX.Y.Z and uploads with twine using the TWINE_API_KEY secret.
1 parent 05497e8 commit 1cc7801

1 file changed

Lines changed: 67 additions & 24 deletions

File tree

Lines changed: 67 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Update pypi release
1+
name: Build, validate & Release
22

33
on:
44
push:
@@ -16,44 +16,87 @@ on:
1616
- reopened
1717

1818
jobs:
19-
release:
19+
build_check:
20+
name: Build & validate package
2021
runs-on: ubuntu-latest
21-
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
python-version: [ "3.10", "3.11", "3.12" ] # adjust to what you support
2226
steps:
23-
- name: Setup Python
24-
id: setup-python
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Python ${{ matrix.python-version }}
2531
uses: actions/setup-python@v5
2632
with:
27-
python-version: '3.x'
33+
python-version: ${{ matrix.python-version }}
2834

29-
- name: Cache dependencies
30-
id: pip-cache
35+
- name: Cache pip
3136
uses: actions/cache@v4
3237
with:
3338
path: ~/.cache/pip
34-
key: ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements.txt', 'setup.cfg', 'setup.py') }}
39+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml', 'setup.cfg', 'setup.py', 'requirements.txt') }}
3540
restore-keys: |
36-
${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }}-
41+
${{ runner.os }}-pip-${{ matrix.python-version }}-
3742
${{ runner.os }}-pip-
3843
39-
- name: Install dependencies
44+
- name: Install build tools
4045
run: |
41-
pip install --upgrade pip
42-
pip install wheel
43-
pip install "packaging>=24.2"
44-
pip install build
45-
pip install twine
46+
python -m pip install --upgrade pip
47+
python -m pip install build twine wheel "packaging>=24.2"
48+
49+
- name: Build distributions (sdist + wheel)
50+
run: python -m build
51+
52+
- name: Inspect dist
53+
run: |
54+
ls -lah dist/
55+
echo "sdist contents (first ~200 entries):"
56+
tar -tf dist/*.tar.gz | sed -n '1,200p'
57+
58+
- name: Twine metadata & README check
59+
run: python -m twine check dist/*
60+
61+
- name: Install from wheel & smoke test
62+
run: |
63+
# Install from the built wheel (not from the source tree)
64+
python -m pip install --no-deps dist/*.whl
65+
66+
python - <<'PY'
67+
import importlib
68+
pkg_name = "dlclivegui" # change if your top-level import differs
69+
m = importlib.import_module(pkg_name)
70+
print("Imported:", m.__name__, "version:", getattr(m, "__version__", "n/a"))
71+
PY
4672
47-
- name: Checkout code
73+
# Console entry point best-effort check (adjust name if different)
74+
(command -v dlclivegui && dlclivegui --help) || echo "CLI not available or returned non-zero; continuing."
75+
76+
publish:
77+
name: Publish to PyPI
78+
runs-on: ubuntu-latest
79+
needs: build_check
80+
if: ${{ startsWith(github.ref, 'refs/tags/v') }} # only on tag pushes like v1.2.3
81+
steps:
82+
- name: Checkout
4883
uses: actions/checkout@v4
4984

50-
- name: Build and publish to PyPI
51-
if: ${{ github.event_name == 'push' }}
85+
- name: Setup Python
86+
uses: actions/setup-python@v5
87+
with:
88+
python-version: "3.x"
89+
90+
- name: Install build tools
91+
run: |
92+
python -m pip install --upgrade pip
93+
python -m pip install build twine
94+
95+
- name: Build distributions (sdist + wheel)
96+
run: python -m build
97+
98+
- name: Publish to PyPI
5299
env:
53100
TWINE_USERNAME: __token__
54101
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
55-
run: |
56-
python -m build
57-
ls dist/
58-
tar tvf dist/*.tar.gz
59-
python3 -m twine upload --verbose dist/*
102+
run: python -m twine upload --verbose dist/*

0 commit comments

Comments
 (0)