|
| 1 | +name: Build hexdoc book |
| 2 | +description: Builds a hexdoc book. |
| 3 | +author: hexdoc-dev |
| 4 | + |
| 5 | +inputs: |
| 6 | + release: |
| 7 | + description: "Boolean: if the book should be written to the release path (true) or the latest path (false)" |
| 8 | + required: true |
| 9 | + python-version: |
| 10 | + description: Python version to install |
| 11 | + required: false |
| 12 | + default: "3.11" |
| 13 | + props: |
| 14 | + description: Path to your props file (hexdoc.toml or properties.toml) |
| 15 | + required: false |
| 16 | + pip-extras: |
| 17 | + description: Pip extras for your package (eg. "[dev]") |
| 18 | + required: false |
| 19 | + subdirectory: |
| 20 | + description: Subdirectory to deploy the book to |
| 21 | + required: false |
| 22 | + site-url: |
| 23 | + description: Set the base site url instead of looking up the current repo's GitHub Pages url |
| 24 | + required: false |
| 25 | + pages-artifact: |
| 26 | + description: Name of the GitHub Pages artifact to upload |
| 27 | + required: false |
| 28 | + default: hexdoc-pages |
| 29 | + build-artifact: |
| 30 | + description: Name of the Python build artifact to upload |
| 31 | + required: false |
| 32 | + default: hexdoc-build |
| 33 | + use-artifacts-v3: |
| 34 | + description: If true, use actions/upload-artifact@v3 instead of actions/upload-artifact@v4 |
| 35 | + required: false |
| 36 | + default: "false" |
| 37 | + |
| 38 | +outputs: |
| 39 | + pages-url: |
| 40 | + description: Current GitHub Pages url for this repo |
| 41 | + value: ${{ steps.export.outputs.pages-url }} |
| 42 | + release: |
| 43 | + description: Value of inputs.release for convenience |
| 44 | + value: ${{ inputs.release }} |
| 45 | + |
| 46 | +runs: |
| 47 | + using: composite |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v3 |
| 50 | + - uses: actions/setup-python@v4 |
| 51 | + with: |
| 52 | + python-version: ${{ inputs.python-version }} |
| 53 | + cache: pip |
| 54 | + - uses: yezz123/setup-uv@v4 |
| 55 | + |
| 56 | + - name: Install display server |
| 57 | + uses: awalsh128/cache-apt-pkgs-action@v1 |
| 58 | + with: |
| 59 | + packages: xvfb |
| 60 | + |
| 61 | + - name: Install Python packages |
| 62 | + shell: bash |
| 63 | + run: uv pip install --system -e .${{ inputs.pip-extras }} hatch |
| 64 | + |
| 65 | + - name: Build web book |
| 66 | + id: export |
| 67 | + env: |
| 68 | + HEXDOC_PROPS: ${{ inputs.props }} |
| 69 | + HEXDOC_RELEASE: ${{ inputs.release }} |
| 70 | + HEXDOC_SUBDIRECTORY: ${{ inputs.subdirectory }} |
| 71 | + GITHUB_PAGES_URL: ${{ inputs.site-url }} |
| 72 | + shell: bash |
| 73 | + run: xvfb-run --auto-servernum hexdoc ci build |
| 74 | + |
| 75 | + - name: Zip web book |
| 76 | + working-directory: _site/src/docs |
| 77 | + shell: bash |
| 78 | + run: zip site.zip ./* -r |
| 79 | + |
| 80 | + - name: Upload intermediate Pages artifact (v4) |
| 81 | + if: inputs.use-artifacts-v3 != 'true' |
| 82 | + uses: actions/upload-artifact@v4 |
| 83 | + with: |
| 84 | + name: ${{ inputs.pages-artifact }} |
| 85 | + path: _site/src/docs/site.zip |
| 86 | + |
| 87 | + - name: Upload package artifact (v4) |
| 88 | + if: inputs.use-artifacts-v3 != 'true' |
| 89 | + uses: actions/upload-artifact@v4 |
| 90 | + with: |
| 91 | + name: ${{ inputs.build-artifact }} |
| 92 | + path: dist |
| 93 | + |
| 94 | + - name: Upload intermediate Pages artifact (v3) |
| 95 | + if: inputs.use-artifacts-v3 == 'true' |
| 96 | + uses: actions/upload-artifact@v3 |
| 97 | + with: |
| 98 | + name: ${{ inputs.pages-artifact }} |
| 99 | + path: _site/src/docs/site.zip |
| 100 | + |
| 101 | + - name: Upload package artifact (v3) |
| 102 | + if: inputs.use-artifacts-v3 == 'true' |
| 103 | + uses: actions/upload-artifact@v3 |
| 104 | + with: |
| 105 | + name: ${{ inputs.build-artifact }} |
| 106 | + path: dist |
| 107 | + |
| 108 | + - name: Add job summary |
| 109 | + shell: bash |
| 110 | + run: echo "Built version \`$(hatch version)\` from commit \`$(git rev-parse --short "$GITHUB_SHA")\`." >> $GITHUB_STEP_SUMMARY |
0 commit comments