From 57f45d86b1c95f8f8c31956309cdb2f5e5ea6dad Mon Sep 17 00:00:00 2001 From: Kira Sotnikov Date: Fri, 17 Jan 2025 00:26:29 +0300 Subject: [PATCH] Build static --- .github/workflows/rust.yml | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8476095..772dd65 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -24,20 +24,29 @@ jobs: default: true override: true - - name: Install protobuf-compiler - run: sudo apt-get install -y protobuf-compiler + - name: Install protobuf-compiler + run: sudo apt-get install -y protobuf-compiler - - name: Install musl-tools - run: sudo apt-get update && sudo apt-get install -y musl-tools + - name: Install musl-tools + run: sudo apt-get update && sudo apt-get install -y musl-tools + + - name: Link musl-g++ + run: sudo ln -sf "/usr/bin/musl-gcc" "/usr/bin/musl-g++" + + - name: Add musl target + run: rustup target add x86_64-unknown-linux-musl + + - name: Set environment variables for musl + run: | + echo "export CC=musl-gcc" >> $GITHUB_ENV + echo "export CXX=musl-g++" >> $GITHUB_ENV + + - name: Build statically linked binary + env: + CC: musl-gcc + CXX: musl-g++ + run: cargo build --release --no-default-features --features agent --target x86_64-unknown-linux-musl - - name: Link g++ musl - run: sudo ln -s "/usr/bin/g++" "/usr/bin/musl-g++" - - - name: Add musl target - run: rustup target add x86_64-unknown-linux-musl - - - name: Build statically linked binary - run: cargo build --release --target x86_64-unknown-linux-musl build-api: runs-on: ubuntu-latest @@ -54,5 +63,5 @@ jobs: override: true - name: Build - run: cargo build --bin api --no-default-features --features api + run: cargo build --release --bin api --no-default-features --features api