2023-08-07 01:27:52 +02:00
|
|
|
name: Build the web book
|
2022-05-21 17:56:52 +02:00
|
|
|
|
2022-05-21 18:42:05 +02:00
|
|
|
on:
|
|
|
|
push:
|
2023-08-07 01:27:52 +02:00
|
|
|
workflow_dispatch:
|
2023-08-28 07:41:53 +02:00
|
|
|
inputs:
|
|
|
|
publish:
|
|
|
|
description: Whether to publish the docgen to PyPI.
|
|
|
|
type: boolean
|
|
|
|
default: false
|
|
|
|
segment:
|
|
|
|
description: The version segment to bump with Hatch.
|
|
|
|
type: string
|
|
|
|
required: false
|
2022-05-21 17:56:52 +02:00
|
|
|
|
2023-08-28 01:21:09 +02:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
|
|
|
concurrency:
|
2023-08-28 07:45:38 +02:00
|
|
|
group: "hexdoc"
|
2023-08-28 01:21:09 +02:00
|
|
|
cancel-in-progress: false
|
|
|
|
|
2022-05-21 17:56:52 +02:00
|
|
|
jobs:
|
2023-08-28 01:06:20 +02:00
|
|
|
build:
|
2022-05-21 17:56:52 +02:00
|
|
|
runs-on: ubuntu-latest
|
2023-08-28 07:41:53 +02:00
|
|
|
# only execute on the default branch or when invoked manually
|
2023-08-28 01:21:09 +02:00
|
|
|
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || github.event_name == 'workflow_dispatch'
|
2023-08-28 01:06:20 +02:00
|
|
|
|
2022-05-21 17:56:52 +02:00
|
|
|
steps:
|
2023-08-28 07:41:53 +02:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: "3.11"
|
2023-08-07 01:27:52 +02:00
|
|
|
|
2023-08-28 07:41:53 +02:00
|
|
|
- name: Install docgen
|
|
|
|
run: pip install . hatch
|
2023-08-07 01:27:52 +02:00
|
|
|
|
2023-08-28 07:41:53 +02:00
|
|
|
- name: Bump version
|
|
|
|
if: inputs.segment
|
|
|
|
run: hatch version ${{ inputs.segment }}
|
|
|
|
|
|
|
|
- name: Commit updated version
|
|
|
|
if: inputs.segment
|
|
|
|
uses: stefanzweifel/git-auto-commit-action@v4
|
|
|
|
with:
|
|
|
|
commit_message: Bump version from ${{ github.ref }}
|
2023-08-07 01:27:52 +02:00
|
|
|
|
2023-08-28 07:41:53 +02:00
|
|
|
- name: Generate web book
|
|
|
|
run: hexdoc doc/properties.toml --ci -o out
|
|
|
|
|
|
|
|
- name: Build docgen
|
|
|
|
run: hatch build
|
|
|
|
|
|
|
|
- name: Upload hexdoc artifact
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: hexdoc-build
|
|
|
|
path: dist/
|
|
|
|
|
|
|
|
- name: Copy build to Pages
|
|
|
|
run: |
|
|
|
|
mkdir out/dist
|
|
|
|
cp dist/*.whl out/dist/latest.whl
|
|
|
|
cp dist/*.tar.gz out/dist/latest.tar.gz
|
2023-08-07 01:27:52 +02:00
|
|
|
|
2023-08-28 07:48:16 +02:00
|
|
|
- name: Fix permissions
|
|
|
|
run: |
|
|
|
|
chmod -c -R +rX "out/" | while read line; do
|
|
|
|
echo "::warning title=Invalid file permissions automatically fixed::$line"
|
|
|
|
done
|
|
|
|
|
2023-08-28 07:41:53 +02:00
|
|
|
- name: Upload Pages artifact
|
|
|
|
uses: actions/upload-pages-artifact@v2
|
|
|
|
with:
|
2023-08-28 07:48:16 +02:00
|
|
|
path: out/
|
2023-08-28 01:06:20 +02:00
|
|
|
|
2023-08-28 07:41:53 +02:00
|
|
|
deploy-pages:
|
2023-08-28 01:06:20 +02:00
|
|
|
runs-on: ubuntu-latest
|
2023-08-28 01:21:09 +02:00
|
|
|
needs: build
|
2023-08-28 01:06:20 +02:00
|
|
|
|
|
|
|
environment:
|
|
|
|
name: github-pages
|
|
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
|
|
|
2023-08-28 07:45:38 +02:00
|
|
|
permissions:
|
|
|
|
id-token: write
|
|
|
|
pages: write
|
|
|
|
|
2023-08-28 01:06:20 +02:00
|
|
|
steps:
|
|
|
|
- name: Deploy to Pages
|
|
|
|
id: deployment
|
|
|
|
uses: actions/deploy-pages@v2
|
2023-08-28 07:41:53 +02:00
|
|
|
|
|
|
|
publish:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: build
|
|
|
|
if: inputs.publish == true
|
|
|
|
|
|
|
|
environment:
|
|
|
|
name: testpypi
|
|
|
|
url: https://pypi.org/p/hexdoc
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
id-token: write
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Download hexdoc artifact
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: hexdoc-build
|
|
|
|
|
|
|
|
- name: Publish to TestPyPI
|
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
|
|
with:
|
|
|
|
repository-url: https://test.pypi.org/simple/
|