|
| 1 | +name: Build and deploy |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + release: |
| 6 | + types: |
| 7 | + - published |
| 8 | + |
| 9 | +jobs: |
| 10 | + build_sdist: |
| 11 | + name: Build source distribution |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + - uses: actions/setup-python@v5 |
| 16 | + with: |
| 17 | + python-version: "3.12" |
| 18 | + cache: "pip" |
| 19 | + - name: Install dependencies |
| 20 | + run: | |
| 21 | + python -m pip install --upgrade pip |
| 22 | + pip install build twine |
| 23 | + - name: Build sdist |
| 24 | + run: python -m build --sdist |
| 25 | + - name: Check the package |
| 26 | + run: python -m twine check dist/* |
| 27 | + - uses: actions/upload-artifact@v4 |
| 28 | + with: |
| 29 | + name: cibw-sdist |
| 30 | + path: dist/*.tar.gz |
| 31 | + |
| 32 | + test_sdist: |
| 33 | + needs: [build_sdist] |
| 34 | + name: Test source distribution |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + - uses: actions/setup-python@v5 |
| 39 | + with: |
| 40 | + python-version: "3.12" |
| 41 | + cache: "pip" |
| 42 | + - uses: actions/download-artifact@v4 |
| 43 | + with: |
| 44 | + name: cibw-sdist |
| 45 | + path: dist |
| 46 | + - name: Install from sdist |
| 47 | + run: pip install "$(ls dist/fabio-*.tar.gz)" |
| 48 | + - name: Run tests |
| 49 | + run: python -c "import fabio.test, sys; sys.exit(fabio.test.run_tests())" |
| 50 | + |
| 51 | + build_doc: |
| 52 | + name: Build documentation |
| 53 | + runs-on: ubuntu-latest |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v4 |
| 56 | + - uses: actions/setup-python@v5 |
| 57 | + with: |
| 58 | + python-version: "3.12" |
| 59 | + cache: "pip" |
| 60 | + - name: Install pandoc&graphviz |
| 61 | + run: sudo apt-get install pandoc graphviz |
| 62 | + - name: Install fabio |
| 63 | + run: pip install . |
| 64 | + - name: Install documentation dependencies |
| 65 | + run: pip install -r requirements.txt |
| 66 | + - name: Build doc |
| 67 | + env: |
| 68 | + READTHEDOCS: "True" # To skip checking that fabio is installed locally |
| 69 | + run: | |
| 70 | + export FABIO_VERSION="$(python -c 'import fabio; print(fabio.strictversion)')" |
| 71 | + sphinx-build doc/source/ "fabio-${FABIO_VERSION}_documentation/" |
| 72 | + zip -r "fabio-${FABIO_VERSION}_documentation.zip" "fabio-${FABIO_VERSION}_documentation/" |
| 73 | + - uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: documentation |
| 76 | + path: fabio-*_documentation.zip |
| 77 | + |
| 78 | + build_wheels: |
| 79 | + name: Build wheels on ${{ matrix.os }}-${{ matrix.cibw_archs }} |
| 80 | + runs-on: ${{ matrix.os }} |
| 81 | + strategy: |
| 82 | + # Ensure that a wheel builder finishes even if another fails |
| 83 | + fail-fast: false |
| 84 | + matrix: |
| 85 | + include: |
| 86 | + - os: ubuntu-20.04 |
| 87 | + cibw_archs: "auto64" |
| 88 | + - os: ubuntu-20.04 |
| 89 | + cibw_archs: "aarch64" |
| 90 | + - os: ubuntu-20.04 |
| 91 | + cibw_archs: "ppc64le" |
| 92 | + - os: windows-2019 |
| 93 | + cibw_archs: "auto64" |
| 94 | + - os: macos-11 |
| 95 | + cibw_archs: "x86_64" |
| 96 | + macos_target: "10.9" |
| 97 | + - os: macos-14 |
| 98 | + cibw_archs: "arm64" |
| 99 | + macos_target: "11.0" |
| 100 | + |
| 101 | + steps: |
| 102 | + - uses: actions/checkout@v4 |
| 103 | + - uses: docker/setup-qemu-action@v3 |
| 104 | + if: runner.os == 'Linux' |
| 105 | + with: |
| 106 | + platforms: all |
| 107 | + |
| 108 | + env: |
| 109 | + # Use silx wheelhouse: needed for ppc64le |
| 110 | + CIBW_ENVIRONMENT_LINUX: "PIP_FIND_LINKS=https://www.silx.org/pub/wheelhouse/ PIP_TRUSTED_HOST=www.silx.org" |
| 111 | + |
| 112 | + CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* cp311-* cp312-* |
| 113 | + # Do not build for pypy and muslinux |
| 114 | + CIBW_SKIP: pp* *-musllinux_* |
| 115 | + CIBW_ARCHS: ${{ matrix.cibw_archs }} |
| 116 | + |
| 117 | + MACOSX_DEPLOYMENT_TARGET: "${{ matrix.macos_target }}" |
| 118 | + |
| 119 | + # Install test dependencies |
| 120 | + CIBW_TEST_COMMAND: python -c "import fabio.test, sys; sys.exit(fabio.test.run_tests())" |
| 121 | + # Skip tests for emulated architectures |
| 122 | + # and Python3.8 on macos/arm64 (https://github.com/pypa/cibuildwheel/pull/1169) |
| 123 | + CIBW_TEST_SKIP: "*-*linux_{aarch64,ppc64le,s390x} cp38-macosx_arm64" |
| 124 | + |
| 125 | + - uses: actions/upload-artifact@v4 |
| 126 | + with: |
| 127 | + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} |
| 128 | + path: ./wheelhouse/*.whl |
| 129 | + |
| 130 | + pypi-publish: |
| 131 | + needs: [build_doc, build_sdist, build_wheels, test_sdist] |
| 132 | + name: Upload release to PyPI |
| 133 | + runs-on: ubuntu-latest |
| 134 | + environment: |
| 135 | + name: pypi |
| 136 | + permissions: |
| 137 | + id-token: write |
| 138 | + if: github.event_name == 'release' && github.event.action == 'published' |
| 139 | + # or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) |
| 140 | + # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 141 | + steps: |
| 142 | + - uses: actions/download-artifact@v4 |
| 143 | + with: |
| 144 | + pattern: cibw-* |
| 145 | + path: dist |
| 146 | + merge-multiple: true |
| 147 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments