Skip to content

Use gh-action-pypi-publish #122

Use gh-action-pypi-publish

Use gh-action-pypi-publish #122

Workflow file for this run

---

Check failure on line 1 in .github/workflows/wheels.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/wheels.yml

Invalid workflow file

(Line: 131, Col: 7): Unexpected value 'url:'
name: Wheel-Builder
on:
workflow_call:
inputs:
pypi-repository:
required: false
type: string
secrets:
pypi-username:
required: false
pypi-password:
required: false
permissions: {}
jobs:
build_wheels:
name: Build wheel for ${{ matrix.platform }} ${{ matrix.archs }} ${{ matrix.build }} (runs on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04]
archs: [x86_64, i686, aarch64, ppc64le, s390x]
build: [manylinux, musllinux]
include:
- os: windows-2022
archs: AMD64
- os: windows-2022
archs: x86
- os: windows-2022
archs: ARM64
- os: macos-13
archs: x86_64
- os: macos-14
archs: arm64
- os: macos-14
archs: universal2
- os: ubuntu-24.04
platform: android
archs: x86_64
build: android
- os: macos-14
platform: android
archs: arm64_v8a
build: android
- os: macos-14
platform: ios
archs: arm64_iphoneos
- os: macos-14
platform: ios
archs: arm64_iphonesimulator
- os: macos-13
platform: ios
archs: x86_64_iphonesimulator
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Set up QEMU
if: runner.os == 'Linux' && matrix.platform != 'android'
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
# https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/
- name: Set up KVM for Android emulation
if: runner.os == 'Linux' && matrix.platform == 'android'
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Build wheels
uses: pypa/cibuildwheel@vc923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
with:
output-dir: wheelhouse
env:
CIBW_BUILD: "{cp39,cp310,cp311,cp312,cp313,cp314,cp314t}-${{ matrix.build }}*"
CIBW_PLATFORM: ${{ matrix.platform || 'auto' }}
CIBW_ARCHS: ${{ matrix.archs }}
CIBW_BUILD_FRONTEND: "build"
CIBW_TEST_REQUIRES: "pytest"
CIBW_TEST_SOURCES_ANDROID: "./tests"
CIBW_TEST_SOURCES_IOS: "./tests"
CIBW_TEST_COMMAND: "pytest {project}"
CIBW_TEST_COMMAND_ANDROID: "python -m pytest ./tests"
CIBW_TEST_COMMAND_IOS: "python -m pytest ./tests"
CIBW_TEST_SKIP: "*-win_arm64 *-android_arm64_v8a"
- uses: actions/upload-artifact@v4
with:
name: Wheel-${{ matrix.os }}-${{ matrix.platform }}-${{ matrix.build }}${{ matrix.archs }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build a source distribution
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Build sdist
run: |
python -m pip install --upgrade pip
pip install setuptools build
python -m build --sdist
- name: Test building from the source distribution
shell: bash
run: |
pip install ".[test,type]"
pip uninstall -y mmh3
python -m pip install dist/*.tar.gz
python -m pytest
mypy --strict tests
- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz
publish:
if: ${{ inputs.pypi-repository == 'pypi' || inputs.pypi-repository == 'testpypi'}}
name: "Upload to PyPI/Test PyPI"
runs-on: ubuntu-24.04
needs: [build_wheels, build_sdist]
environment:
name: ${{ inputs.pypi-repository }}
url:: ${{ inputs.pypi-url }}
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Set up built items
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
repository-url: ${{ inputs.pypi-endpoint }}