|
1 | | -name: Update pypi release |
| 1 | +name: Build, validate & Release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
16 | 16 | - reopened |
17 | 17 |
|
18 | 18 | jobs: |
19 | | - release: |
| 19 | + build_check: |
| 20 | + name: Build & validate package |
20 | 21 | 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 |
22 | 26 | 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 }} |
25 | 31 | uses: actions/setup-python@v5 |
26 | 32 | with: |
27 | | - python-version: '3.x' |
| 33 | + python-version: ${{ matrix.python-version }} |
28 | 34 |
|
29 | | - - name: Cache dependencies |
30 | | - id: pip-cache |
| 35 | + - name: Cache pip |
31 | 36 | uses: actions/cache@v4 |
32 | 37 | with: |
33 | 38 | 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') }} |
35 | 40 | restore-keys: | |
36 | | - ${{ runner.os }}-pip-${{ steps.setup-python.outputs.python-version }}- |
| 41 | + ${{ runner.os }}-pip-${{ matrix.python-version }}- |
37 | 42 | ${{ runner.os }}-pip- |
38 | 43 |
|
39 | | - - name: Install dependencies |
| 44 | + - name: Install build tools |
40 | 45 | 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 |
46 | 72 |
|
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 |
48 | 83 | uses: actions/checkout@v4 |
49 | 84 |
|
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 |
52 | 99 | env: |
53 | 100 | TWINE_USERNAME: __token__ |
54 | 101 | 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