name: Test and upload Python package on: pull_request: push: branches: [master] tags: - 'v*' - '!v*-dev' jobs: pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - uses: pre-commit/action@v3.0.0 test: if: github.repository == 'zeek/zeek-client' runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install -e '.[dev]' - name: Run unit tests run: pytest upload: runs-on: ubuntu-latest needs: [test] if: github.repository == 'zeek/zeek-client' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') steps: - uses: actions/checkout@v4 - name: Check release version # This fails e.g. if VERSION contains a dev commits suffix, # since we don't want to push these to PyPI. run: | grep -E -x '[0-9]+\.[0-9]+\.[0-9]+' VERSION - name: Build sdist # This places the sdist in the dist folder, where the upload # action in the next step knows to look for it. run: | make dist - name: Upload to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }}