Skip to content

Commit 09a8364

Browse files
committed
Update python-package.yml
1 parent cf51c1f commit 09a8364

File tree

1 file changed

+45
-53
lines changed

1 file changed

+45
-53
lines changed

.github/workflows/python-package.yml

Lines changed: 45 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,26 @@ name: Build, validate & Release
22

33
on:
44
push:
5-
tags:
6-
- 'v*.*.*'
5+
tags: [ 'v*.*.*' ]
76
pull_request:
8-
branches:
9-
- main
10-
- public
11-
types:
12-
- labeled
13-
- opened
14-
- edited
15-
- synchronize
16-
- reopened
7+
branches: [ main, public ]
8+
types: [ labeled, opened, edited, synchronize, reopened ]
179

1810
jobs:
19-
build_check:
20-
name: Build & validate package
11+
test:
12+
name: Test / smoke (matrix)
2113
runs-on: ubuntu-latest
2214
strategy:
2315
fail-fast: false
2416
matrix:
25-
python-version: [ "3.10", "3.11", "3.12" ] # adjust to what you support
17+
python-version: [ "3.10", "3.11", "3.12" ]
2618
steps:
27-
- name: Checkout
28-
uses: actions/checkout@v6
29-
30-
- name: Setup Python ${{ matrix.python-version }}
31-
uses: actions/setup-python@v6
19+
- uses: actions/checkout@v6
20+
- uses: actions/setup-python@v6
3221
with:
3322
python-version: ${{ matrix.python-version }}
3423

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
24+
- name: Install tools
4625
run: |
4726
python -m pip install --upgrade pip
4827
python -m pip install build twine wheel "packaging>=24.2"
@@ -61,50 +40,63 @@ jobs:
6140

6241
- name: Install from wheel & smoke test
6342
run: |
64-
# Install from the built wheel (not from the source tree)
6543
python -m pip install dist/*.whl
66-
6744
python - <<'PY'
6845
import importlib
69-
pkg_name = "dlclivegui" # change if your top-level import differs
46+
pkg_name = "dlclivegui"
7047
m = importlib.import_module(pkg_name)
7148
print("Imported:", m.__name__, "version:", getattr(m, "__version__", "n/a"))
7249
PY
7350
7451
if ! command -v dlclivegui >/dev/null 2>&1; then
75-
echo "CLI entry point 'dlclivegui' not found in PATH; skipping CLI smoke test."
52+
echo "CLI entry point 'dlclivegui' not found in PATH; skipping CLI smoke test."
7653
else
54+
if command -v dlclivegui >/dev/null 2>&1; then
7755
echo "Running 'dlclivegui --help' smoke test..."
7856
if ! dlclivegui --help >/dev/null 2>&1; then
7957
echo "::error::'dlclivegui --help' failed; this indicates a problem with the installed CLI package."
8058
exit 1
8159
fi
82-
fi
8360
84-
publish:
85-
name: Publish to PyPI
61+
build:
62+
name: Build release artifacts (single)
8663
runs-on: ubuntu-latest
87-
needs: build_check
88-
if: ${{ startsWith(github.ref, 'refs/tags/v') }} # only on tag pushes like v1.2.3
64+
needs: test
65+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
8966
steps:
90-
- name: Checkout
91-
uses: actions/checkout@v6
92-
93-
- name: Setup Python
94-
uses: actions/setup-python@v6
67+
- uses: actions/checkout@v6
68+
- uses: actions/setup-python@v6
9569
with:
96-
python-version: "3.x"
70+
python-version: "3.12"
9771

98-
- name: Install build tools
72+
- name: Build distributions (sdist + wheel)
9973
run: |
10074
python -m pip install --upgrade pip
101-
python -m pip install build twine
75+
python -m pip install build twine wheel "packaging>=24.2"
76+
python -m build
77+
python -m twine check dist/*
10278
103-
- name: Build distributions (sdist + wheel)
104-
run: python -m build
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
105100

106101
- name: Publish to PyPI
107-
env:
108-
TWINE_USERNAME: __token__
109-
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
110-
run: python -m twine upload --verbose dist/*
102+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)