[Maint] use setuptools_scm for versioning (#159) #74
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 | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
concurrency: | |
group: deploy_docs | |
cancel-in-progress: true | |
# This job installs dependencies, build the book, and pushes it to `gh-pages` | |
jobs: | |
build-and-deploy-book: | |
permissions: | |
contents: write | |
id-token: write | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python-version: [3.9] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# Install dependencies | |
- name: Install dependencies | |
run: | | |
# Install Python dependencies | |
pip install --upgrade pip build ".[doc]" | |
# Build and install the theme package. | |
- name: Build and install theme | |
env: | |
ENV: prod | |
run: | | |
python -m build | |
pip install dist/napari_sphinx_theme*.whl | |
# Build the documentation. | |
- name: Build docs | |
env: | |
GOOGLE_CALENDAR_API_KEY: ${{ secrets.GOOGLE_CALENDAR_API_KEY }} | |
run: sphinx-build -b=html docs/ build/ | |
# Deploy the book's HTML to github pages | |
- name: GitHub Pages action | |
if: github.repository == 'napari/napari-sphinx-theme' && github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./build | |
# If tagged version: Publish wheel to PyPI | |
- name: Publish to PyPI | |
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && startsWith(github.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
# If tagged version: Update release on github repo | |
- uses: softprops/action-gh-release@v1 | |
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && startsWith(github.ref, 'refs/tags') | |
with: | |
tag_name: ${{ github.ref }} | |
name: ${{ env.tag }} | |
files: | | |
dist/* | |
generate_release_notes: true |