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, macos-15-intel, ubuntu-24.04-arm, windows-11-arm] steps: - uses: actions/checkout@v6 with: submodules: true - name: Set up Python uses: actions/setup-python@v6 with: python-version: '3.12' - name: Install cibuildwheel run: python3 -m pip install cibuildwheel==3.3.0 - name: Build wheels run: python3 -m cibuildwheel --output-dir wheelhouse wrappers/python - name: Upload wheels uses: actions/upload-artifact@v6 with: name: cibw-wheels-${{ matrix.os }} path: ./wheelhouse/*.whl build-sdist: name: Build source distribution runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 with: submodules: true - name: Set up Python uses: actions/setup-python@v6 with: python-version: '3.14' - name: Install dependencies working-directory: wrappers/python run: python -m pip install --upgrade build - name: Build sdist working-directory: wrappers/python run: python3 -m build --sdist - name: Upload sdist uses: actions/upload-artifact@v6 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@v8 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/