diff --git a/.github/workflows/docker-docs.yml b/.github/workflows/docker-docs.yml new file mode 100644 index 0000000..a03b3ac --- /dev/null +++ b/.github/workflows/docker-docs.yml @@ -0,0 +1,39 @@ +name: docs-image + +on: + push: + branches: [ master ] + paths: + - 'docs/Dockerfile' + pull_request: + branches: [ master ] + paths: + - 'docs/Dockerfile' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + env: + IMAGE: ghcr.io/${{ github.repository }} + steps: + - uses: actions/checkout@v4 + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: docs/Dockerfile + push: true + tags: | + ${{ env.IMAGE }}:docs-build diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b0033e7..af14d91 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -7,7 +7,7 @@ on: branches: [ master ] jobs: - build: + test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -25,20 +25,44 @@ jobs: env: FORCE_COLOR: 1 - - name: Install LaTeX dependencies - run: | - sudo apt-get update - sudo apt-get install -y texlive-full latexmk + build-pdf: + runs-on: ubuntu-latest + container: + image: ghcr.io/${{ github.repository }}:docs-build + steps: + - uses: actions/checkout@v4 + + - name: Install Python dependencies + run: uv sync --group docs - name: Build PDF documentation run: uv run make -C docs latexpdf - env: - FORCE_COLOR: 1 - - name: Copy PDF to static directory - run: | - mkdir -p docs/_static - cp docs/_build/latex/argclass.pdf docs/_static/ + - name: Upload PDF artifact + uses: actions/upload-artifact@v4 + with: + name: documentation-pdf + path: docs/_build/latex/argclass.pdf + + build-html: + needs: build-pdf + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup uv + uses: astral-sh/setup-uv@v4 + with: + python-version: "3.12" + + - name: Install Python dependencies + run: uv sync --group docs + + - name: Download PDF artifact + uses: actions/download-artifact@v4 + with: + name: documentation-pdf + path: docs/_static - name: Build HTML documentation run: uv run make -C docs html @@ -51,14 +75,8 @@ jobs: name: documentation path: docs/_build/html - - name: Upload PDF documentation - uses: actions/upload-artifact@v4 - with: - name: documentation-pdf - path: docs/_build/latex/argclass.pdf - publish: - needs: build + needs: build-html runs-on: ubuntu-latest container: rclone/rclone:latest if: github.event_name == 'push' && github.ref == 'refs/heads/master' diff --git a/docs/Dockerfile b/docs/Dockerfile index 299aeee..97d7611 100644 --- a/docs/Dockerfile +++ b/docs/Dockerfile @@ -1,5 +1,8 @@ FROM python:3.13-slim +LABEL org.opencontainers.image.source="https://github.com/mosquito/argclass" +LABEL org.opencontainers.image.description="LaTeX build environment for argclass docs" + # Install LaTeX (full distribution) and required packages RUN apt-get update && apt-get install -y --no-install-recommends \ texlive-full \ diff --git a/docs/Makefile b/docs/Makefile index c1a6cd4..020e31f 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -2,7 +2,7 @@ SPHINXOPTS ?= -W SPHINXBUILD ?= uv run --group docs sphinx-build SOURCEDIR = . BUILDDIR = _build -DOCKER_IMAGE = argclass-docs +DOCKER_IMAGE ?= ghcr.io/mosquito/argclass:docs-build .PHONY: help clean html latexpdf pdf docker-pdf test all @@ -33,9 +33,11 @@ latexpdf: pdf: latexpdf # Build PDF using Docker (no local LaTeX installation needed) +# Override DOCKER_IMAGE to use a local build: +# make docker-pdf DOCKER_IMAGE=argclass-docs-local docker-pdf: - @echo "Building Docker image..." - docker build -t $(DOCKER_IMAGE) -f Dockerfile .. + @echo "Pulling Docker image $(DOCKER_IMAGE)..." + -docker pull $(DOCKER_IMAGE) @echo "Installing dependencies and building LaTeX sources..." docker run --rm -v $(CURDIR)/..:/project -w /project $(DOCKER_IMAGE) \ sh -c "uv sync --group docs && uv run --group docs sphinx-build -W -b latex docs docs/_build/latex"