diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 13688f56..91e6dcee 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -4,6 +4,9 @@ on: push: branches: - doc + - main + tags: + - 'v*' paths: - 'doc/**' - 'mkdocs.yml' @@ -16,22 +19,20 @@ on: - '.github/workflows/docs.yml' permissions: - contents: read - pages: write - id-token: write + contents: write concurrency: - group: "pages" + group: "docs-${{ github.ref }}" cancel-in-progress: false jobs: - build: + docs: runs-on: ubuntu-latest 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 @@ -44,23 +45,28 @@ jobs: pipx inject mkdocs mkdocs-material pipx inject mkdocs pymdown-extensions pipx inject mkdocs mkdocs-callouts + pipx inject mkdocs mike + # Workaround, if pipx inject fails to install symlink + ln -s "$(pipx environment -V PIPX_LOCAL_VENVS)/mkdocs/bin/mike" \ + "$(pipx environment -V PIPX_BIN_DIR)/mike" || true - - name: Build documentation - run: mkdocs build + - name: Configure Git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" - - name: Upload Pages artifact - uses: actions/upload-pages-artifact@v3 - with: - path: site/ + - name: Deploy dev version + if: github.event_name == 'push' && (github.ref == 'refs/heads/doc' || github.ref == 'refs/heads/main') + run: | + mike deploy --push --update-aliases dev latest + mike set-default --push latest - deploy: - if: github.ref == 'refs/heads/doc' && github.event_name == 'push' - needs: build - runs-on: ubuntu-latest - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + - name: Deploy tagged version + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + run: | + TAG=${GITHUB_REF#refs/tags/v} + # Extract YEAR.MONTH from tag (e.g., v25.06.0-beta1 -> 25.06) + VERSION=$(echo $TAG | sed -E 's/^([0-9]+\.[0-9]+)(\.[0-9]+)?(-.*)?$/\1/') + echo "Deploying tag $TAG as docs version $VERSION" + mike deploy --push --update-aliases $VERSION latest + mike set-default --push latest diff --git a/mkdocs.yml b/mkdocs.yml index dc9fa422..61a7aef6 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -110,7 +110,10 @@ markdown_extensions: plugins: - search - callouts + - mike extra: generator: false homepage: https://kernelkit.org/ + version: + provider: mike