Add a release action #751
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
# As much as possible, this file should be kept in sync with | |
# https://github.com/napari/napari/blob/main/.github/workflows/build_docs.yml | |
# | |
# Note this workflow is also triggered by | |
# https://github.com/napari/napari/blob/main/.github/workflows/deploy_docs.yml when a | |
# commit to `main` occurs in `napari/napari` | |
name: Build & Deploy PR Docs | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
target_directory: | |
description: 'The directory to deploy the docs to' | |
required: true | |
default: 'dev' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-and-upload: | |
name: Build & Upload Artifact | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone docs repo | |
uses: actions/checkout@v4 | |
with: | |
# place in '/home/runner/work/docs/docs/docs' | |
path: docs # place in a named directory | |
- name: Clone main repo | |
uses: actions/checkout@v4 | |
with: | |
# place in '/home/runner/work/docs/docs/napari' | |
path: napari # place in a named directory | |
repository: napari/napari | |
# ensure version metadata is proper | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache-dependency-path: | | |
napari/pyproject.toml | |
docs/requirements.txt | |
- uses: tlambert03/setup-qt-libs@v1 | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install "napari/[all]" | |
env: | |
PIP_CONSTRAINT: ${{ github.workspace }}/napari/resources/constraints/constraints_py3.10_docs.txt | |
- name: Testing | |
run: | | |
python -c 'import napari; print(napari.__version__)' | |
python -c 'import napari.layers; print(napari.layers.__doc__)' | |
- name: Create fallback videos | |
# Only needed for deployment, so should **NOT** be in | |
# napari/napari/.github/workflows/build_docs.yml | |
run: | | |
sudo apt-get update && sudo apt-get install -y ffmpeg | |
cd docs | |
make fallback-videos | |
- name: Update version switcher (on new release) | |
if: ((github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) | |
run: | | |
cd docs | |
python docs/_scripts/update_switcher.py ${{ github.event.inputs.target_directory || github.event.release.tag_name }} | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add docs/_static/version_switcher.json | |
git commit -m "Update version switcher for release" --allow-empty | |
- name: Build Docs | |
uses: aganders3/headless-gui@v2 | |
env: | |
GOOGLE_CALENDAR_ID: ${{ secrets.GOOGLE_CALENDAR_ID }} | |
GOOGLE_CALENDAR_API_KEY: ${{ secrets.GOOGLE_CALENDAR_API_KEY }} | |
PIP_CONSTRAINT: ${{ github.workspace }}/napari/resources/constraints/constraints_py3.10_docs.txt | |
with: | |
# Runs in '/home/runner/work/docs/docs/docs' | |
# Built HTML pages in '/home/runner/work/docs/docs/docs/docs/_build/html' | |
run: make -C docs docs | |
# skipping setup stops the action from running the default (tiling) window manager | |
# the window manager is not necessary for docs builds at this time and it was causing | |
# problems with screenshots (https://github.com/napari/docs/issues/285) | |
linux-setup: "echo 'skip setup'" | |
linux-teardown: "echo 'skip teardown'" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: html | |
path: docs/docs/_build/html/ | |
deploy: | |
name: Download & Deploy Artifact | |
needs: build-and-upload | |
runs-on: ubuntu-latest | |
# Working directory: '/home/runner/work/docs/docs' | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: html | |
# Downloads to '/home/runner/work/docs/docs/html' | |
path: html | |
- name: Deploy Dev Docs | |
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/main')) | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
# Note that GITHUB_TOKEN has no permission to access to external repositories. | |
# When you use deploy_key, set your private key to the repository which | |
# includes this action as a secret, and set your public key to your external repository. | |
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} | |
external_repository: napari/napari.github.io | |
publish_dir: ./html | |
publish_branch: gh-pages | |
destination_dir: ${{ github.event.inputs.target_directory || 'dev' }} | |
cname: napari.org | |
keep_files: true | |
# Because we are using two deploy actions, we need to reset the ssh-agent | |
# to avoid the following error: | |
# unix_listener: cannot bind to path /tmp/ssh-auth.sock: Address already in use | |
# See https://github.com/peaceiris/actions-gh-pages/issues/909 | |
- name: Reset ssh agent | |
if: ((github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) | |
run: killall ssh-agent | |
# Because the actions-gh-pages triggers a pages deployment, it can be some | |
# time before the repo is updated. We need to wait for the deployment to | |
# complete before we can create a second deployment, or we will have a git | |
# conflict. The 5m sleep is completely arbitrary. | |
- name: Wait for first deployment | |
if: ((github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) | |
run: sleep 5m | |
- name: Deploy Release Docs | |
if: ((github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} | |
external_repository: napari/napari.github.io | |
publish_dir: ./html | |
publish_branch: gh-pages | |
destination_dir: ${{ github.event.inputs.target_directory || github.event.release.tag_name }} | |
cname: napari.org | |
keep_files: true | |
- name: Set up stable symlink | |
if: ((github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) | |
uses: convictional/[email protected] | |
with: | |
owner: napari | |
repo: napari.github.io | |
github_token: ${{ secrets.WORKFLOW_PAT }} | |
workflow_file_name: symlink-stable.yml | |
client_payload: '{"target_directory": "${{ github.event.inputs.target_directory || github.event.release.tag_name }}"}' |