# Build uv on all platforms.
#
# Generates both wheels (for PyPI) and archived binaries (for GitHub releases).
#
# Called from:
# - .github/workflows/ci.yml (when release-relevant files change)
# - .github/workflows/release.yml (as a local artifacts job within `cargo-dist`)
name: "Build release binaries"

on:
  workflow_call:
    inputs:
      plan:
        required: false
        type: string

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  PACKAGE_NAME: uv
  MODULE_NAME: uv
  PYTHON_VERSION: "3.11"
  CARGO_INCREMENTAL: 0
  CARGO_NET_RETRY: 10
  CARGO_TERM_COLOR: always
  RUSTUP_MAX_RETRIES: 10

permissions: {}

jobs:
  sdist:
    name: sdist
    runs-on: depot-ubuntu-24.04-4
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}

      # uv
      - name: "Prep README.md"
        run: python scripts/transform_readme.py --target pypi
      - name: "Build sdist"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          command: sdist
          args: --out dist
      - name: "Test sdist"
        run: |
          # We can't use `--find-links` here, since we need maturin, which means no `--no-index`, and without that option
          # we run the risk that pip pull uv from PyPI instead.
          pip install dist/${PACKAGE_NAME}-*.tar.gz --force-reinstall
          ${MODULE_NAME} --help
          python -m ${MODULE_NAME} --help
          uvx --help
      - name: "Upload sdist"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv-sdist
          path: dist

      # uv-build
      - name: "Build sdist uv-build"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          command: sdist
          args: --out crates/uv-build/dist -m crates/uv-build/Cargo.toml
      - name: "Fix Cargo.lock in sdist uv-build"
        run: python scripts/repair-sdist-cargo-lock.py crates/uv-build/dist/${PACKAGE_NAME}_build-*.tar.gz
      - name: "Test sdist uv-build"
        run: |
          pip install crates/uv-build/dist/${PACKAGE_NAME}_build-*.tar.gz --force-reinstall
          ${MODULE_NAME}-build --help
          python -m ${MODULE_NAME}_build --help
      - name: "Upload sdist uv-build"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv_build-sdist
          path: crates/uv-build/dist

  macos-x86_64:
    name: x86_64-apple-darwin
    runs-on: depot-macos-15
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}
          architecture: x64
      - name: "Prep README.md"
        run: python scripts/transform_readme.py --target pypi
      - name: "Install cargo extensions"
        shell: bash
        run: scripts/install-cargo-extensions.sh

      # uv
      - name: "Build wheels - x86_64"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: x86_64
          args: --release --locked --out dist --features self-update --compatibility pypi
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      - name: "Upload wheels"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv-macos-x86_64
          path: dist
      - name: "Archive binary"
        run: |
          TARGET=x86_64-apple-darwin
          ARCHIVE_NAME=uv-$TARGET
          ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz

          mkdir -p $ARCHIVE_NAME
          cp target/$TARGET/release/uv $ARCHIVE_NAME/uv
          cp target/$TARGET/release/uvx $ARCHIVE_NAME/uvx
          tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
          shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
      - name: "Upload binary"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: artifacts-macos-x86_64
          path: |
            *.tar.gz
            *.sha256

      # uv-build
      - name: "Build wheels uv-build - x86_64"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: x86_64
          args: --profile minimal-size --locked --out crates/uv-build/dist -m crates/uv-build/Cargo.toml --compatibility pypi
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      - name: "Upload wheels uv-build"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv_build-macos-x86_64
          path: crates/uv-build/dist

  macos-aarch64:
    name: aarch64-apple-darwin
    runs-on: depot-macos-15
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}
          architecture: arm64
      - name: "Prep README.md"
        run: python scripts/transform_readme.py --target pypi
      - name: "Install cargo extensions"
        shell: bash
        run: scripts/install-cargo-extensions.sh

      # uv
      - name: "Build wheels - aarch64"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: aarch64
          manylinux: 2_17
          args: --release --locked --out dist --features self-update --compatibility pypi
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      - name: "Test wheel - aarch64"
        run: |
          pip install ${PACKAGE_NAME} --no-index --find-links dist/ --force-reinstall
          ${MODULE_NAME} --help
          python -m ${MODULE_NAME} --help
          uvx --help
      - name: "Upload wheels"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv-aarch64-apple-darwin
          path: dist
      - name: "Archive binary"
        run: |
          TARGET=aarch64-apple-darwin
          ARCHIVE_NAME=uv-$TARGET
          ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz

          mkdir -p $ARCHIVE_NAME
          cp target/$TARGET/release/uv $ARCHIVE_NAME/uv
          cp target/$TARGET/release/uvx $ARCHIVE_NAME/uvx
          tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
          shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
      - name: "Upload binary"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: artifacts-aarch64-apple-darwin
          path: |
            *.tar.gz
            *.sha256

      # uv-build
      - name: "Build wheels uv-build - aarch64"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: aarch64
          args: --profile minimal-size --locked --out crates/uv-build/dist -m crates/uv-build/Cargo.toml --compatibility pypi
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      - name: "Test wheel - aarch64"
        run: |
          pip install ${PACKAGE_NAME}_build --no-index --find-links crates/uv-build/dist --force-reinstall
          ${MODULE_NAME}-build --help
          python -m ${MODULE_NAME}_build --help
      - name: "Upload wheels uv-build"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv_build-aarch64-apple-darwin
          path: crates/uv-build/dist

  windows:
    name: ${{ matrix.platform.target }}
    runs-on: ${{ matrix.platform.runner }}
    strategy:
      matrix:
        platform:
          - target: x86_64-pc-windows-msvc
            arch: x64
            runner: github-windows-2025-x86_64-8
          - target: i686-pc-windows-msvc
            arch: x86
            runner: github-windows-2025-x86_64-8
          - target: aarch64-pc-windows-msvc
            arch: arm64
            runner: github-windows-11-aarch64-8
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}
          architecture: ${{ matrix.platform.arch }}
      - name: "Prep README.md"
        run: python scripts/transform_readme.py --target pypi
      - name: "Install cargo extensions"
        shell: bash
        run: scripts/install-cargo-extensions.sh
      - name: "Install NASM"
        # NASM is required for x86/x86-64 Windows targets by aws-lc-sys.
        # On aarch64-pc-windows-msvc, it uses clang-cl instead.
        # See: https://aws.github.io/aws-lc-rs/requirements/windows.html#build-requirements
        if: contains(matrix.platform.target, 'x86') || contains(matrix.platform.target, 'i686')
        run: |
          winget install NASM.NASM --accept-source-agreements --accept-package-agreements
          echo "C:\Program Files\NASM" | Out-File -FilePath $env:GITHUB_PATH -Append
      # uv
      - name: "Build wheels"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.platform.target }}
          args: --release --locked --out dist --features self-update,windows-gui-bin --compatibility pypi
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.cmd
          # Disable prebuilt NASM objects so we always compile assembly from source.
          AWS_LC_SYS_PREBUILT_NASM: "0"
      - name: "Test wheel"
        shell: bash
        run: |
          pip install ${PACKAGE_NAME} --no-index --find-links dist/ --force-reinstall
          ${MODULE_NAME} --help
          python -m ${MODULE_NAME} --help
          uvx --help
          uvw --help
      - name: "Upload wheels"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv-${{ matrix.platform.target }}
          path: dist
      - name: "Archive binary"
        shell: bash
        run: |
          ARCHIVE_FILE=uv-${PLATFORM_TARGET}.zip
          7z a $ARCHIVE_FILE ./target/${PLATFORM_TARGET}/release/uv.exe
          7z a $ARCHIVE_FILE ./target/${PLATFORM_TARGET}/release/uvx.exe
          7z a $ARCHIVE_FILE ./target/${PLATFORM_TARGET}/release/uvw.exe
          sha256sum $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
        env:
          PLATFORM_TARGET: ${{ matrix.platform.target }}
      - name: "Upload binary"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: artifacts-${{ matrix.platform.target }}
          path: |
            *.zip
            *.sha256

      # uv-build
      - name: "Build wheels uv-build"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.platform.target }}
          args: --profile minimal-size --locked --out crates/uv-build/dist -m crates/uv-build/Cargo.toml --compatibility pypi
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.cmd
      - name: "Test wheel uv-build"
        shell: bash
        run: |
          pip install ${PACKAGE_NAME}_build --no-index --find-links crates/uv-build/dist --force-reinstall
          ${MODULE_NAME}-build --help
          python -m ${MODULE_NAME}_build --help
      - name: "Upload wheels uv-build"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv_build-${{ matrix.platform.target }}
          path: crates/uv-build/dist

  linux:
    name: ${{ matrix.target }}
    runs-on: depot-ubuntu-latest-4
    strategy:
      matrix:
        include:
          - { target: "i686-unknown-linux-gnu", cc: "gcc -m32" }
          - { target: "x86_64-unknown-linux-gnu", cc: "gcc" }
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}
          architecture: x64
      - name: "Prep README.md"
        run: python scripts/transform_readme.py --target pypi

      # uv
      - name: "Build wheels"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          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
          manylinux: 2_17
          docker-options: -e CARGO
          args: --release --locked --out dist --features self-update --compatibility pypi
          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 pkgconfig libatomic

                # Install cross build requirements
                if [[ "${{ matrix.target }}" == "i686-unknown-linux-gnu" ]]; then
                  yum install -y glibc-devel.i686 libstdc++-devel.i686 libatomic.i686
                fi

                # Symlink libatomic so the linker can find it with -latomic.
                if [[ -f "/usr/lib/libatomic.so.1" && ! -f "/usr/lib/libatomic.so" ]]; then
                    ln -s /usr/lib/libatomic.so.1 /usr/lib/libatomic.so
                fi
            else
                # If we're running on debian-based system.
                apt update -y && apt-get install -y pkg-config
            fi
            # Install cargo extensions as a static musl binary so it runs in any container.
            scripts/install-cargo-extensions.sh
        env:
          CC: ${{ matrix.cc }}
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      - name: "Test wheel"
        if: ${{ startsWith(matrix.target, 'x86_64') }}
        run: |
          pip install ${PACKAGE_NAME} --no-index --find-links dist/ --force-reinstall
          ${MODULE_NAME} --help
          python -m ${MODULE_NAME} --help
          uvx --help
      - name: "Upload wheels"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv-${{ matrix.target }}
          path: dist
      - name: "Archive binary"
        shell: bash
        run: |
          ARCHIVE_NAME=uv-$TARGET
          ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz

          mkdir -p $ARCHIVE_NAME
          cp target/$TARGET/release/uv $ARCHIVE_NAME/uv
          cp target/$TARGET/release/uvx $ARCHIVE_NAME/uvx
          tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
          shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
        env:
          TARGET: ${{ matrix.target }}
      - name: "Upload binary"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: artifacts-${{ matrix.target }}
          path: |
            *.tar.gz
            *.sha256

      # uv-build
      - name: "Build wheels uv-build"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.target }}
          manylinux: 2_17
          docker-options: -e CARGO
          args: --profile minimal-size --locked --out crates/uv-build/dist -m crates/uv-build/Cargo.toml --compatibility pypi
          before-script-linux: |
            scripts/install-cargo-extensions.sh
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      - name: "Test wheel uv-build"
        if: ${{ startsWith(matrix.target, 'x86_64') }}
        run: |
          pip install ${PACKAGE_NAME}_build --no-index --find-links crates/uv-build/dist --force-reinstall
          ${MODULE_NAME}-build --help
          python -m ${MODULE_NAME}_build --help
      - name: "Upload wheels uv-build"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv_build-${{ matrix.target }}
          path: crates/uv-build/dist

  linux-arm:
    name: ${{ matrix.platform.target }}
    runs-on: depot-ubuntu-24.04-8
    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
            # Build fails with 2_17 container: https://github.com/astral-sh/uv/actions/runs/20850906093/job/59905482208?pr=17358
            manylinux: 2_28
          - target: armv7-unknown-linux-gnueabihf
            arch: armv7
            manylinux: 2_17
          - target: arm-unknown-linux-musleabihf
            arch: arm
            # Special case: armv6l is linux_armv6l, no manylinux or musllinux.
            # "auto" instead of "off" to get the cross container
            manylinux: auto

    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: "Prep README.md"
        run: python scripts/transform_readme.py --target pypi

      # uv
      - name: "Build wheels"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.platform.target }}
          manylinux: ${{ matrix.platform.manylinux }}
          docker-options: -e CARGO ${{ matrix.platform.maturin_docker_options }}
          args: --release --locked --out dist --features self-update --compatibility pypi
          before-script-linux: |
            scripts/install-cargo-extensions.sh
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      # TODO(zanieb): Find an alternative for this action; it uses EOL Node 20
      - uses: uraimo/run-on-arch-action@f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9 # v3.1.0
        name: "Test wheel"
        with:
          arch: ${{ matrix.platform.arch == 'arm' && 'armv6' || matrix.platform.arch }}
          distro: ${{ matrix.platform.arch == 'arm' && 'bullseye' || 'ubuntu20.04' }}
          install: |
            apt-get update
            apt-get install -y --no-install-recommends python3 python3-pip python-is-python3
            pip3 install -U pip
          run: |
            pip install ${PACKAGE_NAME} --no-index --find-links dist/ --force-reinstall
            ${MODULE_NAME} --help
            # TODO(konsti): Enable this test on all platforms, currently `find_uv_bin` is failing to discover uv here.
            # python -m ${MODULE_NAME} --help
            uvx --help
          env: |
            PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
            MODULE_NAME: ${{ env.MODULE_NAME }}
      - name: "Upload wheels"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv-${{ matrix.platform.target }}
          path: dist
      - name: "Archive binary"
        shell: bash
        run: |
          ARCHIVE_NAME=uv-$TARGET
          ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz

          mkdir -p $ARCHIVE_NAME
          cp target/$TARGET/release/uv $ARCHIVE_NAME/uv
          cp target/$TARGET/release/uvx $ARCHIVE_NAME/uvx
          tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
          shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
        env:
          TARGET: ${{ matrix.platform.target }}
      - name: "Upload binary"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: artifacts-${{ matrix.platform.target }}
          path: |
            *.tar.gz
            *.sha256

      # uv-build
      - name: "Build wheels uv-build"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.platform.target }}
          manylinux: ${{ matrix.platform.manylinux }}
          docker-options: -e CARGO ${{ matrix.platform.maturin_docker_options }}
          args: --profile minimal-size --locked --out crates/uv-build/dist -m crates/uv-build/Cargo.toml --compatibility pypi
          before-script-linux: |
            scripts/install-cargo-extensions.sh
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      # TODO(zanieb): Find an alternative for this action; it uses EOL Node 20
      - uses: uraimo/run-on-arch-action@f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9 # v3.1.0
        name: "Test wheel uv-build"
        with:
          arch: ${{ matrix.platform.arch == 'arm' && 'armv6' || matrix.platform.arch }}
          distro: ${{ matrix.platform.arch == 'arm' && 'bullseye' || 'ubuntu20.04' }}
          install: |
            apt-get update
            apt-get install -y --no-install-recommends python3 python3-pip python-is-python3
            pip3 install -U pip
          run: |
            pip install ${PACKAGE_NAME}_build --no-index --find-links crates/uv-build/dist --force-reinstall
            ${MODULE_NAME}-build --help
            # TODO(konsti): Enable this test on all platforms, currently `find_uv_bin` is failing to discover uv here.
            # python -m ${MODULE_NAME}_build --help
          env: |
            PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
            MODULE_NAME: ${{ env.MODULE_NAME }}
      - name: "Upload wheels uv-build"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv_build-${{ matrix.platform.target }}
          path: crates/uv-build/dist

  # Like `linux-arm`.
  linux-s390x:
    name: ${{ matrix.platform.target }}
    timeout-minutes: 30
    runs-on: depot-ubuntu-latest-4
    strategy:
      matrix:
        platform:
          - target: s390x-unknown-linux-gnu
            arch: s390x

    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: "Prep README.md"
        run: python scripts/transform_readme.py --target pypi

      # uv
      - name: "Build wheels"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.platform.target }}
          manylinux: 2_17
          docker-options: -e CARGO ${{ matrix.platform.maturin_docker_options }}
          args: --release --locked --out dist --features self-update --compatibility pypi
          rust-toolchain: ${{ matrix.platform.toolchain || null }}
          before-script-linux: |
            scripts/install-cargo-extensions.sh
            # Install the s390x cross target on x86_64
            rustup target add ${{ matrix.platform.target }}
            apt-get update && apt-get install -y gcc-s390x-linux-gnu binutils-s390x-linux-gnu
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh

      # TODO(zanieb): Find an alternative for this action; it uses EOL Node 20
      - uses: uraimo/run-on-arch-action@f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9 # v3.1.0
        name: "Test wheel"
        with:
          arch: ${{ matrix.platform.arch }}
          distro: ubuntu20.04
          install: |
            apt-get update
            apt-get install -y --no-install-recommends python3 python3-pip python-is-python3
            pip3 install -U pip
          run: |
            pip install ${PACKAGE_NAME} --no-index --find-links dist/ --force-reinstall
            ${MODULE_NAME} --help
            # TODO(konsti): Enable this test on all platforms, currently `find_uv_bin` is failing to discover uv here.
            # python -m ${MODULE_NAME} --help
            uvx --help
          env: |
            PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
            MODULE_NAME: ${{ env.MODULE_NAME }}
      - name: "Upload wheels"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv-${{ matrix.platform.target }}
          path: dist
      - name: "Archive binary"
        shell: bash
        run: |
          ARCHIVE_NAME=uv-$TARGET
          ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz

          mkdir -p $ARCHIVE_NAME
          cp target/$TARGET/release/uv $ARCHIVE_NAME/uv
          cp target/$TARGET/release/uvx $ARCHIVE_NAME/uvx
          tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
          shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
        env:
          TARGET: ${{ matrix.platform.target }}
      - name: "Upload binary"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: artifacts-${{ matrix.platform.target }}
          path: |
            *.tar.gz
            *.sha256

      # uv-build
      - name: "Build wheels uv-build"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.platform.target }}
          manylinux: 2_17
          docker-options: -e CARGO ${{ matrix.platform.maturin_docker_options }}
          args: --profile minimal-size --locked --out crates/uv-build/dist -m crates/uv-build/Cargo.toml --compatibility pypi
          before-script-linux: |
            scripts/install-cargo-extensions.sh
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      # TODO(zanieb): Find an alternative for this action; it uses EOL Node 20
      - uses: uraimo/run-on-arch-action@f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9 # v3.1.0
        name: "Test wheel uv-build"
        with:
          arch: ${{ matrix.platform.arch }}
          distro: ubuntu20.04
          install: |
            apt-get update
            apt-get install -y --no-install-recommends python3 python3-pip python-is-python3
            pip3 install -U pip
          run: |
            pip install ${PACKAGE_NAME}-build --no-index --find-links crates/uv-build/dist --force-reinstall
            ${MODULE_NAME}-build --help
            # TODO(konsti): Enable this test on all platforms, currently `find_uv_bin` is failing to discover uv here.
            # python -m ${MODULE_NAME}-build --help
          env: |
            PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
            MODULE_NAME: ${{ env.MODULE_NAME }}
      - name: "Upload wheels uv-build"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv_build-${{ matrix.platform.target }}
          path: crates/uv-build/dist

  # Like `linux-arm`, but install the `gcc-powerpc64-linux-gnu` package.
  linux-powerpc:
    name: ${{ matrix.platform.target }}
    runs-on: depot-ubuntu-24.04-4
    strategy:
      matrix:
        platform:
          - 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

    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: "Prep README.md"
        run: python scripts/transform_readme.py --target pypi

      # uv
      - name: "Build wheels"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.platform.target }}
          manylinux: 2_17
          docker-options: -e CARGO ${{ matrix.platform.maturin_docker_options }}
          args: --release --locked --out dist --features self-update --compatibility pypi
          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
            scripts/install-cargo-extensions.sh
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      # TODO(charlie): Re-enable testing for PPC wheels.
      # - uses: uraimo/run-on-arch-action@d94c13912ea685de38fccc1109385b83fd79427d # v3.0.1
      #   name: "Test wheel"
      #   with:
      #     arch: ${{ matrix.platform.arch }}
      #     distro: ubuntu20.04
      #     install: |
      #       apt-get update
      #       apt-get install -y --no-install-recommends python3 python3-pip python-is-python3
      #       pip3 install -U pip
      #     run: |
      #       pip install ${PACKAGE_NAME} --no-index --find-links dist/ --force-reinstall
      #       ${MODULE_NAME} --help
      #       #(konsti) TODO: Enable this test on all platforms,currently `find_uv_bin` is failingto discover uv here.
      #       # python -m ${MODULE_NAME} --helppython -m ${MODULE_NAME} --help
      #       uvx --help
      - name: "Upload wheels"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv-${{ matrix.platform.target }}
          path: dist
      - name: "Archive binary"
        shell: bash
        run: |
          ARCHIVE_NAME=uv-$TARGET
          ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz

          mkdir -p $ARCHIVE_NAME
          cp target/$TARGET/release/uv $ARCHIVE_NAME/uv
          cp target/$TARGET/release/uvx $ARCHIVE_NAME/uvx
          tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
          shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
        env:
          TARGET: ${{ matrix.platform.target }}
      - name: "Upload binary"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: artifacts-${{ matrix.platform.target }}
          path: |
            *.tar.gz
            *.sha256

      # uv-build
      - name: "Build wheels uv-build"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.platform.target }}
          manylinux: 2_17
          docker-options: -e CARGO ${{ matrix.platform.maturin_docker_options }}
          args: --profile minimal-size --locked --out crates/uv-build/dist -m crates/uv-build/Cargo.toml --compatibility pypi
          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
            scripts/install-cargo-extensions.sh
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      # TODO(charlie): Re-enable testing for PPC wheels.
      - name: "Upload wheels uv-build"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv_build-${{ matrix.platform.target }}
          path: crates/uv-build/dist

  # Like `linux-arm`.
  linux-riscv64:
    name: ${{ matrix.platform.target }}
    timeout-minutes: 30
    runs-on: depot-ubuntu-latest-4
    strategy:
      matrix:
        platform:
          - target: riscv64gc-unknown-linux-gnu
            arch: riscv64

    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: "Prep README.md"
        run: python scripts/transform_readme.py --target pypi

      # uv
      - name: "Build wheels"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.platform.target }}
          manylinux: 2_31
          docker-options: -e CARGO ${{ matrix.platform.maturin_docker_options }}
          args: --release --locked --out dist --features self-update --compatibility pypi
          before-script-linux: |
            scripts/install-cargo-extensions.sh
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      # TODO(zanieb): Find an alternative for this action; it uses EOL Node 20
      - uses: uraimo/run-on-arch-action@f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9 # v3.1.0
        name: "Test wheel"
        with:
          arch: ${{ matrix.platform.arch }}
          distro: ubuntu20.04
          githubToken: ${{ github.token }}
          install: |
            apt-get update
            apt-get install -y --no-install-recommends python3 python3-pip python-is-python3
            pip3 install -U pip
          run: |
            pip install ${PACKAGE_NAME} --no-index --find-links dist/ --force-reinstall
            ${MODULE_NAME} --help
            # TODO(konsti): Enable this test on all platforms, currently `find_uv_bin` is failing to discover uv here.
            # python -m ${MODULE_NAME} --help
            uvx --help
          env: |
            PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
            MODULE_NAME: ${{ env.MODULE_NAME }}
      - name: "Upload wheels"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv-${{ matrix.platform.target }}
          path: dist
      - name: "Archive binary"
        shell: bash
        run: |
          ARCHIVE_NAME=uv-$TARGET
          ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz

          mkdir -p $ARCHIVE_NAME
          cp target/$TARGET/release/uv $ARCHIVE_NAME/uv
          cp target/$TARGET/release/uvx $ARCHIVE_NAME/uvx
          tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
          shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
        env:
          TARGET: ${{ matrix.platform.target }}
      - name: "Upload binary"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: artifacts-${{ matrix.platform.target }}
          path: |
            *.tar.gz
            *.sha256

      # uv-build
      - name: "Build wheels uv-build"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.platform.target }}
          manylinux: 2_31
          docker-options: -e CARGO ${{ matrix.platform.maturin_docker_options }}
          args: --profile minimal-size --locked --out crates/uv-build/dist -m crates/uv-build/Cargo.toml --compatibility pypi
          before-script-linux: |
            scripts/install-cargo-extensions.sh
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      # TODO(zanieb): Find an alternative for this action; it uses EOL Node 20
      - uses: uraimo/run-on-arch-action@f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9 # v3.1.0
        name: "Test wheel uv-build"
        with:
          arch: ${{ matrix.platform.arch }}
          distro: ubuntu20.04
          githubToken: ${{ github.token }}
          install: |
            apt-get update
            apt-get install -y --no-install-recommends python3 python3-pip python-is-python3
            pip3 install -U pip
          run: |
            pip install ${PACKAGE_NAME}-build --no-index --find-links crates/uv-build/dist --force-reinstall
            ${MODULE_NAME}-build --help
            # TODO(konsti): Enable this test on all platforms, currently `find_uv_bin` is failing to discover uv here.
            # python -m ${MODULE_NAME}-build --help
          env: |
            PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
            MODULE_NAME: ${{ env.MODULE_NAME }}
      - name: "Upload wheels uv-build"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv_build-${{ matrix.platform.target }}
          path: crates/uv-build/dist

  musllinux:
    name: ${{ matrix.target }}
    runs-on: depot-ubuntu-24.04-4
    strategy:
      matrix:
        target:
          - x86_64-unknown-linux-musl
          - i686-unknown-linux-musl
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}
          architecture: x64
      - name: "Prep README.md"
        run: python scripts/transform_readme.py --target pypi

      # uv
      - name: "Build wheels"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.target }}
          manylinux: musllinux_1_1
          docker-options: -e CARGO
          args: --release --locked --out dist --features self-update --compatibility pypi
          before-script-linux: |
            scripts/install-cargo-extensions.sh
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      - name: "Test wheel"
        if: matrix.target == 'x86_64-unknown-linux-musl'
        run: |
          docker run --rm -v ${{ github.workspace }}:/io -w /io --env MODULE_NAME --env PACKAGE_NAME alpine:3.12 sh -c "
            apk add python3 py3-pip;
            python3 -m venv .venv;
            .venv/bin/pip install --upgrade pip;
            .venv/bin/pip install ${PACKAGE_NAME} --no-index --find-links dist/ --force-reinstall;
            .venv/bin/${MODULE_NAME} --help;
            # TODO(konsti): Enable this test on all platforms, currently `find_uv_bin` is failing to discover uv here.
            # .venv/bin/python -m ${MODULE_NAME} --help;
            .venv/bin/uvx --help;
          "
      - name: "Upload wheels"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv-${{ matrix.target }}
          path: dist
      - name: "Archive binary"
        shell: bash
        run: |
          ARCHIVE_NAME=uv-$TARGET
          ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz

          mkdir -p $ARCHIVE_NAME
          cp target/$TARGET/release/uv $ARCHIVE_NAME/uv
          cp target/$TARGET/release/uvx $ARCHIVE_NAME/uvx
          tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
          shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
        env:
          TARGET: ${{ matrix.target }}
      - name: "Upload binary"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: artifacts-${{ matrix.target }}
          path: |
            *.tar.gz
            *.sha256

      # uv-build
      - name: "Build wheels uv-build"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.target }}
          manylinux: musllinux_1_1
          docker-options: -e CARGO
          args: --profile minimal-size --locked --out crates/uv-build/dist -m crates/uv-build/Cargo.toml --compatibility pypi
          before-script-linux: |
            scripts/install-cargo-extensions.sh
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      - name: "Test wheel uv-build"
        if: matrix.target == 'x86_64-unknown-linux-musl'
        run: |
          docker run --rm -v ${{ github.workspace }}:/io -w /io --env MODULE_NAME --env PACKAGE_NAME alpine:3.12 sh -c "
            apk add python3 py3-pip;
            python3 -m venv .venv;
            .venv/bin/pip install --upgrade pip;
            .venv/bin/pip install ${PACKAGE_NAME}-build --no-index --find-links crates/uv-build/dist --force-reinstall;
            .venv/bin/${MODULE_NAME}-build --help;
            # TODO(konsti): Enable this test on all platforms, currently `find_uv_bin` is failing to discover uv here.
            # .venv/bin/python -m ${MODULE_NAME}_build --help;
          "
      - name: "Upload wheels uv-build"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv_build-${{ matrix.target }}
          path: crates/uv-build/dist

  musllinux-cross:
    name: ${{ matrix.platform.target }}
    runs-on: depot-ubuntu-24.04-8
    env:
      CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-C target-feature=+crt-static"
    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
          - target: riscv64gc-unknown-linux-musl
            arch: riscv64
      fail-fast: false

    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: "Prep README.md"
        run: python scripts/transform_readme.py --target pypi

      # uv
      - name: "Build wheels"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.platform.target }}
          manylinux: musllinux_1_1
          # Tag the musl builds as manylinux 2_17 fallback cause the aarch64 build only support 2_28
          args: --release --locked --out dist --features self-update --compatibility ${{ matrix.platform.arch == 'riscv64' && '2_31' || '2_17'}} --compatibility pypi
          docker-options: -e CARGO ${{ matrix.platform.maturin_docker_options }}
          rust-toolchain: ${{ matrix.platform.toolchain || null }}
          before-script-linux: |
            scripts/install-cargo-extensions.sh
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      # TODO(zanieb): Find an alternative for this action; it uses EOL Node 20
      - uses: uraimo/run-on-arch-action@f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9 # v3.1.0
        name: "Test wheel"
        with:
          arch: ${{ matrix.platform.arch }}
          distro: alpine_latest
          install: |
            apk add python3
          run: |
            python -m venv .venv
            .venv/bin/pip install ${PACKAGE_NAME} --no-index --find-links dist/ --force-reinstall
            .venv/bin/${MODULE_NAME} --help
            # TODO(konsti): Enable this test on all platforms, currently `find_uv_bin` is failing to discover uv here.
            # .venv/bin/python -m ${MODULE_NAME} --help
            .venv/bin/uvx --help
          env: |
            PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
            MODULE_NAME: ${{ env.MODULE_NAME }}
      # TODO(zanieb): Find an alternative for this action; it uses EOL Node 20
      - uses: uraimo/run-on-arch-action@f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9 # v3.1.0
        name: "Test wheel (manylinux)"
        if: matrix.platform.arch == 'aarch64'
        with:
          arch: aarch64
          distro: ubuntu20.04
          install: |
            apt-get update
            apt-get install -y --no-install-recommends python3 python3-pip python-is-python3
            pip3 install -U pip
          run: |
            pip install ${PACKAGE_NAME} --no-index --find-links dist/ --force-reinstall
            ${MODULE_NAME} --help
            # TODO(konsti): Enable this test on all platforms, currently `find_uv_bin` is failing to discover uv here.
            # python -m ${MODULE_NAME} --help
            uvx --help
          env: |
            PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
            MODULE_NAME: ${{ env.MODULE_NAME }}
      - name: "Upload wheels"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv-${{ matrix.platform.target }}
          path: dist
      - name: "Archive binary"
        shell: bash
        run: |
          ARCHIVE_NAME=uv-$TARGET
          ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz

          mkdir -p $ARCHIVE_NAME
          cp target/$TARGET/$PROFILE/uv $ARCHIVE_NAME/uv
          cp target/$TARGET/$PROFILE/uvx $ARCHIVE_NAME/uvx
          tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
          shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
        env:
          TARGET: ${{ matrix.platform.target }}
          PROFILE: ${{ matrix.platform.arch == 'ppc64le' && 'release-no-lto' || 'release' }}
      - name: "Upload binary"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: artifacts-${{ matrix.platform.target }}
          path: |
            *.tar.gz
            *.sha256

      # uv-build
      - name: "Build wheels"
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          maturin-version: v1.13.1
          target: ${{ matrix.platform.target }}
          manylinux: musllinux_1_1
          args: --profile minimal-size --locked ${{ matrix.platform.arch == 'aarch64' && '--compatibility 2_17' || ''}} --out crates/uv-build/dist -m crates/uv-build/Cargo.toml --compatibility pypi
          docker-options: -e CARGO ${{ matrix.platform.maturin_docker_options }}
          rust-toolchain: ${{ matrix.platform.toolchain || null }}
          before-script-linux: |
            scripts/install-cargo-extensions.sh
        env:
          CARGO: ${{ github.workspace }}/scripts/cargo.sh
      # TODO(zanieb): Find an alternative for this action; it uses EOL Node 20
      - uses: uraimo/run-on-arch-action@f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9 # v3.1.0
        name: "Test wheel"
        with:
          arch: ${{ matrix.platform.arch }}
          distro: alpine_latest
          install: |
            apk add python3
          run: |
            python -m venv .venv
            .venv/bin/pip install ${PACKAGE_NAME}-build --no-index --find-links crates/uv-build/dist --force-reinstall
            .venv/bin/${MODULE_NAME}-build --help
            # TODO(konsti): Enable this test on all platforms, currently `find_uv_bin` is failing to discover uv here.
            # .venv/bin/python -m ${MODULE_NAME}_build --help
          env: |
            PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
            MODULE_NAME: ${{ env.MODULE_NAME }}
      # TODO(zanieb): Find an alternative for this action; it uses EOL Node 20
      - uses: uraimo/run-on-arch-action@f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9 # v3.1.0
        name: "Test wheel (manylinux)"
        if: matrix.platform.arch == 'aarch64'
        with:
          arch: aarch64
          distro: ubuntu20.04
          install: |
            apt-get update
            apt-get install -y --no-install-recommends python3 python3-pip python-is-python3
            pip3 install -U pip
          run: |
            pip install ${PACKAGE_NAME}-build --no-index --find-links crates/uv-build/dist --force-reinstall
            ${MODULE_NAME}-build --help
            # TODO(konsti): Enable this test on all platforms, currently `find_uv_bin` is failing to discover uv here.
            # python -m ${MODULE_NAME}_build --help
          env: |
            PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
            MODULE_NAME: ${{ env.MODULE_NAME }}
      - name: "Upload wheels"
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wheels_uv_build-${{ matrix.platform.target }}
          path: crates/uv-build/dist

  check-wheels:
    name: "Check wheel contents"
    runs-on: ubuntu-slim
    needs:
      - macos-x86_64
      - macos-aarch64
      - windows
      - linux
      - linux-arm
      - linux-s390x
      - linux-powerpc
      - linux-riscv64
      - musllinux
      - musllinux-cross
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
      - name: "Install uv"
        uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
      - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
        with:
          pattern: wheels_*-*
          path: wheels
          merge-multiple: true
      - name: "Check wheel contents"
        run: uv run --no-project scripts/check_uv_wheel_contents.py wheels/*
