diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index f09cf5e68..e65684473 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -26,14 +26,75 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + CARGO_INCREMENTAL: 0 + CARGO_NET_RETRY: 10 + CARGO_TERM_COLOR: always + RUSTUP_MAX_RETRIES: 10 + jobs: - linux: + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: "Upload sdist" + uses: actions/upload-artifact@v4 + with: + name: wheels-sdist + path: dist + + windows: + runs-on: windows-latest + strategy: + matrix: + platform: + - target: x86_64-pc-windows-msvc + arch: x64 + - target: i686-pc-windows-msvc + arch: x86 + - target: aarch64-pc-windows-msvc + arch: x64 # not relevant here + steps: + - uses: actions/checkout@v4 + - name: "Build wheels" + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + args: --release --locked --out dist --features self-update + sccache: 'true' + - name: "Upload wheels" + uses: actions/upload-artifact@v4 + with: + name: wheels-windows-${{ matrix.platform.target }} + path: dist + - name: "Archive binary" + shell: bash + run: | + ARCHIVE_FILE=prek-${{ matrix.platform.target }}.zip + 7z a $ARCHIVE_FILE ./target/${{ matrix.platform.target }}/release/prek.exe + sha256sum $ARCHIVE_FILE > $ARCHIVE_FILE.sha256 + - name: "Upload binary" + uses: actions/upload-artifact@v4 + with: + name: artifacts-${{ matrix.platform.target }} + path: | + *.zip + *.sha256 + + macos: runs-on: ${{ matrix.platform.runner }} strategy: matrix: platform: - - runner: ubuntu-latest - target: x86_64-unknown-linux-gnu + - runner: macos-15 + target: x86_64-apple-darwin + - runner: macos-15 + target: aarch64-apple-darwin steps: - uses: actions/checkout@v4 - name: "Build wheels" @@ -42,7 +103,123 @@ jobs: target: ${{ matrix.platform.target }} args: --release --locked --out dist --features self-update sccache: 'true' + - name: "Upload wheels" + uses: actions/upload-artifact@v4 + with: + name: wheels-macos-${{ matrix.platform.target }} + path: dist + - name: "Archive binary" + run: | + TARGET=${{ matrix.platform.target }} + ARCHIVE_NAME=prek-$TARGET + ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz + + mkdir -p $ARCHIVE_NAME + cp target/$TARGET/release/prek $ARCHIVE_NAME/prek + tar czvf $ARCHIVE_FILE $ARCHIVE_NAME + shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256 + - name: "Upload binary" + uses: actions/upload-artifact@v4 + with: + name: artifacts-${{ matrix.platform.target }} + path: | + *.tar.gz + *.sha256 + + + linux: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - { target: "i686-unknown-linux-gnu", cc: "gcc -m32" } + - { target: "x86_64-unknown-linux-gnu", cc: "gcc" } + steps: + - uses: actions/checkout@v4 + - name: "Build wheels" + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + # Generally, we try to build in a target docker container. In this case however, a + # 32-bit compiler runs out of memory (4GB memory limit for 32-bit), so we cross compile + # from 64-bit version of the container, breaking the pattern from other builds. + container: quay.io/pypa/manylinux2014 + args: --release --locked --out dist --features self-update + # See: https://github.com/sfackler/rust-openssl/issues/2036#issuecomment-1724324145 + before-script-linux: | + # Install the 32-bit cross target on 64-bit (noop if we're already on 64-bit) + rustup target add ${{ matrix.target }} + # If we're running on rhel centos, install needed packages. + if command -v yum &> /dev/null; then + yum update -y && yum install -y perl-core openssl openssl-devel pkgconfig libatomic + + # If we're running on i686 we need to symlink libatomic + # in order to build openssl with -latomic flag. + if [[ ! -d "/usr/lib64" ]]; then + ln -s /usr/lib/libatomic.so.1 /usr/lib/libatomic.so + else + # Support cross-compiling from 64-bit to 32-bit + yum install -y glibc-devel.i686 libstdc++-devel.i686 + fi + else + # If we're running on debian-based system. + apt update -y && apt-get install -y libssl-dev openssl pkg-config + fi + sccache: 'true' manylinux: auto + env: + CC: ${{ matrix.cc }} + - name: "Upload wheels" + uses: actions/upload-artifact@v4 + with: + name: wheels-linux-${{ matrix.target }} + path: dist + - name: "Archive binary" + shell: bash + run: | + set -euo pipefail + + TARGET=${{ matrix.target }} + ARCHIVE_NAME=prek-$TARGET + ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz + + mkdir -p $ARCHIVE_NAME + cp target/$TARGET/release/prek $ARCHIVE_NAME/prek + tar czvf $ARCHIVE_FILE $ARCHIVE_NAME + shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256 + - name: "Upload binary" + uses: actions/upload-artifact@v4 + with: + name: artifacts-${{ matrix.target }} + path: | + *.tar.gz + *.sha256 + + linux-arm: + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + matrix: + platform: + - target: aarch64-unknown-linux-gnu + arch: aarch64 + # see https://github.com/astral-sh/ruff/issues/3791 + # and https://github.com/gnzlbg/jemallocator/issues/170#issuecomment-1503228963 + maturin_docker_options: -e JEMALLOC_SYS_WITH_LG_PAGE=16 + - target: armv7-unknown-linux-gnueabihf + arch: armv7 + - target: arm-unknown-linux-musleabihf + arch: arm + steps: + - uses: actions/checkout@v4 + - name: "Build wheels" + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + # On `aarch64`, use `manylinux: 2_28`; otherwise, use `manylinux: auto`. + manylinux: ${{ matrix.platform.arch == 'aarch64' && '2_28' || 'auto' }} + docker-options: ${{ matrix.platform.maturin_docker_options }} + args: --release --locked --out dist --features self-update - name: "Upload wheels" uses: actions/upload-artifact@v4 with: @@ -69,64 +246,91 @@ jobs: *.tar.gz *.sha256 - windows: - runs-on: ${{ matrix.platform.runner }} + linux-s390x: + runs-on: ubuntu-latest + timeout-minutes: 30 strategy: matrix: platform: - - runner: windows-latest - target: x86_64-pc-windows-msvc + - target: s390x-unknown-linux-gnu + arch: s390x steps: - uses: actions/checkout@v4 - name: "Build wheels" uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} + manylinux: auto args: --release --locked --out dist --features self-update - sccache: 'true' + # Until the llvm updates hit stable + # https://github.com/rust-lang/rust/issues/141287 + rust-toolchain: nightly-2025-08-18 - name: "Upload wheels" uses: actions/upload-artifact@v4 with: - name: wheels-windows-${{ matrix.platform.target }} + name: wheels-linux-${{ matrix.platform.target }} path: dist - name: "Archive binary" shell: bash run: | - ARCHIVE_FILE=prek-${{ matrix.platform.target }}.zip - 7z a $ARCHIVE_FILE ./target/${{ matrix.platform.target }}/release/prek.exe - sha256sum $ARCHIVE_FILE > $ARCHIVE_FILE.sha256 + set -euo pipefail + + TARGET=${{ matrix.platform.target }} + ARCHIVE_NAME=prek-$TARGET + ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz + + mkdir -p $ARCHIVE_NAME + cp target/$TARGET/release/prek $ARCHIVE_NAME/prek + tar czvf $ARCHIVE_FILE $ARCHIVE_NAME + shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256 - name: "Upload binary" uses: actions/upload-artifact@v4 with: name: artifacts-${{ matrix.platform.target }} path: | - *.zip + *.tar.gz *.sha256 - macos: - runs-on: ${{ matrix.platform.runner }} + linux-powerpc: + runs-on: ubuntu-latest + timeout-minutes: 30 strategy: matrix: platform: - - runner: macos-15 - target: x86_64-apple-darwin - - runner: macos-15 - target: aarch64-apple-darwin + - target: powerpc64le-unknown-linux-gnu + arch: ppc64le + # see https://github.com/astral-sh/uv/issues/6528 + maturin_docker_options: -e JEMALLOC_SYS_WITH_LG_PAGE=16 + - target: powerpc64-unknown-linux-gnu + arch: ppc64 + # see https://github.com/astral-sh/uv/issues/6528 + maturin_docker_options: -e JEMALLOC_SYS_WITH_LG_PAGE=16 steps: - uses: actions/checkout@v4 - name: "Build wheels" uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} + manylinux: auto + docker-options: ${{ matrix.platform.maturin_docker_options }} args: --release --locked --out dist --features self-update - sccache: 'true' + before-script-linux: | + if command -v yum &> /dev/null; then + yum update -y + yum -y install epel-release + yum repolist + yum install -y gcc-powerpc64-linux-gnu + fi - name: "Upload wheels" uses: actions/upload-artifact@v4 with: - name: wheels-macos-${{ matrix.platform.target }} + name: wheels-linux-${{ matrix.platform.target }} path: dist - name: "Archive binary" + shell: bash run: | + set -euo pipefail + TARGET=${{ matrix.platform.target }} ARCHIVE_NAME=prek-$TARGET ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz @@ -143,17 +347,133 @@ jobs: *.tar.gz *.sha256 - sdist: + linux-riscv64: runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + matrix: + platform: + - target: riscv64gc-unknown-linux-gnu + arch: riscv64 steps: - uses: actions/checkout@v4 - - name: Build sdist + - name: "Build wheels" uses: PyO3/maturin-action@v1 with: - command: sdist - args: --out dist - - name: "Upload sdist" + target: ${{ matrix.platform.target }} + manylinux: auto + args: --release --locked --out dist --features self-update + - name: "Upload wheels" uses: actions/upload-artifact@v4 with: - name: wheels-sdist + name: wheels-linux-${{ matrix.platform.target }} path: dist + - name: "Archive binary" + shell: bash + run: | + set -euo pipefail + + TARGET=${{ matrix.platform.target }} + ARCHIVE_NAME=prek-$TARGET + ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz + + mkdir -p $ARCHIVE_NAME + cp target/$TARGET/release/prek $ARCHIVE_NAME/prek + tar czvf $ARCHIVE_FILE $ARCHIVE_NAME + shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256 + - name: "Upload binary" + uses: actions/upload-artifact@v4 + with: + name: artifacts-${{ matrix.platform.target }} + path: | + *.tar.gz + *.sha256 + + + musllinux: + runs-on: ubuntu-latest + strategy: + matrix: + target: + - x86_64-unknown-linux-musl + - i686-unknown-linux-musl + steps: + - uses: actions/checkout@v4 + - name: "Build wheels" + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + manylinux: musllinux_1_1 + args: --release --locked --out dist --features self-update + - name: "Upload wheels" + uses: actions/upload-artifact@v4 + with: + name: wheels-linux-${{ matrix.target }} + path: dist + - name: "Archive binary" + shell: bash + run: | + set -euo pipefail + + TARGET=${{ matrix.target }} + ARCHIVE_NAME=prek-$TARGET + ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz + + mkdir -p $ARCHIVE_NAME + cp target/$TARGET/release/prek $ARCHIVE_NAME/prek + tar czvf $ARCHIVE_FILE $ARCHIVE_NAME + shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256 + - name: "Upload binary" + uses: actions/upload-artifact@v4 + with: + name: artifacts-${{ matrix.target }} + path: | + *.tar.gz + *.sha256 + + musllinux-cross: + runs-on: ubuntu-latest + strategy: + matrix: + platform: + - target: aarch64-unknown-linux-musl + arch: aarch64 + maturin_docker_options: -e JEMALLOC_SYS_WITH_LG_PAGE=16 + - target: armv7-unknown-linux-musleabihf + arch: armv7 + fail-fast: false + steps: + - uses: actions/checkout@v4 + - name: "Build wheels" + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + manylinux: musllinux_1_1 + args: --release --locked --out dist --features self-update ${{ matrix.platform.arch == 'aarch64' && '--compatibility 2_17' || ''}} + docker-options: ${{ matrix.platform.maturin_docker_options }} + rust-toolchain: ${{ matrix.platform.toolchain || null }} + - name: "Upload wheels" + uses: actions/upload-artifact@v4 + with: + name: wheels-linux-${{ matrix.platform.target }} + path: dist + - name: "Archive binary" + shell: bash + run: | + set -euo pipefail + + TARGET=${{ matrix.platform.target }} + ARCHIVE_NAME=prek-$TARGET + ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz + + mkdir -p $ARCHIVE_NAME + cp target/$TARGET/release/prek $ARCHIVE_NAME/prek + tar czvf $ARCHIVE_FILE $ARCHIVE_NAME + shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256 + - name: "Upload binary" + uses: actions/upload-artifact@v4 + with: + name: artifacts-${{ matrix.platform.target }} + path: | + *.tar.gz + *.sha256 diff --git a/dist-workspace.toml b/dist-workspace.toml index 0b678260a..a95d701d3 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -20,7 +20,26 @@ github-release = "announce" # The installers to generate for each app installers = ["shell", "powershell", "homebrew"] # Target platforms to build apps for (Rust target-triple syntax) -targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"] +targets = [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "aarch64-unknown-linux-musl", + "aarch64-pc-windows-msvc", + "arm-unknown-linux-musleabihf", + "armv7-unknown-linux-gnueabihf", + "armv7-unknown-linux-musleabihf", + "x86_64-apple-darwin", + "powerpc64-unknown-linux-gnu", + "powerpc64le-unknown-linux-gnu", + "riscv64gc-unknown-linux-gnu", + "s390x-unknown-linux-gnu", + "x86_64-unknown-linux-gnu", + "x86_64-unknown-linux-musl", + "x86_64-pc-windows-msvc", + "i686-unknown-linux-gnu", + "i686-unknown-linux-musl", + "i686-pc-windows-msvc" +] # Local artifacts jobs to run in CI local-artifacts-jobs = ["./build-binaries"] # Publish jobs to run in CI