Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# CI and releases

The build workflow checks pushes and pull requests. It builds a universal wheel from the source
archive, checks Ruff and documentation, and tests the installed wheel on Apple Silicon and Intel
with Python 3.10–3.14 and free-threaded 3.13t/3.14t, both with and without optional dependencies.
Python 3.14 also installs and tests the source archive on both architectures. Metal tests skip
when a runner has no Metal device; a passing job with those skips does not validate GPU transfers.

To publish, run **Publish release** manually on the default branch and select PyPI, GitHub Releases,
or both. With neither selected, it only builds and validates. All validation jobs must pass before
publication. The version in `pyproject.toml` determines the release tag (`v0.2.0` for this version).
Use a new version for each release; existing releases and packages are not overwritten.

Before the first PyPI publication, configure a GitHub trusted publisher on PyPI for owner `cansik`,
repository `syphon-python`, workflow `publish.yml`, and environment `pypi`. Create that GitHub
environment and configure any desired reviewer protection. Publication uses OIDC and needs no
PyPI API token. See the [PyPI trusted publishing guide](https://docs.pypi.org/trusted-publishers/adding-a-publisher/).

For documentation hosting, select **GitHub Actions** as the repository's Pages source. The
**Publish documentation** workflow runs manually or on pushed `v*` tags. Tags created by the
release workflow's `GITHUB_TOKEN` do not trigger another workflow, so run documentation publication
manually after those releases.

140 changes: 84 additions & 56 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,96 @@
name: Build
name: Build and test

on:
push:
branches: ['**']
pull_request:
workflow_dispatch:
inputs:
publishReleases:
description: 'Publish to Releases'
required: false
default: 'true'
workflow_call:
outputs:
version:
description: Package version from pyproject.toml
value: ${{ jobs.build.outputs.version }}

permissions:
contents: read

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ 'macos-latest' ]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]

runs-on: ${{ matrix.os }}

