From 9a8647775dc3a2f6816bc8cbf40d15fa011e8c00 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Thu, 18 Sep 2025 21:04:11 +0200 Subject: [PATCH] Setup docs versioning --- .github/workflows/docs.yml | 75 +++++++++++++++++++++++++++++--------- docs-requirements.txt | 1 + mkdocs.yml | 8 ++++ 3 files changed, 67 insertions(+), 17 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 8df96b6..d27b495 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,9 +14,11 @@ on: - 'docs/**' - 'mkdocs.yml' - 'docs-requirements.txt' + release: + types: [published] permissions: - contents: read + contents: write pages: write id-token: write @@ -27,11 +29,12 @@ concurrency: jobs: build: runs-on: ubuntu-latest + if: github.event_name == 'pull_request' steps: - name: Checkout uses: actions/checkout@v4 with: - fetch-depth: 0 # Needed for git-revision-date-localized plugin + fetch-depth: 0 - name: Setup Python uses: actions/setup-python@v4 @@ -46,20 +49,58 @@ jobs: run: | mkdocs build --strict - - name: Upload documentation artifact - if: github.ref == 'refs/heads/main' - uses: actions/upload-pages-artifact@v3 - with: - path: ./site - - deploy: - if: github.ref == 'refs/heads/main' - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} + deploy-dev: runs-on: ubuntu-latest - needs: build + if: github.ref == 'refs/heads/main' && github.event_name == 'push' steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + pip install -r docs-requirements.txt + + - name: Configure Git + run: | + git config --global user.name "${{ github.actor }}" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + + - name: Deploy development version + run: | + mike deploy --push --update-aliases dev latest + + deploy-release: + runs-on: ubuntu-latest + if: github.event_name == 'release' + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + pip install -r docs-requirements.txt + + - name: Configure Git + run: | + git config --global user.name "${{ github.actor }}" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + + - name: Deploy release version + run: | + VERSION=${GITHUB_REF#refs/tags/} + mike deploy --push --update-aliases $VERSION stable + mike set-default --push stable diff --git a/docs-requirements.txt b/docs-requirements.txt index 256e652..632c6e1 100644 --- a/docs-requirements.txt +++ b/docs-requirements.txt @@ -2,3 +2,4 @@ mkdocs-material==9.5.3 mkdocs==1.5.3 pymdown-extensions==10.7 mkdocs-git-revision-date-localized-plugin==1.2.4 +mike==2.0.0 diff --git a/mkdocs.yml b/mkdocs.yml index ed4be3a..cc69245 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -61,8 +61,16 @@ nav: plugins: - search - git-revision-date-localized + - mike: + version_selector: true + css_dir: css + javascript_dir: js + canonical_version: null extra: + version: + provider: mike + default: stable social: - icon: fontawesome/brands/github link: https://github.com/lordmathis/llamactl