release-python.yml 4.3 KB
Newer Older
1
name: release-python
N
nihui 已提交
2
# on: [push, pull_request]
3 4
on:
  push:
N
nihuini 已提交
5 6
    tags:
      - '*'
7 8 9 10 11 12

jobs:
  build_sdist:
    name: Build SDist
    runs-on: ubuntu-latest
    steps:
13
    - uses: actions/checkout@v3
14 15 16
      with:
        submodules: true

17
    - uses: actions/setup-python@v4
N
nihui 已提交
18 19
      with:
        python-version: '3.x'
20 21 22 23 24 25 26 27 28 29

    - name: Install deps
      run: python -m pip install twine build

    - name: Build SDist
      run: python -m build -s

    - name: Check metadata
      run: twine check dist/*

30
    - uses: actions/upload-artifact@v3
31 32 33 34
      with:
        path: dist/*.tar.gz

  build_wheels:
N
nihui 已提交
35
    name: ${{ matrix.arch }} ${{ matrix.build }} on ${{ matrix.os }}
36 37 38 39
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
N
nihui 已提交
40 41 42 43 44 45 46 47 48 49 50
        include:
          - { os: ubuntu-20.04, arch: x86_64,     build: 'cp*-manylinux*' }
          - { os: ubuntu-20.04, arch: x86_64,     build: 'cp*-musllinux*' }
          - { os: ubuntu-20.04, arch: x86_64,     build: 'pp*'            }
          - { os: ubuntu-20.04, arch: i686,       build: 'cp*-manylinux*' }
          - { os: ubuntu-20.04, arch: i686,       build: 'cp*-musllinux*' }
          - { os: ubuntu-20.04, arch: i686,       build: 'pp*'            }
          - { os: windows-2019, arch: x86,        build: 'cp*'            }
          - { os: windows-2019, arch: AMD64,      build: 'cp*'            }
          - { os: windows-2019, arch: AMD64,      build: 'pp*'            }
          - { os: windows-2019, arch: ARM64,      build: 'cp*'            }
N
nihui 已提交
51 52 53 54
          - { os: macos-latest, arch: x86_64,     build: 'cp*'            }
          - { os: macos-latest, arch: x86_64,     build: 'pp*'            }
          - { os: macos-latest, arch: arm64,      build: 'cp*'            }
          - { os: macos-latest, arch: universal2, build: 'cp*'            }
55 56

    steps:
57
    - uses: actions/checkout@v3
58 59 60
      with:
        submodules: true

61
    - uses: actions/setup-python@v4
N
nihui 已提交
62 63
      with:
        python-version: '3.x'
64

65
    - name: brew uninstall libomp
N
nihui 已提交
66
      if: matrix.os == 'macos-latest'
67 68 69
      run: |
        brew uninstall --ignore-dependencies libomp

70
    - name: Build wheels
71
      uses: pypa/cibuildwheel@v2.12.3
72
      env:
N
nihui 已提交
73 74 75 76 77 78
        CIBW_ARCHS_MACOS: ${{ matrix.arch }}
        CIBW_ARCHS_LINUX: ${{ matrix.arch }}
        CIBW_ARCHS_WINDOWS: ${{ matrix.arch }}
        CIBW_BUILD: ${{ matrix.build }}
        CIBW_BUILD_VERBOSITY: 1
        CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=2
79 80 81 82 83 84 85 86 87 88

    - name: Show files
      run: ls -lh wheelhouse
      shell: bash

    - name: Verify clean directory
      run: git diff --exit-code
      shell: bash

    - name: Upload wheels
89
      uses: actions/upload-artifact@v3
90 91 92 93
      with:
        path: wheelhouse/*.whl

  build_wheels_qemu:
N
nihui 已提交
94
    name: ${{ matrix.arch }} ${{ matrix.build }}
95 96 97 98 99 100
    runs-on: ubuntu-20.04

    strategy:
      fail-fast: false
      matrix:
        arch: [aarch64, ppc64le, s390x]
N
nihui 已提交
101
        build: ['cp36-*', 'cp37-*', 'cp38-*', 'cp39-*', 'cp310-*', 'cp311-*']
102 103
        include:
          - arch: aarch64
N
nihui 已提交
104
            build: 'pp37-*'
105
          - arch: aarch64
N
nihui 已提交
106
            build: 'pp38-*'
N
nihui 已提交
107
          - arch: aarch64
N
nihui 已提交
108
            build: 'pp39-*'
109 110

    steps:
111
    - uses: actions/checkout@v3
112 113 114
      with:
        submodules: true

115
    - uses: actions/setup-python@v4
N
nihui 已提交
116 117
      with:
        python-version: '3.x'
118

C
Cai Shanli 已提交
119
    - name: Set up QEMU
120
      uses: docker/setup-qemu-action@v2
C
Cai Shanli 已提交
121 122 123
      with:
        platforms: all

124
    - name: Build wheels
125
      uses: pypa/cibuildwheel@v2.12.3
126
      env:
127 128
        CIBW_ARCHS_LINUX: ${{ matrix.arch }}
        CIBW_BUILD: ${{ matrix.build }}
N
nihui 已提交
129 130
        CIBW_BUILD_VERBOSITY: 1
        CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=2
131 132 133 134 135 136 137 138 139 140

    - name: Show files
      run: ls -lh wheelhouse
      shell: bash

    - name: Verify clean directory
      run: git diff --exit-code
      shell: bash

    - name: Upload wheels
141
      uses: actions/upload-artifact@v3
142 143 144 145
      with:
        path: wheelhouse/*.whl

  upload_all:
146 147
    permissions:
      contents: none
N
nihui 已提交
148
    name: Upload
149
    needs: [build_wheels, build_wheels_qemu, build_sdist]
150 151 152
    runs-on: ubuntu-latest

    steps:
153
    - uses: actions/setup-python@v4
N
nihui 已提交
154 155
      with:
        python-version: '3.x'
156

157
    - uses: actions/download-artifact@v3
158 159 160 161
      with:
        name: artifact
        path: dist

N
nihui 已提交
162
    - uses: pypa/gh-action-pypi-publish@release/v1
163 164 165
      with:
        user: __token__
        password: ${{ secrets.PYPI_API_TOKEN }}