|
| 1 | +# Build on every branch push, tag push, and pull request change: |
| 2 | +# Sources: |
| 3 | +# https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml |
| 4 | +# https://github.com/airspeed-velocity/asv/blob/main/.github/workflows/build_wheels.yml |
| 5 | +# include [wheel build] in the commit to trigger wheel builds |
| 6 | +name: Build wheels |
| 7 | +on: [push, pull_request, workflow_dispatch] |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read # to fetch code (actions/checkout) |
| 15 | + |
| 16 | +jobs: |
| 17 | + get_commit_message: |
| 18 | + name: Get commit message |
| 19 | + runs-on: ubuntu-latest |
| 20 | + if: "github.repository == 'flowy-code/pyflowy'" |
| 21 | + outputs: |
| 22 | + message: ${{ steps.commit_message.outputs.message }} |
| 23 | + steps: |
| 24 | + - name: Checkout project |
| 25 | + uses: actions/checkout@v4 |
| 26 | + # Gets the correct commit message for pull request |
| 27 | + with: |
| 28 | + ref: ${{ github.event.pull_request.head.sha }} |
| 29 | + - name: Get commit message |
| 30 | + id: commit_message |
| 31 | + run: | |
| 32 | + set -xe |
| 33 | + COMMIT_MSG=$(git log --no-merges -1 --oneline) |
| 34 | + echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT |
| 35 | + echo github.ref ${{ github.ref }} |
| 36 | + build_wheels: |
| 37 | + name: Build wheels |
| 38 | + needs: get_commit_message |
| 39 | + if: >- |
| 40 | + contains(needs.get_commit_message.outputs.message, '[wheel build]') || |
| 41 | + github.event_name == 'schedule' || |
| 42 | + github.event_name == 'workflow_dispatch' || |
| 43 | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && ( ! endsWith(github.ref, 'dev0'))) |
| 44 | + runs-on: ${{ matrix.buildplat[0] }} |
| 45 | + strategy: |
| 46 | + # Ensure that a wheel builder finishes even if another fails |
| 47 | + fail-fast: false |
| 48 | + matrix: |
| 49 | + # From NumPy |
| 50 | + # Github Actions doesn't support pairing matrix values together, let's improvise |
| 51 | + # https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 |
| 52 | + buildplat: |
| 53 | + # TODO(rg): This needs to be pruned |
| 54 | + # This will build all 21 (many,musl)linux related wheels (64, 32), for supported pythons 3.9, 3.10, 3.11, 3.12, pypy 3.9, pypy 3.10 |
| 55 | + - [ubuntu-20.04, manylinux_x86_64] |
| 56 | + # - [ubuntu-20.04, musllinux_x86_64] |
| 57 | + # TODO(rg): Handle these later via indirection |
| 58 | + # - [macos-12, macosx_x86_64] |
| 59 | + # - [macos-12, macosx_arm64] |
| 60 | + # - [windows-2019, win_amd64] |
| 61 | + python-version: ['3.11'] # This is the python version of the CI, not related to the ones built by cibuildwheel |
| 62 | + |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + - name: Echo Python version and build platform |
| 66 | + run: echo Building wheel for ${{ matrix.python-version }}-${{ matrix.buildplat[1] }} |
| 67 | + - uses: actions/setup-python@v5 |
| 68 | + with: |
| 69 | + python-version: ${{ matrix.python-version }} |
| 70 | + - name: Build wheels |
| 71 | + uses: pypa/cibuildwheel@v2.16.5 |
| 72 | + - uses: actions/upload-artifact@v3 |
| 73 | + with: |
| 74 | + path: ./wheelhouse/*.whl |
| 75 | + |
| 76 | + build_sdist: |
| 77 | + name: Build source distribution |
| 78 | + needs: get_commit_message |
| 79 | + if: >- |
| 80 | + contains(needs.get_commit_message.outputs.message, '[wheel build]') || |
| 81 | + github.event_name == 'schedule' || |
| 82 | + github.event_name == 'workflow_dispatch' || |
| 83 | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && ( ! endsWith(github.ref, 'dev0'))) |
| 84 | + runs-on: ubuntu-latest |
| 85 | + steps: |
| 86 | + - uses: actions/checkout@v4 |
| 87 | + |
| 88 | + - name: Install dependencies |
| 89 | + run: sudo apt-get install libnetcdf-dev libfmt-dev libxtensor-dev libxtensor-blas-dev |
| 90 | + |
| 91 | + - name: Build sdist |
| 92 | + shell: bash -l {0} |
| 93 | + run: pipx run build --sdist |
| 94 | + |
| 95 | + - uses: actions/upload-artifact@v3 |
| 96 | + with: |
| 97 | + path: dist/*.tar.gz |
0 commit comments