Skip to content

Build the web book

Build the web book #16

Workflow file for this run

name: Build the web book
on:
workflow_dispatch:
inputs:
minecraft-version:
description: Minecraft version to export
type: choice
options:
- '1.20.2'
- '1.20.1'
- '1.19.2'
- '1.18.2'
release:
description: Release this version
type: boolean
default: false
publish:
description: Package index to publish to
type: choice
options:
- none
- PyPI
env:
HATCH_GRADLE_DIR: versions/${{ inputs.minecraft-version }}
HEXDOC_PROPS: versions/${{ inputs.minecraft-version }}/hexdoc.toml
HEXDOC_RELEASE: ${{ inputs.release }}
PYPI_PACKAGE: hexdoc-minecraft
PYTHON_VERSION: '3.11'
permissions:
contents: read
pages: read
jobs:
build:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
pages: read
outputs:
pages-url: ${{ steps.export.outputs.pages-url }}
matrix: ${{ steps.export.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
- name: Install display server
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: xvfb
- name: Install Python packages
run: pip install -e . hatch
- name: Fetch Minecraft client jar
env:
GITHUB_PAGES_URL: # because otherwise hexdoc complains
run: hexdoc-minecraft fetch
- name: Extract Minecraft assets
env:
GITHUB_PAGES_URL:
run: hexdoc-minecraft unzip
- name: Export common data
id: export
run: xvfb-run --auto-servernum hexdoc ci export
- name: Upload hexdoc cache artifact
uses: actions/upload-artifact@v3
with:
name: hexdoc-cache
path: .hexdoc
- name: Upload temporary Pages artifact
uses: actions/upload-artifact@v3
with:
name: github-pages-tmp
path: _site
- name: Upload package artifact
uses: actions/upload-artifact@v3
with:
name: hexdoc-build
path: dist
- name: Add job summary
run: echo "Built version \`$(hatch version)\` from commit \`$(git rev-parse --short "$GITHUB_SHA")\`." >> $GITHUB_STEP_SUMMARY
deploy-pages:
needs: build
runs-on: ubuntu-latest
concurrency:
group: hexdoc-deploy-pages
cancel-in-progress: false
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Download temporary Pages artifact
uses: actions/download-artifact@v3
with:
name: github-pages-tmp
path: _site
- name: Deploy to Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: _site
target-folder: docs
clean: false
publish-pypi:
runs-on: ubuntu-latest
needs: [build, deploy-pages]
if: inputs.release == true && inputs.publish == 'PyPI'
concurrency:
group: pypi
cancel-in-progress: false
environment:
name: pypi
url: https://pypi.org/p/${{ env.PYPI_PACKAGE }}
permissions:
id-token: write
steps:
- name: Download package artifact
uses: actions/download-artifact@v3
with:
name: hexdoc-build
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1