Skip to content

Release

Release #17

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# TODO: In the future we ought to perform linting and code coverage checks
name: Release
on:
workflow_dispatch:
jobs:
test:
name: Tests
timeout-minutes: 20
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: true
matrix:
# Python 3.9->3.11 on Ubuntu, Windows and MacOS
operating-system: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip" # caching pip dependencies
- name: CPU PyTorch (Windows/MacOS)
if: matrix.operating-system == 'windows-latest' || matrix.operating-system == 'macos-latest'
run: python -m pip install torch torchvision
- name: CPU PyTorch (Linux)
if: matrix.operating-system == 'ubuntu-latest'
run: python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
- name: Install dependencies
run: python -m pip install ".[dev]"
- name: PyTest
run: python -m invoke test.pytest
- name: Doctest
run: python -m invoke test.doctest
- name: Notebooks
run: python -m invoke test.nb
documentation:
name: Documentation
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: 'pip' # caching pip dependencies
- name: Install Dependencies
run: |
sudo apt-get install -y pandoc
python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
python -m pip install ".[dev,doc]"
- name: Build Documentation
run: python -m invoke docs.build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/_build
release_pypi:
name: Release / PyPi
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
concurrency: release
needs: [test, documentation]
permissions:
id-token: write
contents: write
outputs:
released: ${{ steps.release.outputs.released }}
tag: ${{ steps.release.outputs.tag }}
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Hatch
run: python3 -m pip install hatch~=1.9.7
- name: Python Semantic Release
id: release
uses: python-semantic-release/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Package
if: steps.release.outputs.released == 'true'
run: python3 -m hatch build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: steps.release.outputs.released == 'true'
- name: Publish package distributions to GitHub Releases
uses: python-semantic-release/upload-to-gh-release@0f96c02a48278aff14251e9f1a0d73122a8c638b
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_docker:
name: Release / Docker
environment: release
runs-on: ubuntu-latest
needs: [release_pypi]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
file: docker/dockerfile
tags: >-
${{ secrets.DOCKERHUB_USERNAME }}/jupyter-capymoa:${{ needs.release_pypi.outputs.tag }},
${{ secrets.DOCKERHUB_USERNAME }}/jupyter-capymoa:latest
build-args: CAPYMOA_VERSION=${{ needs.release_pypi.outputs.tag }}
website:
name: Website
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
runs-on: ubuntu-latest
needs: [release_pypi, documentation]
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4