tidy py workflow

This commit is contained in:
Kenneth Bingham 2025-03-04 20:54:30 -05:00
parent 8247c0edda
commit 7e2e1144f3
No known key found for this signature in database
GPG Key ID: 31709281860130B6
3 changed files with 32 additions and 49 deletions

View File

@ -1,4 +1,4 @@
name: build wheels name: Publish Python Distributions
on: on:
release: release:
@ -23,35 +23,24 @@ jobs:
exit 1 exit 1
fi fi
build_wheels: build_distributions:
needs: enforce_stable_semver needs: enforce_stable_semver
defaults: defaults:
run: run:
working-directory: sdk/python/src working-directory: sdk/python/src
strategy: runs-on: ubuntu-24.04
fail-fast: false name: Building Python Distributions
matrix:
spec:
- { name: 'linux x86_64', runner: ubuntu-24.04, platform: linux, target: manylinux_2_27_x86_64 }
- { name: 'macOS x86_64', runner: macos-13, platform: macos, target: macosx_10_14_x86_64 }
- { name: 'Windows x86_64', runner: windows-2019, platform: windows, target: win_amd64 }
name: building ${{ matrix.spec.name }}
runs-on: ${{ matrix.spec.runner }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.13' python-version: '3.13'
cache: 'pip'
- name: Install Python Tools - name: Build Python distributions
run: python -m pip install -U pip setuptools
- name: Build distro
env: env:
ZROK_VERSION: ${{ github.event.release.tag_name }} ZROK_VERSION: ${{ github.event.release.tag_name }}
ZROK_PY_NAME: ${{ vars.ZROK_PY_NAME || null }} ZROK_PY_NAME: ${{ vars.ZROK_PY_NAME || null }}
@ -61,46 +50,35 @@ jobs:
set -o pipefail set -o pipefail
set -o xtrace set -o xtrace
# Install build requirements
pip install --upgrade pip pip install --upgrade pip
pip install -r build-requirements.txt
if [ "${{ matrix.spec.platform }}" == "linux" ]; then # Build source distribution and wheel
# Use cibuildwheel for Linux builds (proper manylinux containers) python -m build
pip install cibuildwheel
python -m cibuildwheel --output-dir ./dist
# Also build an sdist
pip install build
python -m build --sdist
elif [ "${{ matrix.spec.platform }}" == "windows" ]; then # List built distributions
# For Windows, use regular build with Windows-specific script handling ls -lAR ./dist
pip install build wheel
python -m build
else
# For macOS, use regular build
pip install build wheel
python -m build
fi
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: startsWith(matrix.spec.name, 'linux')
with: with:
name: zrok_sdk_${{ matrix.spec.target }} name: zrok_sdk_distributions
path: sdk/python/src/dist/* path: sdk/python/src/dist/*
publish-testpypi: publish_testpypi:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
needs: [ build_wheels ] needs: [ build_distributions ]
permissions: permissions:
id-token: write id-token: write
steps: steps:
- name: Download artifacts - name: Download artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
path: ./dist path: sdk/python/src/dist
merge-multiple: true merge-multiple: true
pattern: zrok_sdk_* pattern: zrok_sdk_distributions
- name: Publish wheels (TestPYPI) - name: Publish Distributions to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1 uses: pypa/gh-action-pypi-publish@release/v1
with: with:
repository-url: https://test.pypi.org/legacy/ repository-url: https://test.pypi.org/legacy/
@ -108,20 +86,20 @@ jobs:
skip-existing: true skip-existing: true
verbose: true verbose: true
publish-pypi: publish_pypi:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
needs: [ publish-testpypi ] needs: [ publish_testpypi ]
permissions: permissions:
id-token: write id-token: write
steps: steps:
- name: Download artifacts - name: Download artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
path: sdk/python/src/dist path: sdk/python/src/dist
merge-multiple: true merge-multiple: true
pattern: zrok_sdk_* pattern: zrok_sdk_distributions
- name: Publish wheels (PyPI) - name: Publish Distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1 uses: pypa/gh-action-pypi-publish@release/v1
with: with:
packages-dir: sdk/python/src/dist packages-dir: sdk/python/src/dist

View File

@ -0,0 +1,2 @@
build
wheel

View File

@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"