pypi-publish #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A workflow to publish releases to PyPi and TestPyPi. | |
name: pypi-publish | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
test_sdist: | |
description: 'Test the sdist before uploading' | |
type: boolean | |
default: true | |
permissions: read-all | |
jobs: | |
pypi-publish: | |
name: Upload to PyPI | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/dm-meltingpot | |
permissions: | |
id-token: write | |
timeout-minutes: 90 | |
steps: | |
- name: Checkout Melting Pot | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
- name: Set up Python | |
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 | |
with: | |
python-version: '3.11' | |
- name: Build distribution | |
run: | | |
pip install build==1.0.3 | |
python -m build --outdir dist/ | |
- name: Test distribution | |
if: github.event_name == 'release' || inputs.test_sdist | |
run: | | |
VENV="$(mktemp --dry-run)" | |
python -m venv "${VENV}" | |
source "${VENV}/bin/activate" | |
pip install dist/*.whl | |
pip install pytest-xdist | |
pytest -n auto -rax --pyargs meltingpot | |
deactivate | |
rm -rf "${VENV}" |