CI: ensure Python >=3 is installed when building the documentation #284
Workflow file for this run
This file contains 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 & Deploy static content to GitHub Pages | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
build: | |
# build on macos until bindgen is fixed | |
runs-on: macos-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# sphinx-multiversion uses tags to build | |
# the documentation in multiple versions. | |
- name: Checkout | Fetch tags | |
run: git fetch --tags origin | |
- name: Setup | mdBook | 1/2 | |
uses: hecrj/setup-rust-action@f344d1a51e8ad6e1c6c51d9cf8d5a6edf4cfd230 | |
- name: Setup | mdBook | 2/2 | |
uses: peaceiris/actions-mdbook@4b5ef36b314c2599664ca107bb8c02412548d79d | |
with: | |
mdbook-version: "latest" | |
- name: Setup | System | |
run: | | |
brew install doxygen sphinx-doc gmp ninja node | |
pip install --upgrade pip | |
- name: Setup | OCaml | 1/2 | |
uses: ocaml/setup-ocaml@v2 | |
with: | |
ocaml-compiler: 4.14.1 | |
- name: Setup | OCaml | 2/2 | |
run: | | |
opam install --yes ocamlfind odoc ctypes zarith cppo dune | |
- name: Setup | JS | |
run: | | |
npm install -g jsdoc | |
- name: Setup | Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Setup | Sphinx | |
run: | | |
cd docs/reference | |
pip install -r requirements.txt | |
- name: Build | Book | |
run: | | |
# We `cd` into this directory first because the book | |
# uses references relative to this directory, i.e., | |
# `../../../rust/src/aead.rs`. | |
pushd docs/book | |
mdbook build | |
popd | |
mv docs/book/book build | |
- name: Build | C API Reference | |
run: | | |
mkdir build/c | |
sphinx-multiversion docs/reference build/c | |
- name: Build | OCaml API Reference | |
run: | | |
mkdir -p build/ocaml/main | |
./opam.sh | |
cd opam | |
eval $(opam env) | |
opam install . --yes | |
dune build @doc --only-packages=hacl-star | |
cp -r _build/default/_doc/_html/* ../build/ocaml/main/ | |
# TODO: #423 ctypes.stubs need to be added to old tags to build documentation. | |
# https://github.com/cryspen/hacl-packages/commit/81303b83a54a92d3b5f54f1b8ddbea60438cc2bf | |
# - name: Build | OCaml API Reference for Tags | |
# run: | | |
# mkdir -p build/ocaml | |
# for branch in $(git for-each-ref --format='%(refname)' refs/tags/); do | |
# if [[ "$branch" == *"ocaml-"* ]]; then | |
# rm -rf opam | |
# tag=$(echo $branch | cut -d'/' -f 3) | |
# git checkout $tag | |
# echo "Building documentation for $tag" | |
# mkdir -p build/ocaml/$tag | |
# ./opam.sh | |
# cd opam | |
# eval $(opam env) | |
# opam install . --yes | |
# dune build @doc --only-packages=hacl-star | |
# cp -r _build/default/_doc/_html/* ../build/ocaml/$tag/ | |
# cd ../ | |
# fi | |
# done | |
- name: Build | JS API Reference | |
run: | | |
git checkout main | |
cp -r js/* src/wasm | |
cd src/wasm | |
mkdir doc | |
node api_doc.js | |
jsdoc doc/readable_api.js -d doc/out | |
cd ../.. | |
mkdir -p build/js | |
cp -r src/wasm/doc/out build/js/main | |
- name: Build | Rust Docs | |
run: | | |
mkdir -p build/rust | |
cd rust/hacl-sys | |
cargo doc --no-deps | |
cp -r target/doc ../../build/rust/main | |
cd ../ | |
cargo doc --no-deps --all-features | |
cp -r target/doc/* ../build/rust/main | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: "build" | |
deploy: | |
if: ${{ github.ref == 'refs/heads/main' }} | |
needs: build | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-22.04 | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow one concurrent deployment | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
steps: | |
- name: Setup | Pages | |
uses: actions/configure-pages@v2 | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v1 |