diff --git a/.github/workflows/publish_documentation.yml b/.github/workflows/publish_documentation.yml index d861424f3..d1235e085 100644 --- a/.github/workflows/publish_documentation.yml +++ b/.github/workflows/publish_documentation.yml @@ -5,6 +5,9 @@ on: push: branches: - main + release: + types: + - created permissions: contents: write @@ -14,6 +17,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: actions/setup-python@v4 with: python-version: 3.x @@ -25,7 +30,24 @@ jobs: restore-keys: | mkdocs-material- - run: pip install -r requirements-doc.txt - - name: Build documentation + - run: mkdocs build + + - name: Set up Git + run: | + git config user.name ${{ github.actor }} + git config user.email ${{ github.actor }}@users.noreply.github.com + + - name: Publish Tag as latest + env: + GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }} + if: github.event_name == 'release' + run: | + mike deploy --push --update-aliases ${{ github.ref_name }} latest + mike set-default --push latest + + - name: Publish main as unstable env: GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }} - run: mkdocs gh-deploy --force + if: github.event_name == 'push' + run: | + mike deploy --push --update-aliases ${{ github.ref_name }} unstable diff --git a/mkdocs.yml b/mkdocs.yml index 4189df1c0..b200ee3d8 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -45,6 +45,10 @@ extra: analytics: provider: google property: !ENV GOOGLE_ANALYTICS_KEY + version: + provider: mike + default: latest + alias: true # Extensions markdown_extensions: diff --git a/requirements-doc.txt b/requirements-doc.txt index cf8c674a7..05f9f36ec 100644 --- a/requirements-doc.txt +++ b/requirements-doc.txt @@ -6,3 +6,4 @@ mkdocs-section-index mkdocstrings[python] mkdocs-git-committers-plugin-2 mkdocs-git-revision-date-localized-plugin +mike