summaryrefslogtreecommitdiff
path: root/.github/workflows/build-python-package.yml
blob: 67272d70127bf8cd4a3a60b1869f8c98d3d8ab2c (plain)
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
name: Build & Publish Python Package

on: [push, pull_request]

jobs:
  build_wheels:
    name: Build wheel on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: true
      matrix:
        os: [ubuntu-18.04, macos-latest]

    steps:
    - uses: actions/checkout@v1

    - uses: actions/setup-python@v1
      name: Install Python
      with:
        python-version: '3.7'

    - name: Install cibuildwheel
      run: |
        python -m pip install cibuildwheel==1.4.2  

    - name: Install build tools for OSX
      if: startsWith(matrix.os, 'macos')
      run: |
        brew install automake

    - name: Build wheels on Linux
      if: startsWith(matrix.os, 'macos') != true
      env:
        CIBW_BEFORE_BUILD: cd src/runtime/c && autoreconf -i && ./configure && make && make install
      run: |
        python -m cibuildwheel src/runtime/python --output-dir wheelhouse

    - name: Build wheels on OSX
      if: startsWith(matrix.os, 'macos')
      env:
        CIBW_BEFORE_BUILD: cd src/runtime/c && glibtoolize && autoreconf -i && ./configure && make && make install
      run: |
        python -m cibuildwheel src/runtime/python --output-dir wheelhouse

    - uses: actions/upload-artifact@v2
      with:
        path: ./wheelhouse

  build_sdist:
    name: Build source distribution
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions/setup-python@v2
        name: Install Python
        with:
          python-version: '3.7'

      - name: Build sdist
        run: cd src/runtime/python && python setup.py sdist

      - uses: actions/upload-artifact@v2
        with:
          path: ./src/runtime/python/dist/*.tar.gz

  upload_pypi:
    needs: [build_wheels, build_sdist]
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.x'

      - name: Install twine
        run: pip install twine

      - uses: actions/download-artifact@v2
        with:
          name: artifact
          path: ./src/runtime/python/dist

      - name: Publish
        env:
          TWINE_USERNAME: __token__
          TWINE_PASSWORD: ${{ secrets.pypi_password }}
        run: |
          (cd ./src/runtime/python && curl -I --fail https://test.pypi.org/project/$(python setup.py --name)/$(python setup.py --version)/) || twine upload --repository testpypi dist/*