From 5443880997b2548fea2fbb5f1d5ed1709e6262ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melissa=20Weber=20Mendon=C3=A7a?= Date: Thu, 12 Sep 2024 18:08:27 -0300 Subject: [PATCH 1/6] Add a release action This action will build and deploy docs for a new release, copying the built docs artifacts to both the dev and the {version} folders in napari.github.io. It will also update the stable symlink to point to the new version folder. This action will be triggered by a new release tag pushed to the repo or by manually trigerring the action with an input specifying the new version (any input different from the default dev will trigger the action.) --- .circleci/config.yml | 4 +-- .github/workflows/build_and_deploy.yml | 44 +++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f808dcd58..6500834e9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,12 +6,12 @@ version: 2.1 # Orbs are reusable packages of CircleCI configuration that you may share across projects. # See: https://circleci.com/docs/2.1/orb-intro/ orbs: - python: circleci/python@1.5.0 + python: circleci/python@2.1.1 jobs: build-docs: docker: # A list of available CircleCI Docker convenience images are available here: https://circleci.com/developer/images/image/cimg/python - - image: cimg/python:3.10.13 + - image: cimg/python:3.10 steps: - checkout: path: docs diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index fdcfd13e1..4d97a06af 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -69,6 +69,8 @@ jobs: 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 @@ -109,13 +111,53 @@ jobs: # Downloads to '/home/runner/work/docs/docs/html' path: html - - name: Deploy Docs + - 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@v3 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 + 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 + run: sleep 5m + + - name: Deploy Release Docs + if: (github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) + uses: peaceiris/actions-gh-pages@v3 + 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' || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) + uses: convictional/trigger-workflow-and-wait@v1.6.5 + 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 }}"}' From 369746c5ee07ea3eca7e8d8a9cfb3d0058024746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melissa=20Weber=20Mendon=C3=A7a?= Date: Thu, 26 Sep 2024 18:48:31 -0300 Subject: [PATCH 2/6] Fix release action execution condition --- .github/workflows/build_and_deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 4d97a06af..b316d3da3 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -131,6 +131,7 @@ jobs: # 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' || (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 @@ -138,6 +139,7 @@ jobs: # 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' || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) run: sleep 5m - name: Deploy Release Docs From 78167202bc7609d492d3e25494a5f19ed23aab3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melissa=20Weber=20Mendon=C3=A7a?= Date: Tue, 22 Oct 2024 13:21:52 -0300 Subject: [PATCH 3/6] Add condition to filter out release candidates from release action --- .github/workflows/build_and_deploy.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index b316d3da3..f48a1d5f2 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -131,7 +131,7 @@ jobs: # 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' || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) + 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 @@ -139,11 +139,11 @@ jobs: # 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' || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) + 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' || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) + 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@v3 with: deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} @@ -155,7 +155,7 @@ jobs: keep_files: true - name: Set up stable symlink - if: (github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) + 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/trigger-workflow-and-wait@v1.6.5 with: owner: napari From a9e9297e3e2255936f965594f3e13af7e76efdc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melissa=20Weber=20Mendon=C3=A7a?= Date: Tue, 22 Oct 2024 14:07:56 -0300 Subject: [PATCH 4/6] Add script to update version switcher --- .github/workflows/build_and_deploy.yml | 10 ++++++++ docs/_scripts/update_switcher.py | 34 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 docs/_scripts/update_switcher.py diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index f48a1d5f2..54ea025ee 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -76,6 +76,16 @@ jobs: 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 "action@github.com" + 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: diff --git a/docs/_scripts/update_switcher.py b/docs/_scripts/update_switcher.py new file mode 100644 index 000000000..b7d934ba6 --- /dev/null +++ b/docs/_scripts/update_switcher.py @@ -0,0 +1,34 @@ +import sys +import json + + +def update_version_switcher(new_version): + """Update version_switcher.json after a new release.""" + with open("docs/_static/version_switcher.json", "r") as f: + switcher = json.load(f) + oldstable = switcher[1] + + newstable = oldstable.copy() + newstable["version"] = new_version + newstable["name"] = f"stable ({new_version})" + + oldstable["name"] = f"{oldstable['version']}" + del oldstable["preferred"] + oldstable["url"] = oldstable["url"].replace("stable", oldstable["version"]) + + switcher[1] = oldstable + switcher.insert(1, newstable) + with open("docs/_static/version_switcher.json", "w") as f: + json.dump(switcher, f, indent=4) + + print(f"Version switcher updated to {new_version}") + print(f"Old stable version: {switcher[2]}") + print(f"New stable version: {switcher[1]}") + + +if __name__ == "__main__": + if len(sys.argv) != 2: + print("Usage: python update_switcher.py ") + sys.exit() + new_version = sys.argv[1] + update_version_switcher(new_version) From 050b300aa89055b765d89bfce42c9cf07bea7fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melissa=20Weber=20Mendon=C3=A7a?= Date: Thu, 7 Nov 2024 20:14:55 -0300 Subject: [PATCH 5/6] Bump actions for actionlint --- .github/workflows/build_and_deploy.yml | 2 +- .github/workflows/labeler.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 54ea025ee..2829988d9 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -123,7 +123,7 @@ jobs: - 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@v3 + 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 diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 002112e07..7269a1b25 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -10,6 +10,6 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/labeler@v4 + - uses: actions/labeler@v5 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" From 59135d3339ed68beb1357c0b7facbd86145b4b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melissa=20Weber=20Mendon=C3=A7a?= Date: Thu, 7 Nov 2024 20:16:03 -0300 Subject: [PATCH 6/6] Bump action --- .github/workflows/build_and_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 2829988d9..a3523b2b5 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -154,7 +154,7 @@ jobs: - 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@v3 + uses: peaceiris/actions-gh-pages@v4 with: deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} external_repository: napari/napari.github.io