|
| 1 | +name: Publish to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "Release version (e.g. 0.1.0)" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + dry_run: |
| 11 | + description: "Dry run (build + test only, no upload)" |
| 12 | + type: boolean |
| 13 | + default: false |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + id-token: write |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + name: Build wheel & sdist |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Set up Python |
| 27 | + uses: actions/setup-python@v5 |
| 28 | + with: |
| 29 | + python-version: "3.12" |
| 30 | + |
| 31 | + - name: Install build tools |
| 32 | + run: pip install build |
| 33 | + |
| 34 | + - name: Build wheel and sdist |
| 35 | + run: python -m build |
| 36 | + |
| 37 | + - name: Upload build artifacts |
| 38 | + uses: actions/upload-artifact@v4 |
| 39 | + with: |
| 40 | + name: dist |
| 41 | + path: dist/ |
| 42 | + |
| 43 | + test-install: |
| 44 | + name: Test install — Python ${{ matrix.python }} / ${{ matrix.os }} |
| 45 | + needs: build |
| 46 | + strategy: |
| 47 | + fail-fast: false |
| 48 | + matrix: |
| 49 | + os: [ubuntu-latest, ubuntu-22.04, ubuntu-20.04, macos-latest, windows-latest] |
| 50 | + python: ["3.11", "3.12", "3.13"] |
| 51 | + runs-on: ${{ matrix.os }} |
| 52 | + steps: |
| 53 | + - name: Download build artifacts |
| 54 | + uses: actions/download-artifact@v4 |
| 55 | + with: |
| 56 | + name: dist |
| 57 | + path: dist/ |
| 58 | + |
| 59 | + - name: Set up Python |
| 60 | + uses: actions/setup-python@v5 |
| 61 | + with: |
| 62 | + python-version: ${{ matrix.python }} |
| 63 | + |
| 64 | + - name: Install wheel |
| 65 | + shell: bash |
| 66 | + run: pip install dist/*.whl |
| 67 | + |
| 68 | + - name: Verify CLI entry point |
| 69 | + run: code-intelligence --help |
| 70 | + |
| 71 | + - name: Verify detectors load |
| 72 | + run: python -c "from code_intelligence.detectors.registry import DetectorRegistry; r = DetectorRegistry(); r.load_builtin_detectors(); print(f'{len(r.all_detectors())} detectors loaded')" |
| 73 | + |
| 74 | + - name: Verify version |
| 75 | + run: python -c "import importlib.metadata; print(importlib.metadata.version('code-intelligence'))" |
| 76 | + |
| 77 | + test-container: |
| 78 | + name: Test install — ${{ matrix.container }} |
| 79 | + needs: build |
| 80 | + runs-on: ubuntu-latest |
| 81 | + strategy: |
| 82 | + fail-fast: false |
| 83 | + matrix: |
| 84 | + container: |
| 85 | + - "registry.access.redhat.com/ubi8/python-311:latest" |
| 86 | + - "registry.access.redhat.com/ubi9/python-311:latest" |
| 87 | + - "registry.access.redhat.com/ubi9/python-312:latest" |
| 88 | + - "python:3.11-slim-bookworm" |
| 89 | + - "python:3.12-slim-bookworm" |
| 90 | + - "python:3.13-slim-bookworm" |
| 91 | + - "python:3.11-alpine" |
| 92 | + - "python:3.12-alpine" |
| 93 | + container: |
| 94 | + image: ${{ matrix.container }} |
| 95 | + steps: |
| 96 | + - name: Download build artifacts |
| 97 | + uses: actions/download-artifact@v4 |
| 98 | + with: |
| 99 | + name: dist |
| 100 | + path: dist/ |
| 101 | + |
| 102 | + - name: Install system deps (Alpine) |
| 103 | + if: contains(matrix.container, 'alpine') |
| 104 | + run: apk add --no-cache gcc musl-dev libxml2-dev libxslt-dev |
| 105 | + |
| 106 | + - name: Install system deps (UBI/RHEL) |
| 107 | + if: contains(matrix.container, 'ubi') |
| 108 | + run: | |
| 109 | + dnf install -y libxml2-devel libxslt-devel gcc python3-devel 2>/dev/null || true |
| 110 | +
|
| 111 | + - name: Install wheel |
| 112 | + run: pip install dist/*.whl |
| 113 | + |
| 114 | + - name: Verify CLI |
| 115 | + run: code-intelligence --help |
| 116 | + |
| 117 | + - name: Verify detectors load |
| 118 | + run: python -c "from code_intelligence.detectors.registry import DetectorRegistry; r = DetectorRegistry(); r.load_builtin_detectors(); print(f'{len(r.all_detectors())} detectors loaded')" |
| 119 | + |
| 120 | + publish-pypi: |
| 121 | + name: Publish to PyPI |
| 122 | + needs: [test-install, test-container] |
| 123 | + runs-on: ubuntu-latest |
| 124 | + if: inputs.dry_run == false |
| 125 | + environment: |
| 126 | + name: pypi |
| 127 | + url: https://pypi.org/p/code-intelligence |
| 128 | + steps: |
| 129 | + - name: Download build artifacts |
| 130 | + uses: actions/download-artifact@v4 |
| 131 | + with: |
| 132 | + name: dist |
| 133 | + path: dist/ |
| 134 | + |
| 135 | + - name: Publish to PyPI |
| 136 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 137 | + with: |
| 138 | + attestations: true |
0 commit comments