|
| 1 | +name: Build and Deploy Book |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +# Allow the deploy job to publish to GitHub Pages. |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + pages: write |
| 14 | + id-token: write |
| 15 | + |
| 16 | +# Allow only one concurrent deployment; let in-progress runs finish. |
| 17 | +concurrency: |
| 18 | + group: pages |
| 19 | + cancel-in-progress: false |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + name: Build book |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + # Installs the toolchain pinned in `lean-toolchain`, runs `lake build` |
| 30 | + # (elaborating every chapter / type-checking all proofs), and caches |
| 31 | + # `.lake` so the verso and iris-lean dependency builds are reused. |
| 32 | + - name: Build and check proofs |
| 33 | + uses: leanprover/lean-action@v1 |
| 34 | + with: |
| 35 | + build: true |
| 36 | + |
| 37 | + # `lake build` above already compiled everything; this runs the |
| 38 | + # `textbook` executable to render the HTML book and extract the |
| 39 | + # example code into `_out/`. |
| 40 | + - name: Render book and extract example code |
| 41 | + run: lake exe textbook |
| 42 | + |
| 43 | + - name: Assemble site (html + code.zip) |
| 44 | + run: | |
| 45 | + rm -rf _site |
| 46 | + mkdir -p _site |
| 47 | + cp -r _out/html-multi/. _site/ |
| 48 | + (cd _out && zip -r "$GITHUB_WORKSPACE/_site/code.zip" example-code) |
| 49 | +
|
| 50 | + # On PRs the full build above already runs, catching breakage early. |
| 51 | + # Only upload the Pages artifact for push/manual runs that will deploy |
| 52 | + # (this also avoids restricted-permission warnings on PRs from forks). |
| 53 | + - name: Upload Pages artifact |
| 54 | + if: github.event_name != 'pull_request' |
| 55 | + uses: actions/upload-pages-artifact@v3 |
| 56 | + with: |
| 57 | + path: _site |
| 58 | + |
| 59 | + deploy: |
| 60 | + name: Deploy to GitHub Pages |
| 61 | + needs: build |
| 62 | + runs-on: ubuntu-latest |
| 63 | + # Publish only for pushes to main and manual runs — never for PRs. |
| 64 | + if: github.event_name != 'pull_request' |
| 65 | + environment: |
| 66 | + name: github-pages |
| 67 | + url: ${{ steps.deployment.outputs.page_url }} |
| 68 | + steps: |
| 69 | + - name: Deploy |
| 70 | + id: deployment |
| 71 | + uses: actions/deploy-pages@v4 |
0 commit comments