Skip to content

Commit

Permalink
Major shift in the github actions used.
Browse files Browse the repository at this point in the history
  • Loading branch information
haz committed Dec 24, 2024
1 parent 4133705 commit de23988
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 35 deletions.
85 changes: 50 additions & 35 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/

49 changes: 49 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit de23988

Please sign in to comment.