@@ -2,26 +2,47 @@ name: Build, validate & Release
22
33on :
44 push :
5- tags : [ 'v*.*.*' ]
5+ tags :
6+ - ' v*.*.*'
67 pull_request :
7- branches : [ main, public ]
8- types : [ labeled, opened, edited, synchronize, reopened ]
8+ branches :
9+ - main
10+ - public
11+ types :
12+ - labeled
13+ - opened
14+ - edited
15+ - synchronize
16+ - reopened
917
1018jobs :
11- test :
12- name : Test / smoke (matrix)
19+ build_check :
20+ name : Build & validate package
1321 runs-on : ubuntu-latest
1422 strategy :
1523 fail-fast : false
1624 matrix :
17- python-version : [ "3.10", "3.11", "3.12" ]
25+ python-version : [ "3.10", "3.11", "3.12" ] # adjust to what you support
1826 steps :
19- - uses : actions/checkout@v6
20- - uses : actions/setup-python@v6
27+ - name : Checkout
28+ uses : actions/checkout@v6
29+
30+ - name : Setup Python ${{ matrix.python-version }}
31+ uses : actions/setup-python@v6
2132 with :
2233 python-version : ${{ matrix.python-version }}
2334
24- - name : Install tools
35+ # If we use UV later, the lock file should be included here for caching and validation
36+ - name : Cache pip
37+ uses : actions/cache@v4
38+ with :
39+ path : ~/.cache/pip
40+ key : ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml', 'setup.cfg', 'setup.py', 'requirements.txt') }}
41+ restore-keys : |
42+ ${{ runner.os }}-pip-${{ matrix.python-version }}-
43+ ${{ runner.os }}-pip-
44+
45+ - name : Install build tools
2546 run : |
2647 python -m pip install --upgrade pip
2748 python -m pip install build twine wheel "packaging>=24.2"
@@ -40,63 +61,50 @@ jobs:
4061
4162 - name : Install from wheel & smoke test
4263 run : |
64+ # Install from the built wheel (not from the source tree)
4365 python -m pip install dist/*.whl
66+
4467 python - <<'PY'
4568 import importlib
46- pkg_name = "dlclivegui"
69+ pkg_name = "dlclivegui" # change if your top-level import differs
4770 m = importlib.import_module(pkg_name)
4871 print("Imported:", m.__name__, "version:", getattr(m, "__version__", "n/a"))
4972 PY
5073
5174 if ! command -v dlclivegui >/dev/null 2>&1; then
52- echo "CLI entry point 'dlclivegui' not found in PATH; skipping CLI smoke test."
75+ echo "CLI entry point 'dlclivegui' not found in PATH; skipping CLI smoke test."
5376 else
54- if command -v dlclivegui >/dev/null 2>&1; then
5577 echo "Running 'dlclivegui --help' smoke test..."
5678 if ! dlclivegui --help >/dev/null 2>&1; then
5779 echo "::error::'dlclivegui --help' failed; this indicates a problem with the installed CLI package."
5880 exit 1
5981 fi
82+ fi
6083
61- build :
62- name : Build release artifacts (single)
84+ publish :
85+ name : Publish to PyPI
6386 runs-on : ubuntu-latest
64- needs : test
65- if : ${{ startsWith(github.ref, 'refs/tags/v') }}
87+ needs : build_check
88+ if : ${{ startsWith(github.ref, 'refs/tags/v') }} # only on tag pushes like v1.2.3
6689 steps :
67- - uses : actions/checkout@v6
68- - uses : actions/setup-python@v6
90+ - name : Checkout
91+ uses : actions/checkout@v6
92+
93+ - name : Setup Python
94+ uses : actions/setup-python@v6
6995 with :
70- python-version : " 3.12 "
96+ python-version : " 3.x "
7197
72- - name : Build distributions (sdist + wheel)
98+ - name : Install build tools
7399 run : |
74100 python -m pip install --upgrade pip
75- python -m pip install build twine wheel "packaging>=24.2"
76- python -m build
77- python -m twine check dist/*
101+ python -m pip install build twine
78102
79- - name : Upload dist artifacts
80- uses : actions/upload-artifact@v4
81- with :
82- name : dist
83- path : dist/*
84- if-no-files-found : error
85-
86- publish :
87- name : Publish to PyPI (OIDC)
88- runs-on : ubuntu-latest
89- needs : build
90- if : ${{ startsWith(github.ref, 'refs/tags/v') }}
91- environment : pypi
92- permissions :
93- id-token : write
94- steps :
95- - name : Download dist artifacts
96- uses : actions/download-artifact@v4
97- with :
98- name : dist
99- path : dist
103+ - name : Build distributions (sdist + wheel)
104+ run : python -m build
100105
101106 - name : Publish to PyPI
102- uses : pypa/gh-action-pypi-publish@release/v1
107+ env :
108+ TWINE_USERNAME : __token__
109+ TWINE_PASSWORD : ${{ secrets.TWINE_API_KEY }}
110+ run : python -m twine upload --verbose dist/*
0 commit comments