possible version switcher fix #228
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Documentation | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10.17.1 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Build packages | |
| run: pnpm -r run build | |
| - name: Get latest release tag | |
| id: release | |
| run: | | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT | |
| echo "exists=$([[ -n $LATEST_TAG ]] && echo true || echo false)" >> $GITHUB_OUTPUT | |
| - name: Build main documentation | |
| run: pnpm run docs:build | |
| env: | |
| RELEASE_VERSION: ${{ steps.release.outputs.tag }} | |
| - name: Build release documentation | |
| if: steps.release.outputs.exists == 'true' | |
| run: | | |
| # Save main build and config (config has version dropdown code) | |
| mv docs/.vitepress/dist docs/.vitepress/dist-main | |
| cp docs/.vitepress/config.mts /tmp/config.mts | |
| # Checkout release tag | |
| git checkout ${{ steps.release.outputs.tag }} | |
| # Restore config from main (has version dropdown and dynamic base path) | |
| cp /tmp/config.mts docs/.vitepress/config.mts | |
| # Build at release tag with main's config | |
| pnpm install --frozen-lockfile | |
| pnpm -r run build | |
| RELEASE_VERSION=${{ steps.release.outputs.tag }} IS_RELEASE_BUILD=true pnpm run docs:build | |
| # Combine: main at root, release in /release/ | |
| mv docs/.vitepress/dist docs/.vitepress/dist-main/release | |
| mv docs/.vitepress/dist-main docs/.vitepress/dist | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: docs/.vitepress/dist | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |