File: publish-python.yml

package info (click to toggle)
zxing-cpp 2.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,832 kB
  • sloc: cpp: 32,803; ansic: 18,360; php: 1,156; python: 215; makefile: 28; sh: 3
file content (113 lines) | stat: -rw-r--r-- 3,386 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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-13, windows-latest] # at least macos-13 is required to enable c++20 support

    steps:
    - uses: actions/checkout@v4
      with:
        submodules: true

    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: '3.12'

    - name: Install cibuildwheel
      run: python3 -m pip install cibuildwheel==2.22.0

    - name: Build wheels
      run: python3 -m cibuildwheel --output-dir wheelhouse wrappers/python
      env:
        # TODO: setup a "BEFORE" cmake build and link the python module to the prebuild libZXing.a
        # see https://github.com/YannickJadoul/Parselmouth/blob/523c117aa780184345121f6ff8315670bc7d4d94/.github/workflows/wheels.yml#L120
        CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-*
        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. it might be required to increase that to support c++20 or later features.
        # MACOSX_DEPLOYMENT_TARGET: "10.15"
        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:
        submodules: true

    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: '3.13'

    - 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/