| 1 |
name: PyPI 📦 Distribution |
| 2 |
|
| 3 |
on: [push] |
| 4 |
|
| 5 |
jobs: |
| 6 |
build: |
| 7 |
runs-on: ${{ matrix.os }} |
| 8 |
strategy: |
| 9 |
fail-fast: false |
| 10 |
matrix: |
| 11 |
os: [macos-latest, ubuntu-latest, windows-latest] |
| 12 |
platform: [x32, x64] |
| 13 |
steps: |
| 14 |
- uses: actions/checkout@v2 |
| 15 |
|
| 16 |
- name: Set up Python |
| 17 |
uses: actions/setup-python@v2 |
| 18 |
with: |
| 19 |
python-version: '3.x' |
| 20 |
|
| 21 |
- name: Set up MSVC x86 |
| 22 |
if: matrix.os == 'windows-latest' && matrix.platform == 'x32' |
| 23 |
uses: ilammy/msvc-dev-cmd@v1 |
| 24 |
with: |
| 25 |
arch: x86 |
| 26 |
|
| 27 |
- name: Set up MSVC x64 |
| 28 |
if: matrix.os == 'windows-latest' && matrix.platform == 'x64' |
| 29 |
uses: ilammy/msvc-dev-cmd@v1 |
| 30 |
|
| 31 |
- name: Install dependencies |
| 32 |
run: | |
| 33 |
pip install setuptools wheel |
| 34 |
- name: Build distribution 📦 |
| 35 |
shell: bash |
| 36 |
run: | |
| 37 |
if [ ${{ matrix.platform }} == 'x32' ] && [ ${{ matrix.os }} == 'windows-latest' ]; then |
| 38 |
cd bindings/python && python setup.py build -p win32 bdist_wheel -p win32 |
| 39 |
elif [ ${{ matrix.platform }} == 'x32' ] && [ ${{ matrix.os }} == 'ubuntu-latest' ]; then |
| 40 |
docker run --rm -v `pwd`/:/work dockcross/manylinux1-x86 > ./dockcross |
| 41 |
chmod +x ./dockcross |
| 42 |
chmod +x bindings/python/build_wheel.sh |
| 43 |
./dockcross bindings/python/build_wheel.sh |
| 44 |
elif [ ${{ matrix.platform }} == 'x64' ] && [ ${{ matrix.os }} == 'ubuntu-latest' ]; then |
| 45 |
docker run --rm -v `pwd`/:/work dockcross/manylinux1-x64 > ./dockcross |
| 46 |
chmod +x ./dockcross |
| 47 |
chmod +x bindings/python/build_wheel.sh |
| 48 |
./dockcross bindings/python/build_wheel.sh |
| 49 |
elif [ ${{ matrix.platform }} == 'x32' ] && [ ${{ matrix.os }} == 'macos-latest' ]; then |
| 50 |
cd bindings/python && python setup.py sdist |
| 51 |
else |
| 52 |
cd bindings/python && python setup.py bdist_wheel |
| 53 |
fi |
| 54 |
- uses: actions/upload-artifact@v2 |
| 55 |
with: |
| 56 |
path: ${{ github.workspace }}/bindings/python/dist/* |
| 57 |
|
| 58 |
publish: |
| 59 |
needs: [build] |
| 60 |
runs-on: ubuntu-latest |
| 61 |
if: startsWith(github.ref, 'refs/tags') |
| 62 |
steps: |
| 63 |
- uses: actions/download-artifact@v2 |
| 64 |
with: |
| 65 |
name: artifact |
| 66 |
path: dist |
| 67 |
|
| 68 |
# - name: Publish distribution 📦 to test PyPI |
| 69 |
# uses: pypa/gh-action-pypi-publish@master |
| 70 |
# with: |
| 71 |
# user: __token__ |
| 72 |
# password: ${{ secrets.testpypi_pass }} |
| 73 |
# repository_url: https://test.pypi.org/legacy/ |
| 74 |
|
| 75 |
- name: Publish distribution 📦 to PyPI |
| 76 |
if: ${{ success() }} |
| 77 |
uses: pypa/gh-action-pypi-publish@master |
| 78 |
with: |
| 79 |
user: __token__ |
| 80 |
password: ${{ secrets.pypi_pass }} |