Merge pull request #475 from david-christiansen/readme-links #1069
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: Build book | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.ref }} # Group runs by the ref (branch or PR) | |
| cancel-in-progress: true # Cancel any ongoing runs in the same group | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: leanprover/lean-action@v1 | |
| with: | |
| build: false | |
| test: false | |
| use-mathlib-cache: true | |
| use-github-cache: false | |
| # We manage the Lake cache ourselves rather than using | |
| # lean-action's built-in caching because lean-action saves the | |
| # cache before we generate the site. As a result, Verso and its | |
| # HTML artifacts would never be cached. | |
| - name: Restore Lake cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: .lake | |
| key: lake-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}-${{ github.sha }} | |
| restore-keys: lake-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }} | |
| - name: Build project | |
| run: lake build | |
| - name: Build doc-gen | |
| run: lake -R -Kenv=dev build Analysis:docs | |
| - name: Build book | |
| id: build-site | |
| run: | | |
| SITE_PATH="$(lake query :literateHtml)" | |
| echo "Generated site at: $SITE_PATH" | |
| echo "path=$SITE_PATH" >> "$GITHUB_OUTPUT" | |
| mkdir -p _site | |
| cp -r "$SITE_PATH/." _site | |
| - name: Copy docs to site | |
| run: cp -r .lake/build/doc _site/docs | |
| - name: Remove unnecessary Lake files from docs | |
| run: | | |
| find _site/docs -name "*.trace" -delete | |
| find _site/docs -name "*.hash" -delete | |
| - name: Save Lake cache | |
| if: always() | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: .lake | |
| key: lake-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}-${{ github.sha }} | |
| - name: Upload website | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: _site | |
| deploy: | |
| # Add a dependency to the build job | |
| needs: build | |
| # Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
| permissions: | |
| pages: write # to deploy to Pages | |
| id-token: write # to verify the deployment originates from an appropriate source | |
| # Deploy to the github-pages environment | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| # Specify runner + deployment step | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |