From cadfc0bd4231b17648e34afc01d1078249236dad Mon Sep 17 00:00:00 2001 From: Peter Kok Date: Thu, 4 Jul 2024 15:18:23 +0200 Subject: [PATCH] Publish documentation to github pages --- .github/workflows/build-and-test.yml | 24 +++++++++++++++++++++--- .github/workflows/publish.yml | 21 ++++++++++++++++++++- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index fb5a48a..5ca4a73 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -34,6 +34,7 @@ jobs: python-version: ${{ matrix.python-version }} # Get the version from pyproject.toml + # This will be used to tag the release in the publishing workflow - name: Install toml package run: pip install toml - name: Get version from pyproject.toml @@ -43,21 +44,38 @@ jobs: echo Version: $VERSION echo "version=$VERSION" >> $GITHUB_OUTPUT + # Installation - name: Install dependencies run: | python -m pip install poetry poetry install - # - name: Build the docs # just to see whether the build passes - # run: | - # poetry run mkdocs build + + # Testing and checking - name: Test with pytest run: | poetry run pytest + - name: Type check + run: | + poetry run pytype . + + # Build the package - name: Build the package run: | poetry build - name: Archive build artifacts uses: actions/upload-artifact@v4 + if: github.ref == 'refs/heads/release' with: name: build-artifacts path: dist/ + + # Build the docs + - name: Build the docs + run: | + poetry run make html --directory docs + - name: Archive documentation + uses: actions/upload-artifact@v4 + if: github.ref == 'refs/heads/release' + with: + name: docs-html + path: docs/_build/html/ diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 288b48f..9db8dd7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,7 +2,7 @@ # https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#workflow-definition # https://github.com/marketplace/actions/pypi-publish -name: Publish to PyPI +name: Publish package and docs on: push: @@ -94,3 +94,22 @@ jobs: gh release upload "v${VERSION}" dist/** --repo '${{ github.repository }}' + + + publish-docs: + name: Publish documentation + needs: build-and-test + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Download the documentation + uses: actions/download-artifact@v4 + with: + name: docs-html + path: docs/ + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/