diff --git a/.github/workflows/packaging.yml b/.github/workflows/packaging.yml new file mode 100644 index 00000000..c4545b53 --- /dev/null +++ b/.github/workflows/packaging.yml @@ -0,0 +1,22 @@ +name: Packaging + +on: [push, pull_request] + +jobs: + packaging: + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install tox + - name: Build package + run: | + tox -e packaging diff --git a/pyproject.toml b/pyproject.toml index 02ac0c9a..26a5d3f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,6 +67,9 @@ dev = [ # Docs. "Sphinx==8.1.3 ; python_version>='3.11'", "sphinx-rtd-theme==3.0.2 ; python_version>='3.11'", + # Packaging. + "build==1.2.2 ; python_version>='3.11'", + "twine==6.0.1 ; python_version>='3.11'", ] [project.urls] diff --git a/tox.ini b/tox.ini index 5ebb350a..ced401f8 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = lint, tests, docs +envlist = lint, tests, docs, packaging isolated_build = True [testenv] @@ -23,3 +23,9 @@ commands = description = Build the HTML documentation. commands = sphinx-build -a -b html -W --keep-going docs/ docs/build + +[testenv:packaging] +description = Build the Python package. +commands = + pyproject-build . + twine check --strict dist/*