|
| 1 | +name: Build, validate & Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: [ 'v*.*.*' ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, public ] |
| 8 | + types: [ labeled, opened, edited, synchronize, reopened ] |
| 9 | + |
| 10 | +jobs: |
| 11 | + test: |
| 12 | + name: Test / smoke (matrix) |
| 13 | + runs-on: ubuntu-latest |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + python-version: [ "3.10", "3.11", "3.12" ] |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v6 |
| 20 | + - uses: actions/setup-python@v6 |
| 21 | + with: |
| 22 | + python-version: ${{ matrix.python-version }} |
| 23 | + |
| 24 | + - name: Install tools |
| 25 | + run: | |
| 26 | + python -m pip install --upgrade pip |
| 27 | + python -m pip install build twine wheel "packaging>=24.2" |
| 28 | +
|
| 29 | + - name: Build distributions (sdist + wheel) |
| 30 | + run: python -m build |
| 31 | + |
| 32 | + - name: Inspect dist |
| 33 | + run: | |
| 34 | + ls -lah dist/ |
| 35 | + echo "sdist contents (first ~200 entries):" |
| 36 | + tar -tf dist/*.tar.gz | sed -n '1,200p' |
| 37 | +
|
| 38 | + - name: Twine metadata & README check |
| 39 | + run: python -m twine check dist/* |
| 40 | + |
| 41 | + - name: Install from wheel & smoke test |
| 42 | + run: | |
| 43 | + python -m pip install dist/*.whl |
| 44 | + python - <<'PY' |
| 45 | + import importlib |
| 46 | + pkg_name = "dlclivegui" |
| 47 | + m = importlib.import_module(pkg_name) |
| 48 | + print("Imported:", m.__name__, "version:", getattr(m, "__version__", "n/a")) |
| 49 | + PY |
| 50 | +
|
| 51 | + if ! command -v dlclivegui >/dev/null 2>&1; then |
| 52 | + echo "CLI entry point 'dlclivegui' not found in PATH; skipping CLI smoke test." |
| 53 | + else |
| 54 | + if command -v dlclivegui >/dev/null 2>&1; then |
| 55 | + echo "Running 'dlclivegui --help' smoke test..." |
| 56 | + if ! dlclivegui --help >/dev/null 2>&1; then |
| 57 | + echo "::error::'dlclivegui --help' failed; this indicates a problem with the installed CLI package." |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | +
|
| 61 | + build: |
| 62 | + name: Build release artifacts (single) |
| 63 | + runs-on: ubuntu-latest |
| 64 | + needs: test |
| 65 | + if: ${{ startsWith(github.ref, 'refs/tags/v') }} |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@v6 |
| 68 | + - uses: actions/setup-python@v6 |
| 69 | + with: |
| 70 | + python-version: "3.12" |
| 71 | + |
| 72 | + - name: Build distributions (sdist + wheel) |
| 73 | + run: | |
| 74 | + 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/* |
| 78 | +
|
| 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 |
| 100 | + |
| 101 | + - name: Publish to PyPI |
| 102 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments