Skip to content

Commit 8844c09

Browse files
authored
Add support for doc builds on dev/doc (#10)
1 parent b1fd900 commit 8844c09

2 files changed

Lines changed: 42 additions & 26 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Build the edgcpp/compiler documentation at a tag or branch and copy it into
4+
# this site, so Jekyll publishes it with everything else.
5+
#
6+
# Usage: build-compiler-docs.sh <ref> <dest>
7+
#
8+
# <dest> is relative to the site root and is also the URL path the docs are
9+
# served under; for example, "doc" is published at https://edgcpp.org/doc/.
10+
11+
set -euo pipefail
12+
13+
ref="$1"
14+
dest="$2"
15+
clone="$(mktemp -d)"
16+
17+
# Fetch only doc/; a full checkout of the compiler tree is over 3 GB.
18+
git -c advice.detachedHead=false clone --quiet --depth 1 --branch "$ref" \
19+
--filter=blob:none --sparse https://github.com/edgcpp/compiler.git "$clone"
20+
git -C "$clone" sparse-checkout set doc
21+
echo "Building compiler documentation at $ref" \
22+
"($(git -C "$clone" rev-parse --short HEAD)) into $dest/"
23+
24+
docker run --rm \
25+
-v "$clone:/work" \
26+
-w /work/doc \
27+
edgcpp/sphinx-env:latest \
28+
make dirhtml SPHINXOPTS="-D html_baseurl=https://edgcpp.org/$dest/"
29+
30+
mkdir -p "$dest"
31+
cp -a "$clone/doc/build/dirhtml/." "$dest/"

‎.github/workflows/build_and_deploy.yml‎

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
branches-ignore:
66
- master
7+
# edgcpp/compiler triggers this (on develop) when doc/ changes on its main
8+
# branch, to republish https://edgcpp.org/dev/doc/.
9+
workflow_dispatch:
710

811
# Serialize runs (replaces the CircleCI eddiewebb/queue orb).
912
concurrency:
@@ -13,6 +16,8 @@ concurrency:
1316
env:
1417
# Tag of edgcpp/compiler whose documentation is published at
1518
# https://edgcpp.org/doc/. Bump this to publish a newer release's docs.
19+
# The documentation for its main branch is published at
20+
# https://edgcpp.org/dev/doc/.
1621
COMPILER_DOC_REF: '7.0'
1722

1823
jobs:
@@ -22,18 +27,8 @@ jobs:
2227
- uses: actions/checkout@v5
2328
- name: Build compiler documentation
2429
run: |
25-
# Fetch only doc/ at the tag; a full checkout of the tree is over 3 GB.
26-
git -c advice.detachedHead=false clone --depth 1 \
27-
--branch "$COMPILER_DOC_REF" --filter=blob:none --sparse \
28-
https://github.com/edgcpp/compiler.git /tmp/compiler
29-
git -C /tmp/compiler sparse-checkout set doc
30-
docker run --rm \
31-
-v /tmp/compiler:/work \
32-
-w /work/doc \
33-
edgcpp/sphinx-env:latest \
34-
make dirhtml
35-
mkdir -p doc
36-
cp -a /tmp/compiler/doc/build/dirhtml/. doc/
30+
.github/scripts/build-compiler-docs.sh "$COMPILER_DOC_REF" doc
31+
.github/scripts/build-compiler-docs.sh main dev/doc
3732
- uses: ruby/setup-ruby@v1
3833
with:
3934
ruby-version: '4.0'
@@ -50,18 +45,8 @@ jobs:
5045
- uses: actions/checkout@v5
5146
- name: Build compiler documentation
5247
run: |
53-
# Fetch only doc/ at the tag; a full checkout of the tree is over 3 GB.
54-
git -c advice.detachedHead=false clone --depth 1 \
55-
--branch "$COMPILER_DOC_REF" --filter=blob:none --sparse \
56-
https://github.com/edgcpp/compiler.git /tmp/compiler
57-
git -C /tmp/compiler sparse-checkout set doc
58-
docker run --rm \
59-
-v /tmp/compiler:/work \
60-
-w /work/doc \
61-
edgcpp/sphinx-env:latest \
62-
make dirhtml
63-
mkdir -p doc
64-
cp -a /tmp/compiler/doc/build/dirhtml/. doc/
48+
.github/scripts/build-compiler-docs.sh "$COMPILER_DOC_REF" doc
49+
.github/scripts/build-compiler-docs.sh main dev/doc
6550
- uses: ruby/setup-ruby@v1
6651
with:
6752
ruby-version: '4.0'
@@ -78,8 +63,8 @@ jobs:
7863
mv _site/* .
7964
rm -r _site/
8065
# Serve master as-is. Without this, GitHub Pages runs Jekyll over it
81-
# again, which drops the documentation's doc/_static/ and
82-
# doc/_sources/ directories.
66+
# again, which drops the documentation's _static/ and _sources/
67+
# directories.
8368
touch .nojekyll
8469
git config --global user.name "GitHub Actions"
8570
git config --global user.email "actions@edgcpp.org"

0 commit comments

Comments
 (0)