diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 70c94b1..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,22 +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 make html --directory docs + + # Testing and checking - name: Test with pytest run: | poetry run pytest - # TODO: run pytype here? + - 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 aae468c..789c242 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/