name: Build + Deploy on: push: branches: [main] tags: ["*.*.*"] pull_request: branches: [main] env: CIBW_TEST_REQUIRES: "pytest -rrequirements.txt" CIBW_TEST_COMMAND: "pytest --pyargs compreffor" CIBW_ENABLE: "pypy" jobs: build_sdist: name: Build Source Distribution runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 with: submodules: recursive # setuptools_scm won't work with shallow clone; fetch all history fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v6 with: python-version: "3.x" - name: Build sdist run: pipx run build --sdist - name: Check metadata run: pipx run twine check dist/*.tar.gz - uses: actions/upload-artifact@v5 with: path: dist/*.tar.gz name: sdist build_wheels: name: ${{ matrix.type }} ${{ matrix.arch }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} defaults: run: shell: bash strategy: fail-fast: false matrix: # macos-15-intel for x86_64 wheels, macos-latest (arm64) handled in include os: [macos-15-intel, windows-latest] arch: [auto64] build: ["*"] skip: ["cp38-* cp39-* cp314t-* pp*"] include: # manylinux2014 for x86_64 - os: ubuntu-latest arch: auto64 type: manylinux2014 build: "cp310-manylinux* cp311-manylinux* cp312-manylinux* cp313-manylinux* cp314-manylinux* pp311-manylinux*" CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_MANYLINUX_I686_IMAGE: manylinux2014 # native arm64 Linux runner - os: ubuntu-24.04-arm arch: aarch64 type: manylinux2014 build: "cp310-manylinux* cp311-manylinux* cp312-manylinux* cp313-manylinux* cp314-manylinux* pp311-manylinux*" - os: macos-latest arch: universal2 build: "*" skip: "cp38-* cp39-* cp314t-* pp*" - os: windows-latest arch: auto32 build: "*" skip: "cp38-* cp39-* cp314t-* pp*" steps: - uses: actions/checkout@v6 with: submodules: recursive fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v6 with: python-version: "3.x" - name: Install dependencies run: pip install cibuildwheel - name: Build Wheels run: python -m cibuildwheel --output-dir wheelhouse . env: CIBW_BUILD: ${{ matrix.build }} CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.CIBW_MANYLINUX_I686_IMAGE }} CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.CIBW_MANYLINUX_X86_64_IMAGE }} CIBW_ARCHS: ${{ matrix.arch }} CIBW_SKIP: ${{ matrix.skip }} - uses: actions/upload-artifact@v5 with: path: wheelhouse/*.whl name: wheels-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.type }} deploy: name: Upload if tagged commit if: startsWith(github.ref, 'refs/tags/') # but only if all build jobs completed successfully needs: [build_wheels, build_sdist] runs-on: ubuntu-latest permissions: contents: write id-token: write steps: - uses: actions/checkout@v6 - uses: actions/download-artifact@v6 with: path: dist merge-multiple: true - name: Extract release notes from annotated tag message id: release_notes env: # e.g. 0.1.0a1, 1.2.0b2 or 2.3.0rc3, but not 1.0.0 PRERELEASE_TAG_PATTERN: "[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+([ab]|rc)[[:digit:]]+" run: | # GH checkout action doesn't preserve tag annotations, we must fetch them # https://github.com/actions/checkout/issues/290 git fetch --tags --force # strip leading 'refs/tags/' to get the tag name TAG_NAME="${GITHUB_REF##*/}" # Dump tag message to temporary .md file (excluding the PGP signature at the bottom) TAG_MESSAGE=$(git tag -l --format='%(contents)' $TAG_NAME | sed -n '/-----BEGIN PGP SIGNATURE-----/q;p') echo "$TAG_MESSAGE" > "${{ runner.temp }}/release_notes.md" # if the tag has a pre-release suffix mark the Github Release accordingly if egrep -q "$PRERELEASE_TAG_PATTERN" <<< "$TAG_NAME"; then echo "Tag contains a pre-release suffix" echo "IS_PRERELEASE=true" >> "$GITHUB_ENV" else echo "Tag does not contain pre-release suffix" echo "IS_PRERELEASE=false" >> "$GITHUB_ENV" fi - name: Create GitHub release id: create_release uses: softprops/action-gh-release@v2 with: body_path: "${{ runner.temp }}/release_notes.md" draft: false prerelease: ${{ env.IS_PRERELEASE }} - uses: pypa/gh-action-pypi-publish@v1.13.0