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
# This workflow will upload a Python Package using Twine when a release is created | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | |
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: Deploy Python Package to PyPi | |
on: | |
release: | |
types: [published,edited] | |
permissions: | |
contents: read | |
jobs: | |
tests: | |
name: Run unit testing ✅❌ | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
make install_requirements | |
- name: Test with pytest | |
run: | | |
pip install pytest pytest-cov | |
make run_tests | |
release-build: | |
name: Build Python 🐍 distribution 📦 | |
runs-on: ubuntu-latest | |
needs: | |
- tests | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Change Package Version in docs/source/conf.py and pyproject.toml | |
run: | | |
python update_version.py | |
- name: Build release distributions | |
run: | | |
python -m pip install build | |
python -m build | |
- name: Upload distributions | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
docs-build: | |
name: Build Python 🐍 distribution 📦 documentation📚 | |
runs-on: ubuntu-latest | |
needs: | |
- tests | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Change Package Version in docs/source/conf.py and pyproject.toml | |
run: | | |
python update_version.py | |
- name: Install Sphinx and dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install sphinx sphinx-rtd-theme | |
- name: Build documentation | |
run: | | |
cd docs | |
make html | |
pypi-publish: | |
runs-on: ubuntu-latest | |
name: Publish Python 🐍 distribution 📦 to PyPI | |
needs: | |
- release-build | |
- docs-build | |
permissions: | |
# IMPORTANT: this permission is mandatory for trusted publishing | |
id-token: write | |
# Dedicated environments with protections for publishing are strongly recommended. | |
environment: | |
name: pypi | |
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status: | |
url: https://pypi.org/project/pydtm/ | |
steps: | |
- name: Retrieve release distributions | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish release distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |