-
Notifications
You must be signed in to change notification settings - Fork 26
103 lines (87 loc) · 2.97 KB
/
python-package.yml
File metadata and controls
103 lines (87 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Build, validate & Release
on:
push:
tags:
- 'v*.*.*'
pull_request:
branches:
- main
- public
types:
- labeled
- opened
- edited
- synchronize
- reopened
jobs:
build_check:
name: Build & validate package
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.10", "3.11", "3.12" ] # adjust to what you support
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# If we use UV later, the lock file should be included here for caching and validation
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml', 'setup.cfg', 'setup.py', 'requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
- name: Install build tools
run: |
python -m pip install --upgrade pip
python -m pip install build twine wheel "packaging>=24.2"
- name: Build distributions (sdist + wheel)
run: python -m build
- name: Inspect dist
run: |
ls -lah dist/
echo "sdist contents (first ~200 entries):"
tar -tf dist/*.tar.gz | sed -n '1,200p'
- name: Twine metadata & README check
run: python -m twine check dist/*
- name: Install from wheel & smoke test
run: |
# Install from the built wheel (not from the source tree)
python -m pip install dist/*.whl
python - <<'PY'
import importlib
pkg_name = "dlclivegui" # change if your top-level import differs
m = importlib.import_module(pkg_name)
print("Imported:", m.__name__, "version:", getattr(m, "__version__", "n/a"))
PY
# Console entry point best-effort check (adjust name if different)
(command -v dlclivegui && dlclivegui --help) || echo "CLI not available or returned non-zero; continuing."
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: build_check
if: ${{ startsWith(github.ref, 'refs/tags/v') }} # only on tag pushes like v1.2.3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install build tools
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build distributions (sdist + wheel)
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
run: python -m twine upload --verbose dist/*