diff --git a/.github/workflows/_docs.yml b/.github/workflows/_docs.yml deleted file mode 100644 index 0868b55839..0000000000 --- a/.github/workflows/_docs.yml +++ /dev/null @@ -1,54 +0,0 @@ -on: - workflow_call: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Avoid git conflicts when tag and branch pushed at same time - if: github.ref_type == 'tag' - run: sleep 60 - - - name: Checkout - uses: actions/checkout@v7 - with: - # Need this to get version number from last tag - fetch-depth: 0 - - - name: Install system packages - run: sudo apt-get install graphviz - - - name: Install uv - uses: astral-sh/setup-uv@v8.3.2 - - - name: Build docs - run: uv run --locked tox -e docs - - - name: Remove environment.pickle - run: rm build/html/.doctrees/environment.pickle - - - name: Upload built docs artifact - uses: actions/upload-artifact@v7 - with: - name: docs - path: build - - - name: Sanitize ref name for docs version - run: echo "DOCS_VERSION=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}" >> $GITHUB_ENV - - - name: Move to versioned directory - run: mv build/html .github/pages/$DOCS_VERSION - - - name: Write switcher.json - run: python .github/pages/make_switcher.py --add $DOCS_VERSION ${{ github.repository }} .github/pages/switcher.json - - - name: Publish Docs to gh-pages - if: github.ref_type == 'tag' || github.ref_name == 'main' - # We pin to the SHA, not the tag, for security reasons. - # https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions - uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: .github/pages - keep_files: true diff --git a/.github/workflows/_release.yml b/.github/workflows/_release.yml deleted file mode 100644 index 14b4b269a6..0000000000 --- a/.github/workflows/_release.yml +++ /dev/null @@ -1,32 +0,0 @@ -on: - workflow_call: - -jobs: - artifacts: - runs-on: ubuntu-latest - - steps: - - name: Download artifacts - uses: actions/download-artifact@v8 - with: - merge-multiple: true - - - name: Zip up docs - run: | - set -vxeuo pipefail - if [ -d html ]; then - mv html $GITHUB_REF_NAME - zip -r docs.zip $GITHUB_REF_NAME - rm -rf $GITHUB_REF_NAME - fi - - - name: Create GitHub Release - # We pin to the SHA, not the tag, for security reasons. - # https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions - uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2 - with: - prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }} - files: "*" - generate_release_notes: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05d03967b2..4cdbf27d40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,10 +40,13 @@ jobs: contents: read packages: write - docs: - uses: ./.github/workflows/_docs.yml - permissions: - contents: write + docs: # Call the docs building workflow directly + uses: DiamondLightSource/myst-version-switcher-plugin/.github/workflows/docs.yml@v0.24 + with: + # Whatever turns your sources into docs/_build/html at $BASE_URL. uv and Node + # are preinstalled, so: make docs · tox -e docs · npm ci && npm run docs + build-command: uv run --locked tox -e docs + html-dir: build/html dist: uses: ./.github/workflows/_dist.yml @@ -57,7 +60,21 @@ jobs: release: needs: [dist, test, docs] - if: github.ref_type == 'tag' - uses: ./.github/workflows/_release.yml + if: github.ref_type == 'tag' # tag pushes only + uses: DiamondLightSource/myst-version-switcher-plugin/.github/workflows/release.yml@v0.24 + permissions: + contents: write # create the Release + attach assets + + publish: + needs: [docs] + # don't publish a pages site in the fork's org + if: github.repository == 'DiamondLightSource/blueapi' + uses: ./.github/workflows/publish-dispatch.yml # your workflow (below) + with: + version-name: ${{ needs.docs.outputs.version-name }} permissions: - contents: write + contents: read + actions: write + pages: write + id-token: write + statuses: write diff --git a/.github/workflows/publish-dispatch.yml b/.github/workflows/publish-dispatch.yml new file mode 100644 index 0000000000..4a02e00d05 --- /dev/null +++ b/.github/workflows/publish-dispatch.yml @@ -0,0 +1,36 @@ +# .github/workflows/publish-dispatch.yml +name: Publish (dispatch) +on: + workflow_call: # ci.yml's `publish` job, for every event + inputs: + version-name: {required: false, default: "", type: string} + # tag re-dispatch + fork-PR preview + manual re-deploy + workflow_dispatch: + inputs: + pr: + description: "Fork PR to approve + preview (empty = re-deploy)" + required: false + default: "" + retry-until: + description: "Internal = epoch-second retry deadline. Don't set manually." + required: false + default: "" + +jobs: + publish: + uses: DiamondLightSource/myst-version-switcher-plugin/.github/workflows/publish.yml@v0.24 + with: + # "" on dispatch → pure durable gather + version-name: ${{ inputs.version-name }} + # set (dispatch) → pin that fork head SHA + pr: ${{ inputs.pr }} + # the file the tag re-dispatch re-fires + dispatch-workflow: publish-dispatch.yml + # forwarded so the re-dispatch job's auto-retry can re-fire this shim + retry-until: ${{ inputs.retry-until }} + permissions: + contents: read + actions: write + pages: write + id-token: write + statuses: write diff --git a/docs/conf.py b/docs/conf.py index 0e96d9dea2..736cb5987c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -5,9 +5,8 @@ https://www.sphinx-doc.org/en/master/usage/configuration.html """ +import os import sys -from pathlib import Path -from subprocess import check_output import requests @@ -21,14 +20,7 @@ # The full version, including alpha/beta/rc tags. release = blueapi.__version__ -# The short X.Y version. -if "+" in release: - # Not on a tag, use branch name - root = Path(__file__).absolute().parent.parent - git_branch = check_output("git branch --show-current".split(), cwd=root) - version = git_branch.decode().strip() -else: - version = release +version = os.environ.get("VERSION_NAME", "local") extensions = [ # Use this for generating API docs @@ -172,7 +164,7 @@ "version_match": version, }, "check_switcher": False, - "navbar_end": ["theme-switcher", "icon-links", "version-switcher"], + "navbar_end": ["theme-switcher", "navbar-icon-links", "version-switcher"], "navigation_with_keys": False, }