From b06024c62adcb2a56492c133a04a8a2af06e0c89 Mon Sep 17 00:00:00 2001 From: Rushit Patel Date: Wed, 1 Jul 2026 18:46:44 -0400 Subject: [PATCH] feat: package fully static/portable binaries for Linux and Windows --- .cargo/config.toml | 2 ++ .github/workflows/release.yml | 20 ++++++++++++++------ .gitignore | 1 + scripts/install.sh | 6 +++--- 4 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..ac2b23f --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[target.x86_64-pc-windows-msvc] +rustflags = ["-C", "target-feature=+crt-static"] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e318f29..47a5261 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,8 +18,8 @@ # crate it just uploaded. # # Binary targets (CLI `tonin` and `tonin-proxy`, built per release): -# - x86_64-unknown-linux-gnu (Linux x86_64) -# - aarch64-unknown-linux-gnu (Linux ARM64, e.g. Graviton) +# - x86_64-unknown-linux-musl (Linux x86_64) +# - aarch64-unknown-linux-musl (Linux ARM64, e.g. Graviton) # - x86_64-apple-darwin (macOS Intel) # - aarch64-apple-darwin (macOS Apple Silicon) # - x86_64-pc-windows-msvc (Windows x86_64) @@ -183,10 +183,10 @@ jobs: fail-fast: false matrix: include: - - target: x86_64-unknown-linux-gnu + - target: x86_64-unknown-linux-musl os: ubuntu-latest archive: tar.gz - - target: aarch64-unknown-linux-gnu + - target: aarch64-unknown-linux-musl os: ubuntu-latest archive: tar.gz - target: x86_64-apple-darwin @@ -229,6 +229,10 @@ jobs: echo "skipped=false" >> "$GITHUB_OUTPUT" fi + - name: Install musl-tools + if: matrix.target == 'x86_64-unknown-linux-musl' && steps.check.outputs.skipped != 'true' + run: sudo apt-get update && sudo apt-get install -y musl-tools + - name: Install Rust 1.93 with target ${{ matrix.target }} if: steps.check.outputs.skipped != 'true' uses: dtolnay/rust-toolchain@stable @@ -274,10 +278,10 @@ jobs: fail-fast: false matrix: include: - - target: x86_64-unknown-linux-gnu + - target: x86_64-unknown-linux-musl os: ubuntu-latest archive: tar.gz - - target: aarch64-unknown-linux-gnu + - target: aarch64-unknown-linux-musl os: ubuntu-latest archive: tar.gz - target: x86_64-apple-darwin @@ -317,6 +321,10 @@ jobs: echo "skipped=false" >> "$GITHUB_OUTPUT" fi + - name: Install musl-tools + if: matrix.target == 'x86_64-unknown-linux-musl' && steps.check.outputs.skipped != 'true' + run: sudo apt-get update && sudo apt-get install -y musl-tools + - name: Install Rust 1.93 with target ${{ matrix.target }} if: steps.check.outputs.skipped != 'true' uses: dtolnay/rust-toolchain@stable diff --git a/.gitignore b/.gitignore index 5a938f9..6111f81 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ # Cargo. **/Cargo.lock.bak .cargo/ +!.cargo/config.toml # Incremental compilation / cache. **/*.rlib diff --git a/scripts/install.sh b/scripts/install.sh index d8eafe5..5cedc81 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -82,8 +82,8 @@ detect_target() { case "$os" in Linux) case "$arch" in - x86_64) echo "x86_64-unknown-linux-gnu" ;; - aarch64|arm64) echo "aarch64-unknown-linux-gnu" ;; + x86_64) echo "x86_64-unknown-linux-musl" ;; + aarch64|arm64) echo "aarch64-unknown-linux-musl" ;; *) err "Unsupported Linux architecture: $arch (pre-built binary not available; use 'cargo install tonin')" ;; esac ;; Darwin) @@ -143,7 +143,7 @@ install_binary() { local repo="$1" # e.g. Rushit/tonin local bin="$2" # e.g. tonin local version="$3" # e.g. v0.5.4 - local target="$4" # e.g. x86_64-unknown-linux-gnu + local target="$4" # e.g. x86_64-unknown-linux-musl local dest_dir="$5" # e.g. /usr/local/bin local dest="${dest_dir}/${bin}"