publish-python #4
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 | |
- 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.2 | |
- name: Build wheels | |
run: python3 -m cibuildwheel --output-dir wheelhouse wrappers/python | |
env: | |
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* | |
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: universal2 | |
CIBW_ENVIRONMENT_MACOS: CMAKE_OSX_ARCHITECTURES="arm64;x86_64" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.runs-on }}-wheels | |
path: ./wheelhouse/*.whl | |
build-sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- 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 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: sdist-wheel | |
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: | |
name: artifact | |
path: dist | |
- uses: pypa/gh-action-pypi-publish@release/v1 | |
# with: | |
# repository-url: https://test.pypi.org/legacy/ |