|
| 1 | +name: release |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: [published] |
| 5 | + tags: |
| 6 | + - v* |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - master |
| 13 | + |
| 14 | +env: |
| 15 | + LIBZIM_RELEASE: libzim_linux-x86_64-6.1.1 |
| 16 | + LIBZIM_LIBRARY_PATH: lib/x86_64-linux-gnu/libzim.so.6.1.1 |
| 17 | + LIBZIM_INCLUDE_PATH: include/zim |
| 18 | + CYTHON_VERSION: 0.29.6 |
| 19 | + |
| 20 | +jobs: |
| 21 | + release: |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + os: [ubuntu-latest] |
| 26 | + # TODO: expand this to cross-platform builds (see V2 approach below) |
| 27 | + # os: [ubuntu-latest, windows-latest, macos-latest] |
| 28 | + python-version: [3.6, 3.7, 3.8] |
| 29 | + |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v2 |
| 32 | + |
| 33 | + - name: Set up Python ${{ matrix.python-version }} |
| 34 | + uses: actions/setup-python@v1 |
| 35 | + with: |
| 36 | + python-version: ${{ matrix.python-version }} |
| 37 | + architecture: x64 |
| 38 | + |
| 39 | + - name: Cache libzim dylib |
| 40 | + uses: actions/cache@master |
| 41 | + id: cache-libzim |
| 42 | + with: |
| 43 | + path: libzim_linux |
| 44 | + key: $LIBZIM_RELEASE-libzim-cache |
| 45 | + |
| 46 | + - name: Install libzim dylib & headers in system |
| 47 | + if: steps.cache-libzim.outputs.cache-hit != 'true' |
| 48 | + run: | |
| 49 | + wget -q https://download.openzim.org/release/libzim/$LIBZIM_RELEASE.tar.gz |
| 50 | + tar --gunzip --extract --file=$LIBZIM_RELEASE.tar.gz |
| 51 | + mv $LIBZIM_RELEASE libzim_linux |
| 52 | +
|
| 53 | + - name: Sync libzim dylib & headers in system |
| 54 | + run: | |
| 55 | + sudo rsync -a $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_LIBRARY_PATH /usr/lib/libzim.so |
| 56 | + sudo rsync -a $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_INCLUDE_PATH/ /usr/include/zim/ |
| 57 | +
|
| 58 | + - name: Copy libzim release for building |
| 59 | + run: | |
| 60 | + rsync -a $GITHUB_WORKSPACE/libzim_linux/ $GITHUB_WORKSPACE/$LIBZIM_RELEASE/ |
| 61 | +
|
| 62 | + - name: Build cython, sdist, and bdist_wheels |
| 63 | + run: | |
| 64 | + pip install --upgrade cython==$CYTHON_VERSION setuptools pip cibuildwheel |
| 65 | + python3 setup.py build_ext --inplace |
| 66 | + python3 setup.py sdist bdist_wheel |
| 67 | + python -m cibuildwheel --output-dir wheelhouse |
| 68 | +
|
| 69 | + - uses: actions/upload-artifact@v1 |
| 70 | + with: |
| 71 | + name: wheels |
| 72 | + path: ./wheelhouse |
| 73 | + |
| 74 | + - name: Push release to PyPI |
| 75 | + if: github.event_name == 'push' && github.ref == 'refs/heads/master' |
| 76 | + uses: pypa/gh-action-pypi-publish@master |
| 77 | + with: |
| 78 | + user: __token__ |
| 79 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 80 | + repository_url: https://test.pypi.org/legacy/ |
| 81 | + |
| 82 | +### TODO V2: The more modern wheel-based cross-platform binary distribution approach |
| 83 | + |
| 84 | + # manylinux-release-wheel: |
| 85 | + # name: Build release wheels for manylinux2010 |
| 86 | + # runs-on: ubuntu-18.04 |
| 87 | + # steps: |
| 88 | + # - uses: actions/checkout@v2 |
| 89 | + # - uses: actions/setup-python@v1 |
| 90 | + # with: |
| 91 | + # python-version: 3.6 |
| 92 | + # - name: Build manylinux2010 wheels |
| 93 | + # run: | |
| 94 | + # docker run -e manylinux2010 tools/ci_build/builds/release_linux.sh |
| 95 | + # python3 -m pip install -U auditwheel |
| 96 | + # for f in artifacts/*.whl; do |
| 97 | + # auditwheel repair --plat manylinux2010_x86_64 $f |
| 98 | + # done |
| 99 | + # ls -al wheelhouse/ |
| 100 | + |
| 101 | + # - uses: actions/upload-artifact@v1 |
| 102 | + # with: |
| 103 | + # name: ${{ runner.os }}-wheels |
| 104 | + # path: wheelhouse |
| 105 | + |
| 106 | + # macos-release-wheel: |
| 107 | + # name: Build release wheels for macOS |
| 108 | + # runs-on: macos-latest |
| 109 | + # strategy: |
| 110 | + # matrix: |
| 111 | + # python-version: ['3.6', '3.7', '3.8'] |
| 112 | + # steps: |
| 113 | + # - uses: actions/checkout@v2 |
| 114 | + # - uses: actions/setup-python@v1 |
| 115 | + # with: |
| 116 | + # python-version: ${{ matrix.python-version }} |
| 117 | + # - name: Build macOS wheels |
| 118 | + # if: github.event_name == 'release' |
| 119 | + # run: | |
| 120 | + # python3 --version |
| 121 | + # python3 -m pip install cython wheel setuptools |
| 122 | + # bazel build \ |
| 123 | + # -c opt \ |
| 124 | + # --copt -mmacosx-version-min=10.13 \ |
| 125 | + # --linkopt -mmacosx-version-min=10.13 \ |
| 126 | + # --noshow_progress \ |
| 127 | + # --noshow_loading_progress \ |
| 128 | + # --verbose_failures \ |
| 129 | + # --test_output=errors \ |
| 130 | + # build_pip_pkg |
| 131 | + # bazel-bin/build_pip_pkg artifacts |
| 132 | + # for f in artifacts/*.whl; do |
| 133 | + # delocate-wheel -w wheelhouse $f |
| 134 | + # done |
| 135 | + # - uses: actions/upload-artifact@v1 |
| 136 | + # with: |
| 137 | + # name: ${{ runner.os }}-wheels |
| 138 | + # path: wheelhouse |
| 139 | + |
| 140 | + # windows-release-wheel: |
| 141 | + # name: Build release wheels for Windows |
| 142 | + # runs-on: windows-latest |
| 143 | + # strategy: |
| 144 | + # matrix: |
| 145 | + # python-version: ['3.6', '3.7', '3.8'] |
| 146 | + # steps: |
| 147 | + # - uses: actions/checkout@v2 |
| 148 | + # - uses: actions/setup-python@v1 |
| 149 | + # with: |
| 150 | + # python-version: ${{ matrix.python-version }} |
| 151 | + # - name: Build Windows wheels |
| 152 | + # shell: bash |
| 153 | + # if: github.event_name == 'release' |
| 154 | + # run: | |
| 155 | + # python -m pip install cython wheel setuptools |
| 156 | + # # TODO build here |
| 157 | + # - uses: actions/upload-artifact@v1 |
| 158 | + # with: |
| 159 | + # name: ${{ runner.os }}-wheels |
| 160 | + # path: artifacts |
| 161 | + |
| 162 | + # upload-wheels: |
| 163 | + # name: Publish wheels to PyPi |
| 164 | + # needs: [manylinux-release-wheel, macos-release-wheel, windows-release-wheel] |
| 165 | + # runs-on: ubuntu-18.04 |
| 166 | + # steps: |
| 167 | + # - uses: actions/download-artifact@v1 |
| 168 | + # with: |
| 169 | + # name: Linux-wheels |
| 170 | + # path: Linux-wheels |
| 171 | + # - uses: actions/download-artifact@v1 |
| 172 | + # with: |
| 173 | + # name: macOS-wheels |
| 174 | + # path: macOS-wheels |
| 175 | + # - uses: actions/download-artifact@v1 |
| 176 | + # with: |
| 177 | + # name: Windows-wheels |
| 178 | + # path: Windows-wheels |
| 179 | + # - run: | |
| 180 | + # set -e -x |
| 181 | + # mkdir -p dist |
| 182 | + # cp Linux-wheels/*.whl dist/ |
| 183 | + # cp macOS-wheels/*.whl dist/ |
| 184 | + # cp Windows-wheels/*.whl dist/ |
| 185 | + # ls -la dist/ |
| 186 | + # sha256sum dist/*.whl |
| 187 | + |
| 188 | + # - uses: pypa/gh-action-pypi-publish@master |
| 189 | + # if: github.event_name == 'release' |
| 190 | + # with: |
| 191 | + # user: __token__ |
| 192 | + # password: ${{ secrets.pypi_token }} |
0 commit comments