Skip to content

ci: skip existing PyPI distributions #3

ci: skip existing PyPI distributions

ci: skip existing PyPI distributions #3

Workflow file for this run

name: Build and Publish
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
jobs:
test:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install package with dev dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
- name: Lint
run: python -m ruff check hermes_pmxt/ tests/
- name: Run unit tests
run: python -m pytest -q -m unit --tb=short
- name: Verify import
run: python -c "import hermes_pmxt; print('OK v' + hermes_pmxt.__version__)"
build:
name: Build package
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install build tools
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build distributions
run: python -m build
- name: Check distributions
run: python -m twine check dist/*
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
id-token: write
contents: read
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true