Deploy Python Distribution #52
Workflow file for this run
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
name: Deploy Python Distribution | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build Python distribution | |
runs-on: ubuntu-latest | |
container: "ghcr.io/gridtools/gridtools-base:gcc-9-ucx-mpi-atlas-parmetis" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install pypa/build | |
run: | | |
python -m pip install build --user | |
- name: Build source tarball | |
run: | | |
python -m build --sdist --outdir dist/ | |
- name: Test sdist | |
run: | | |
python -m venv .venv | |
. .venv/bin/activate | |
python -m pip install --upgrade pip | |
python -m pip install dist/*.tar.gz | |
python -m pip install -r ./bindings/python/min-requirements-test.txt | |
python -c "import ghex" | |
python -m pytest -s ./test/bindings/python/ | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ghex-dist | |
path: ./dist/** | |
publish-pypi: | |
name: Publish Python distribution to pypi.org | |
runs-on: ubuntu-latest | |
needs: build | |
if: ${{ github.event_name == 'workflow_dispatch' }} # the action was triggered manually | |
environment: | |
name: pypi | |
url: https://pypi.org/project/ghex | |
permissions: | |
id-token: write | |
steps: | |
- name: Download wheel | |
uses: actions/download-artifact@v3 | |
with: | |
name: ghex-dist | |
path: dist | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
publish-test-pypi: | |
name: Publish Python distribution to test.pypi.org | |
runs-on: ubuntu-latest | |
needs: build | |
if: ${{ github.event_name == 'release' }} # triggered by releasing on github, test first before manually triggering the deployment to PyPI | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/project/ghex/ | |
permissions: | |
id-token: write | |
steps: | |
- name: Download wheel | |
uses: actions/download-artifact@v4 | |
with: | |
name: ghex-dist | |
path: dist | |
- name: Publish distribution to Test PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
verbose: true |