Skip to content

On release

On release #57

Workflow file for this run

name: On release
on:
release:
types: [published]
workflow_dispatch:
inputs:
branch:
description: "Branch to deploy from"
required: true
default: "main"
deploy_docs:
description: "Deploy docs to GitHub Pages"
type: boolean
default: true
deploy_test_pypi:
description: "Publish package to TestPyPI"
type: boolean
default: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -l {0}
jobs:
docs-build:
if: github.event_name == 'release' || github.event.inputs.deploy_docs == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.ref_name }}
- name: Get current date
id: date
run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"
- name: Install package
run: |
python -m pip install -e ".[docs]"
- name: Register Jupyter kernel
run: |
python -m ipykernel install --user --name=python3
- name: Build documentation
run: |
make docs-build
- name: Upload documentation artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/_build/html
docs-deploy:
runs-on: ubuntu-latest
needs: docs-build
permissions:
pages: write
id-token: write
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
distribution:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch full history so setuptools-scm can find tags
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.ref_name }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tools
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build distributions
env:
SETUPTOOLS_SCM_LOCAL_SCHEME: no-local-version
run: |
python -m build
- name: Check distribution
run: |
python -m pip install --force-reinstall dist/*.whl
python -m pip install twine
twine check dist/*
# Publish to TestPyPI when run manually
- name: Publish to TestPyPI
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_test_pypi == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TEST_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
verbose: true
# Publish to PyPI on release
- name: Publish to PyPI
if: github.event_name == 'release' && github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}