publish-python #11
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-python | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
publish: | |
description: 'Publish package (y/n)' | |
default: 'n' | |
# push: | |
# branches: [master] | |
# tags: ["v*.*.*"] | |
# pull_request: | |
# branches: [master] | |
jobs: | |
build-wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install cibuildwheel | |
run: python3 -m pip install cibuildwheel==2.16.5 | |
- name: Build wheels | |
run: python3 -m cibuildwheel --output-dir wheelhouse wrappers/python | |
env: | |
# CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* | |
CIBW_BUILD: cp39-* | |
CIBW_SKIP: "*musllinux*" | |
# the default maylinux2014 image does not contain a c++20 compiler, see https://github.com/pypa/manylinux | |
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64 | |
# CIBW_ARCHS_MACOS: "x86_64 arm64" | |
CIBW_ARCHS_MACOS: universal2 | |
CIBW_ENVIRONMENT_MACOS: CMAKE_OSX_ARCHITECTURES="arm64;x86_64" | |
# the default macOS target version is 10.9 which does not support c++20 coroutines | |
MACOSX_DEPLOYMENT_TARGET: "10.13" | |
CMAKE_FIND_FRAMEWORK: "LAST" | |
CIBW_BUILD_VERBOSITY: 1 | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.os }} | |
path: ./wheelhouse/*.whl | |
build-sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
working-directory: wrappers/python | |
run: python -m pip install --upgrade pip setuptools | |
- name: Build sdist | |
working-directory: wrappers/python | |
run: python3 setup.py sdist | |
- name: Upload sdist | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-sdist | |
path: wrappers/python/dist/*.tar.gz | |
upload-pypi: | |
name: Upload to PyPI | |
needs: [build-wheels, build-sdist] | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/zxing-cpp | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
# only run if the commit is tagged... | |
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
if: github.event_name == 'release' || github.event.inputs.publish == 'y' | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- name: List wheels | |
run: ls dist | |
- uses: pypa/gh-action-pypi-publish@release/v1 | |
# with: | |
# repository-url: https://test.pypi.org/legacy/ |