name: ${{ github.event.inputs.tag }} python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: macos-15
timeout-minutes: 30
outputs:
version: ${{ steps.metadata.outputs.version }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
python-version: ${{ matrix.python-version }}

- name: Switch to Workspace
run: |
echo ${{ github.workspace }}
cd ${{ github.workspace }}

- name: Get Library Version
id: get_version
run: |
pip install setuptools

lib_version=$(python setup.py --version)
echo "Library Version: $lib_version"

echo ::set-output name=version::"$lib_version"
echo ::set-output name=v_version::"v$lib_version"

- name: Preqrequisites
submodules: recursive
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
id: python
with:
python-version: '3.14'
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
with:
version: '0.11.29'
- name: Ensure the Xcode Metal compiler is available
run: xcrun metal --version || xcodebuild -downloadComponent MetalToolchain
- name: Install development dependencies
env:
UV_PYTHON: ${{ steps.python.outputs.python-path }}
run: uv sync --locked --group docs --extra numpy --extra opengl
- name: Check formatting and lint
run: |
git submodule update --init --recursive

# run build command
- name: Build
uv run --no-sync ruff check .
uv run --no-sync ruff format --check .
- name: Build source archive and universal wheel from it
run: uv build
- name: Validate distributions
run: uv run --no-sync pytest tests/test_distributions.py --dist-dir dist
- name: Build documentation
run: uv run --no-sync python scripts/generate_doc.py
- name: Read package version
id: metadata
run: |
python -m pip install -r dev-requirements.txt
python setup.py build
python setup.py bdist_wheel --plat-name=macosx_10_9_universal2
ls dist
.venv/bin/python -c 'import tomllib; print("version=" + tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])' >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: python-dist
path: |
dist/*.whl
dist/*.tar.gz
if-no-files-found: error

# upload dist
- name: Upload binaries to release
if: ${{ github.event.inputs.publishReleases == 'true' }}
uses: svenstaro/upload-release-action@v2
test:
needs: build
name: Python ${{ matrix.python }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [macos-15, macos-15-intel]
python: ['3.10', '3.11', '3.12', '3.13', '3.14', '3.13t', '3.14t']
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
id: python
with:
python-version: ${{ matrix.python }}
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
with:
version: '0.11.29'
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*.whl
tag: ${{ steps.get_version.outputs.v_version }}
release_name: "Version ${{ steps.get_version.outputs.version }}"
body: "Prebuilt wheel packages version ${{ steps.get_version.outputs.version }}."
overwrite: true
file_glob: true
name: python-dist
path: dist
- name: Ensure the Xcode Metal compiler is available for source builds
if: matrix.python == '3.14'
run: xcrun metal --version || xcodebuild -downloadComponent MetalToolchain
- name: Test installed wheel with and without extras
env:
TEST_PYTHON: ${{ steps.python.outputs.python-path }}
TEST_VARIANT: ${{ endsWith(matrix.python, 't') && 'free-threaded' || 'standard' }}
TEST_SOURCE: ${{ matrix.python == '3.14' && 'true' || 'false' }}
run: bash scripts/ci_test.sh
59 changes: 30 additions & 29 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
name: Publish Docs
name: Publish documentation

# build the documentation whenever there are new commits on main
on:
workflow_dispatch:
push:
# Alternative: only build for tags.
tags:
- '*'
tags: ['v*']

# security: restrict permissions for CI jobs.
permissions:
contents: read

concurrency:
group: github-pages
cancel-in-progress: false

jobs:
# Build the documentation and upload the static HTML files as an artifact.
build:
runs-on: 'macos-latest'
runs-on: macos-15
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
python-version: '3.10'

- name: Preqrequisites
run: |
git submodule update --init --recursive

# install relevant files
- run: pip install -r dev-requirements.txt
- run: pip install -r requirements.txt
- run: python setup.py build

# build documentation into docs/.
- run: python setup.py doc

- uses: actions/upload-pages-artifact@v2
submodules: recursive
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
id: python
with:
python-version: '3.14'
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
with:
version: '0.11.29'
- name: Ensure the Xcode Metal compiler is available
run: xcrun metal --version || xcodebuild -downloadComponent MetalToolchain
- name: Install documentation dependencies
env:
UV_PYTHON: ${{ steps.python.outputs.python-path }}
run: uv sync --locked --no-dev --group docs --extra numpy
- name: Generate documentation
run: uv run --no-sync python scripts/generate_doc.py
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: docs/
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
timeout-minutes: 10
permissions:
pages: write
id-token: write
Expand All @@ -51,4 +52,4 @@ jobs:
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
94 changes: 64 additions & 30 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,76 @@
name: Publish Python Package to PyPI
name: Publish release

on:
workflow_dispatch:
inputs:
tag:
description: 'Version Tag'
required: false
default: 'v0.1.0'
publish_pypi:
description: Publish to PyPI (requires the pypi trusted publisher)
type: boolean
default: false
publish_release:
description: Create a GitHub release and upload distributions
type: boolean
default: false

permissions:
contents: read

jobs:
deploy:
guard:
runs-on: ubuntu-latest
environment: production

timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Require the default branch for publishing
if: inputs.publish_pypi || inputs.publish_release
env:
SELECTED_REF: ${{ github.ref }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: test "$SELECTED_REF" = "refs/heads/$DEFAULT_BRANCH"

- name: "Download binaries from ${{ github.event.inputs.tag }}"
uses: robinraju/release-downloader@v1.3
with:
repository: ${{ github.repository }}
tag: ${{ github.event.inputs.tag }}
fileName: "*"
out-file-path: "dist"
token: ${{ github.token }}
validate:
needs: guard
uses: ./.github/workflows/build.yml

- name: Test
run: |
ls dist
pypi:
if: inputs.publish_pypi
needs: validate
runs-on: ubuntu-latest
timeout-minutes: 10
environment:
name: pypi
url: https://pypi.org/project/syphon-python/
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: python-dist
path: dist
- name: Publish tested distributions using OIDC
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2

- name: Publish package
# if: ${{ false }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
release:
if: inputs.publish_release
needs: validate
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: python-dist
path: dist
- name: Create versioned release with tested distributions
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_VERSION: ${{ needs.validate.outputs.version }}
RELEASE_COMMIT: ${{ github.sha }}
run: |
existing_tag=$(gh api "repos/$GH_REPO/git/matching-refs/tags/v$RELEASE_VERSION" \
--jq ".[] | select(.ref == \"refs/tags/v$RELEASE_VERSION\") | .ref")
test -z "$existing_tag" || { echo "Release tag already exists: $existing_tag"; exit 1; }
gh release create "v$RELEASE_VERSION" dist/*.whl dist/*.tar.gz \
--target "$RELEASE_COMMIT" --title "Version $RELEASE_VERSION" --generate-notes
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,5 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
.DS_Store
docs/**/*
.ruff_cache/
docs/**/*
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.14
Loading
Loading