From de239886ee8874f53c348b321a1f56c2073cbd43 Mon Sep 17 00:00:00 2001 From: Christian Muise Date: Mon, 23 Dec 2024 23:59:03 -0500 Subject: [PATCH] Major shift in the github actions used. --- .github/workflows/deploy.yml | 85 +++++++++++++++++++++--------------- .github/workflows/docs.yml | 49 +++++++++++++++++++++ 2 files changed, 99 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4866d6e1..19383323 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,45 +4,60 @@ on: release: types: [published] +permissions: + contents: read + jobs: - publish: - name: Build and publish Python package distributions to PyPI + release-build: runs-on: ubuntu-latest - strategy: - fail-fast: false + steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 with: - python-version: 3.8 - - name: Install pypa/build, pdoc, and other requirements - run: | - python -m pip install build --user - python -m pip install pdoc - python -m pip install -r docs/requirements.txt - - name: Cleanup dist - run: | - rm -rf dist - - name: Build binary wheel and a source tarball - run: | - python -m build --sdist --wheel --outdir dist/ . - - name: Generate Docs + python-version: "3.x" + + - name: Build release distributions run: | - pdoc macq --math -o docs - - name: Push Docs and dist - uses: stefanzweifel/git-auto-commit-action@v4 + # NOTE: put your own distribution build steps here. + python -m pip install build + python -m build + + - name: Upload distributions + uses: actions/upload-artifact@v4 with: - commit_message: "[auto] Update docs and distribution" - branch: main - file_pattern: docs/* dist/* - add_options: "-f" - commit_user_name: github-actions[bot] - commit_user_email: github-actions[bot]@users.noreply.github.com - skip_dirty_check: true - skip_fetch: true - skip_checkout: true - - name: Publish distribution package to PyPI - uses: pypa/gh-action-pypi-publish@master + name: release-dists + path: dist/ + + pypi-publish: + runs-on: ubuntu-latest + needs: + - release-build + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + + # Dedicated environments with protections for publishing are strongly recommended. + # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules + environment: + name: pypi + # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status: + # url: https://pypi.org/p/YOURPROJECT + # + # ALTERNATIVE: if your GitHub Release name is the PyPI project version string + # ALTERNATIVE: exactly, uncomment the following line instead: + # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }} + + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@v4 + with: + name: release-dists + path: dist/ + + - name: Publish release distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 with: - password: ${{ secrets.PYPI_API_TOKEN }} + packages-dir: dist/ + diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..1f35381e --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,49 @@ +name: website + +# build the documentation whenever there are new commits on main +# on: +# release: +# types: [published] +on: + push: + branches: + - main + +# security: restrict permissions for CI jobs. +permissions: + contents: read + +jobs: + # Build the documentation and upload the static HTML files as an artifact. + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.13' + + # ADJUST THIS: install all dependencies (including pdoc) + - run: pip install -e . + # ADJUST THIS: build your documentation into docs/. + # We use a custom build script for pdoc itself, ideally you just run `pdoc -o docs/ ...` here. + - run: pdoc macq --math -o docs + + - uses: actions/upload-pages-artifact@v3 + with: + path: docs/ + + # Deploy the artifact to GitHub pages. + # This is a separate job so that only actions/deploy-pages has the necessary permissions. + deploy: + needs: build + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - id: deployment + uses: actions/deploy-pages@v4