Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test

on:
pull_request:
push:
branches: [v3]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
installer: [pip, uv]
cache: [false, true]
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Required by sphinxnotes-incrbuild when cache is enabled
- id: build
name: Build documentation (installer=${{ matrix.installer }}, cache=${{ matrix.cache }})
uses: ./
with:
installer: ${{ matrix.installer }}
cache: ${{ matrix.cache }}
checkout: false
publish: false
- name: Verify build output
run: test -f "${{ steps.build.outputs.artifact }}/index.html"
17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ Unless you need to highly customize the action's behavior.
Input Default Required Description
-------------------------- ---------------------------- -------- -------------------------------------------------
``python_version`` ``3.12`` false Version of Python
``installer`` ``pip`` false Python package installer used to install
dependencies, ``pip`` or ``uv``
``sphinx_version`` ``latest`` false Version of Sphinx
``sphinx_build_options`` false Additional options passed to ``sphinx-build``
``cache`` ``false`` false Enable cache to speed up documentation building
Expand Down Expand Up @@ -207,6 +209,21 @@ For non-python dependencies, add a step to your workflow file, and install them

__ https://github.com/sphinx-notes/pages/issues/24

Speed up installation with uv
*****************************

Dependencies are installed with pip by default. Set the ``installer`` input to ``uv``
to install them with uv__ instead, which is usually much faster:

.. code:: yaml

- id: deployment
uses: sphinx-notes/pages@v3
with:
installer: uv

__ https://github.com/astral-sh/uv

Customize checkout options
**************************

Expand Down
16 changes: 14 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ inputs:
description: 'Version of Python'
required: false
default: '3.12'
installer:
description: 'Python package installer used to install dependencies, "pip" or "uv"'
required: false
default: 'pip'
sphinx_version:
description: 'Version of Sphinx'
required: false
Expand Down Expand Up @@ -68,16 +72,23 @@ runs:

- name: Setup python
uses: actions/setup-python@v6
if: ${{ inputs.cache == 'true' }}
if: ${{ inputs.cache == 'true' && inputs.installer == 'pip' }}
with:
python-version: ${{ inputs.python_version }}
cache: 'pip'
- name: Setup python
uses: actions/setup-python@v6
if: ${{ inputs.cache == 'false' }}
if: ${{ inputs.cache == 'false' || inputs.installer == 'uv' }}
with:
python-version: ${{ inputs.python_version }}

- name: Setup uv
# setup-uv only publishes exact version tags, no major tags like v9
uses: astral-sh/setup-uv@v9.0.0
if: ${{ inputs.installer == 'uv' }}
with:
enable-cache: ${{ inputs.cache }}

- name: Restore cache
uses: actions/cache@v5
if: ${{ inputs.cache == 'true' }}
Expand All @@ -101,6 +112,7 @@ runs:
INPUT_REQUIREMENTS_PATH: ${{ inputs.requirements_path }}
INPUT_PYPROJECT_EXTRAS: ${{ inputs.pyproject_extras }}
INPUT_PYPROJECT_GROUP: ${{ inputs.pyproject_group }}
INPUT_INSTALLER: ${{ inputs.installer }}
INPUT_SPHINX_VERSION: ${{ inputs.sphinx_version }}
INPUT_CACHE: ${{ inputs.cache }}
INPUT_SPHINX_BUILD_OPTIONS: ${{ inputs.sphinx_build_options }}
Expand Down
33 changes: 25 additions & 8 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,30 @@ echo Documentation: $doc_dir

echo ::endgroup::

if [ "$INPUT_INSTALLER" != "pip" ] && [ "$INPUT_INSTALLER" != "uv" ]; then
echo "::error::Unknown installer '$INPUT_INSTALLER', supported values: pip, uv"
exit 1
fi

pkg_install() {
if [ "$INPUT_INSTALLER" == "uv" ]; then
# --system: install into the interpreter provided by setup-python,
# no virtual environment required.
uv pip install --system "$@"
else
pip3 install "$@"
fi
}

# The actions doesn't depends on any images,
# so we have to try various package manager.
echo ::group:: Installing Sphinx

echo Installing sphinx via pip
echo Installing sphinx via $INPUT_INSTALLER
if [ -z "$INPUT_SPHINX_VERSION" ] ; then
pip3 install -U sphinx
pkg_install -U sphinx
else
pip3 install -U sphinx==$INPUT_SPHINX_VERSION
pkg_install -U sphinx==$INPUT_SPHINX_VERSION
fi

echo Adding ~/.local/bin to system path
Expand All @@ -37,14 +52,14 @@ else
echo Everything goes well
fi

pip3 install -U sphinxnotes-incrbuild>=1.0
pkg_install -U 'sphinxnotes-incrbuild>=1.0'

echo ::endgroup::

if [ ! -z "$INPUT_REQUIREMENTS_PATH" ] ; then
echo ::group:: Installing dependencies declared by $INPUT_REQUIREMENTS_PATH
if [ -f "$INPUT_REQUIREMENTS_PATH" ]; then
pip3 install -r "$INPUT_REQUIREMENTS_PATH"
pkg_install -r "$INPUT_REQUIREMENTS_PATH"
else
echo No $INPUT_REQUIREMENTS_PATH found, skipped
fi
Expand All @@ -54,7 +69,7 @@ fi
if [ ! -z "$INPUT_PYPROJECT_EXTRAS" ] ; then
echo ::group:: Installing dependencies declared by pyproject.toml[$INPUT_PYPROJECT_EXTRAS]
if [ -f "pyproject.toml" ]; then
pip3 install .[$INPUT_PYPROJECT_EXTRAS]
pkg_install .[$INPUT_PYPROJECT_EXTRAS]
else
echo No pyproject.toml found, skipped
fi
Expand All @@ -64,8 +79,10 @@ fi
if [ ! -z "$INPUT_PYPROJECT_GROUP" ] ; then
echo ::group:: Installing dependency group declared by pyproject.toml[$INPUT_PYPROJECT_GROUP]
if [ -f "pyproject.toml" ]; then
pip3 install -U 'pip>=25.1' # --group requires pip 25.1+
pip3 install --group "pyproject.toml:$INPUT_PYPROJECT_GROUP"
if [ "$INPUT_INSTALLER" == "pip" ]; then
pip3 install -U 'pip>=25.1' # --group requires pip 25.1+
fi
pkg_install --group "pyproject.toml:$INPUT_PYPROJECT_GROUP"
else
echo No pyproject.toml found, skipped
fi
Expand Down