• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: Build + Deploy
2
3on:
4  push:
5    tags: ["*.*.*"]
6  # enables workflow to be run manually
7  # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
8  workflow_dispatch:
9
10env:
11  # skip binary wheels for pypy (preferable to use pure-python) and 32-bit Linux
12  CIBW_SKIP: pp* cp*linux_i686
13  CIBW_ENVIRONMENT: FONTTOOLS_WITH_CYTHON=1
14  CIBW_TEST_REQUIRES: tox
15  # only test core fonttools library without extras for now, stuff like lxml or scipy
16  # create too many issues when testing on a large matrix of environments...
17  CIBW_TEST_COMMAND: "tox -c {package}/tox.ini -e py-cy-noextra --installpkg {wheel}"
18
19jobs:
20
21  build_pure:
22    runs-on: ubuntu-latest
23    steps:
24    - uses: actions/checkout@v4
25    - name: Set up Python
26      uses: actions/setup-python@v5
27      with:
28        python-version: '3.x'
29    - name: Install dependencies
30      run: |
31        pip install setuptools wheel twine
32    - name: Build source distribution and pure-python wheel
33      run: |
34        python setup.py sdist bdist_wheel
35    - uses: actions/upload-artifact@v4
36      with:
37        name: pure
38        path: |
39          dist/*.whl
40          dist/*.tar.gz
41
42  build_wheels:
43    name: ${{ matrix.type }} ${{ matrix.arch }} on ${{ matrix.os }}
44    runs-on: ${{ matrix.os }}
45    defaults:
46      run:
47        shell: bash
48    strategy:
49      fail-fast: false
50      matrix:
51        os: [macos-latest, windows-latest, ubuntu-latest]
52        arch: [auto64]
53        include:
54          - os: macos-latest
55            arch: universal2
56          - os: windows-latest
57            arch: auto32
58    steps:
59    - uses: actions/checkout@v4
60      with:
61        submodules: recursive
62    - name: Set up Python
63      uses: actions/setup-python@v5
64      with:
65        python-version: "3.x"
66    - name: Install dependencies
67      run: pip install cibuildwheel
68
69    - name: Build Wheels
70      run: python -m cibuildwheel --output-dir wheelhouse .
71      env:
72        CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
73        CIBW_ARCHS: ${{ matrix.arch }}
74    - uses: actions/upload-artifact@v4
75      with:
76        name: wheels-${{ matrix.os }}-${{ matrix.arch }}
77        path: wheelhouse/*.whl
78
79  build_arch_wheels:
80    name: py${{ matrix.python }} on ${{ matrix.arch }}
81    runs-on: ubuntu-latest
82    strategy:
83      matrix:
84        # aarch64 uses qemu so it's slow, build each py version in parallel jobs
85        python: [38, 39, 310, 311, 312]
86        arch: [aarch64]
87    steps:
88    - uses: actions/checkout@v4
89      with:
90        submodules: true
91    - uses: docker/setup-qemu-action@v3.0.0
92      with:
93        platforms: all
94    - name: Install dependencies
95      run: pip install cibuildwheel
96    - name: Build Wheels
97      run: python -m cibuildwheel --output-dir wheelhouse .
98      env:
99        CIBW_BUILD: cp${{ matrix.python }}-*
100        CIBW_ARCHS: ${{ matrix.arch }}
101    - uses: actions/upload-artifact@v4
102      with:
103        name: wheels-py${{ matrix.python }}-linux-${{ matrix.arch }}
104        path: wheelhouse/*.whl
105
106  deploy:
107    name: Upload to PyPI on tagged commit
108    runs-on: ubuntu-latest
109    needs:
110      - build_pure
111      - build_wheels
112      - build_arch_wheels
113    # only run if the commit is tagged...
114    if: startsWith(github.ref, 'refs/tags/')
115    steps:
116    - uses: actions/download-artifact@v4
117      with:
118        # so that all artifacts are downloaded in the same directory specified by 'path'
119        merge-multiple: true
120        path: dist
121    - uses: pypa/gh-action-pypi-publish@v1.8.11
122      with:
123        user: __token__
124        password: ${{ secrets.PYPI_PASSWORD }}
125