publish #35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: publish | |
on: | |
workflow_dispatch: | |
inputs: | |
repository: | |
description: 'The repository to upload the package to' | |
required: true | |
default: 'testpypi' | |
jobs: | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, windows-2019, macOS-11] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Set up QEMU | |
if: runner.os == 'Linux' | |
# uses: docker/setup-qemu-action@v1.0.1 | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
- name: Build wheels | |
# uses: joerick/cibuildwheel@v1.9.0 | |
uses: pypa/cibuildwheel@v2.23.0 | |
with: | |
output-dir: wheelhouse | |
env: | |
CIBW_BUILD: '{cp36,cp37,cp38,cp39,cp310,cp311,cp312,cp313}-{manylinux_x86_64,manylinux_aarch64,win32,win_amd64,macosx_x86_64} {cp39,cp310,cp311,cp312,cp313}-macosx_arm64' | |
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 | |
CIBW_ARCHS_LINUX: 'auto aarch64' | |
CIBW_ARCHS_MACOS: 'auto arm64' | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND: 'pytest -s {project}/tests' | |
CIBW_TEST_SKIP: '*-macosx_arm64' # Until the day Apple silicon instances are available on GitHub Actions | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./wheelhouse/*.whl | |
build_sdist: | |
name: Build a source distribution | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Build sdist | |
run: | | |
pip install py-cpuinfo | |
python setup.py build sdist | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dist/*.tar.gz | |
publish: | |
name: 'Upload to PyPI/TestPyPI' | |
runs-on: ubuntu-20.04 | |
needs: [build_wheels, build_sdist] | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Set up built items | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifact | |
path: dist | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine | |
- name: Publish | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
twine upload --verbose --repository ${{ github.event.inputs.repository }} dist/* |