Website: Implement Docusaurus versioning system with automated CI deployment and retroactive versioning #831
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: Documentation | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| workflow_dispatch: | |
| env: | |
| NODE_VERSION: '20' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/develop' && !startsWith(github.ref, 'refs/tags/v') }} | |
| jobs: | |
| # Test documentation build | |
| build-docs: | |
| if: github.ref != 'refs/heads/develop' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: website/package-lock.json | |
| - name: Setup build dependencies | |
| run: | | |
| sudo apt update | |
| sudo apt install -y protobuf-compiler ocaml | |
| - name: Install documentation dependencies | |
| run: make docs-install | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt | |
| # This should be in line with the verison in: | |
| # - Makefile | |
| # - ./github/workflows/docs.yaml | |
| # - ./github/workflows/fmt.yaml | |
| # - ./github/workflows/lint.yaml | |
| toolchain: nightly | |
| - name: Build documentation | |
| run: make docs-build | |
| - name: Upload build artifacts for testing | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docs-build-test | |
| path: website/build | |
| retention-days: 1 | |
| # Deploy to GitHub Pages (only on develop branch) | |
| deploy: | |
| if: github.ref == 'refs/heads/develop' && github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 # Full history for versioning | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: website/package-lock.json | |
| - name: Setup build dependencies | |
| run: | | |
| sudo apt update | |
| sudo apt install -y protobuf-compiler | |
| - name: Install documentation dependencies | |
| run: make docs-install | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt | |
| # This should be in line with the verison in: | |
| # - Makefile | |
| # - ./github/workflows/docs.yaml | |
| # - ./github/workflows/fmt.yaml | |
| # - ./github/workflows/lint.yaml | |
| toolchain: nightly | |
| - name: Build documentation | |
| run: make docs-build | |
| - name: Upload to GitHub Pages | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: website/build | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| # Create and deploy versioned documentation on tag creation | |
| version-docs: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: website/package-lock.json | |
| - name: Install dependencies | |
| run: make docs-install | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Creating version $VERSION" | |
| - name: Create versioned documentation | |
| run: | | |
| cd website | |
| # Create a new version of the documentation | |
| npm run docusaurus docs:version ${{ steps.version.outputs.version }} | |
| - name: Setup build dependencies | |
| run: | | |
| sudo apt update | |
| sudo apt install -y protobuf-compiler | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt | |
| # This should be in line with the verison in: | |
| # - Makefile | |
| # - ./github/workflows/docs.yaml | |
| # - ./github/workflows/fmt.yaml | |
| # - ./github/workflows/lint.yaml | |
| toolchain: nightly | |
| - name: Build versioned documentation | |
| run: make docs-build | |
| env: | |
| NODE_ENV: production | |
| - name: Create versioned documentation archive | |
| run: | | |
| cd website/build | |
| tar -czf "../../mina-docs-${{ steps.version.outputs.version }}.tar.gz" . | |
| cd ../.. | |
| zip -r "mina-docs-${{ steps.version.outputs.version }}.zip" website/build | |
| - name: Upload versioned documentation as release asset | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: versioned-docs-${{ steps.version.outputs.version }} | |
| path: | | |
| mina-docs-${{ steps.version.outputs.version }}.tar.gz | |
| mina-docs-${{ steps.version.outputs.version }}.zip | |
| - name: Upload to GitHub Pages | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: website/build | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |