Skip to content

Commit b7c1eed

Browse files
committed
Move documentation into build workflow so that it is guaranteed to run after wheel build
1 parent 31d5cf8 commit b7c1eed

File tree

1 file changed

+94
-1
lines changed

1 file changed

+94
-1
lines changed

.github/workflows/build.yml

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,100 @@ jobs:
271271
with:
272272
name: dist
273273
pattern: dist-*
274-
274+
275+
# Documentation build job that runs after wheels are built
276+
build-docs:
277+
name: Build docs
278+
runs-on: ubuntu-latest
279+
needs: [build-manylinux-x86_64] # Only need the Linux wheel for docs
280+
# Only run docs on main branch pushes, tags, or PRs
281+
if: github.event_name == 'push' || github.event_name == 'pull_request'
282+
steps:
283+
- name: Set target branch
284+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
285+
id: target-branch
286+
run: |
287+
set -x
288+
if test '${{ github.ref }}' = 'refs/heads/main'; then
289+
echo "value=asf-staging" >> "$GITHUB_OUTPUT"
290+
elif test '${{ github.ref_type }}' = 'tag'; then
291+
echo "value=asf-site" >> "$GITHUB_OUTPUT"
292+
else
293+
echo "Unsupported input: ${{ github.ref }} / ${{ github.ref_type }}"
294+
exit 1
295+
fi
296+
297+
- name: Checkout docs sources
298+
uses: actions/checkout@v5
299+
300+
- name: Checkout docs target branch
301+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
302+
uses: actions/checkout@v5
303+
with:
304+
fetch-depth: 0
305+
ref: ${{ steps.target-branch.outputs.value }}
306+
path: docs-target
307+
308+
- name: Setup Python
309+
uses: actions/setup-python@v5
310+
with:
311+
python-version: "3.11"
312+
313+
- name: Install dependencies
314+
uses: astral-sh/setup-uv@v6
315+
with:
316+
enable-cache: true
317+
318+
# Download the Linux wheel built in the previous job
319+
- name: Download pre-built Linux wheel
320+
uses: actions/download-artifact@v5
321+
with:
322+
name: dist-manylinux-x86_64
323+
path: wheels/
324+
325+
# Install from the pre-built wheel
326+
- name: Install from pre-built wheel
327+
run: |
328+
set -x
329+
uv venv
330+
# Install documentation dependencies
331+
uv sync --dev --no-install-package datafusion --group docs
332+
# Install the pre-built wheel
333+
WHEEL=$(find wheels/ -name "*.whl" | head -1)
334+
if [ -n "$WHEEL" ]; then
335+
echo "Installing wheel: $WHEEL"
336+
uv pip install "$WHEEL"
337+
else
338+
echo "ERROR: No wheel found!"
339+
exit 1
340+
fi
341+
342+
- name: Build docs
343+
run: |
344+
set -x
345+
cd docs
346+
curl -O https://gist.githubusercontent.com/ritchie46/cac6b337ea52281aa23c049250a4ff03/raw/89a957ff3919d90e6ef2d34235e6bf22304f3366/pokemon.csv
347+
curl -O https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-01.parquet
348+
uv run --no-project make html
349+
350+
- name: Copy & push the generated HTML
351+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
352+
run: |
353+
set -x
354+
cd docs-target
355+
# delete anything but: 1) '.'; 2) '..'; 3) .git/
356+
find ./ | grep -vE "^./$|^../$|^./.git" | xargs rm -rf
357+
cp ../.asf.yaml .
358+
cp -r ../docs/build/html/* .
359+
git status --porcelain
360+
if [ "$(git status --porcelain)" != "" ]; then
361+
git config user.name "github-actions[bot]"
362+
git config user.email "github-actions[bot]@users.noreply.github.com"
363+
git add --all
364+
git commit -m 'Publish built docs triggered by ${{ github.sha }}'
365+
git push || git push --force
366+
fi
367+
275368
# NOTE: PyPI publish needs to be done manually for now after release passed the vote
276369
# release:
277370
# name: Publish in PyPI

0 commit comments

Comments
 (0)