Skip to content

Commit 4a234f3

Browse files
authored
feat: use musl binary (#10)
1 parent 4acb4dc commit 4a234f3

1 file changed

Lines changed: 22 additions & 18 deletions

File tree

.github/workflows/release.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ jobs:
3636
matrix:
3737
include:
3838
- os: ubuntu-latest
39-
target: x86_64-unknown-linux-gnu
39+
target: x86_64-unknown-linux-musl
4040
arch_name: linux_amd64
4141
ext: tar.gz
4242
- os: ubuntu-latest
43-
target: aarch64-unknown-linux-gnu
43+
target: aarch64-unknown-linux-musl
4444
arch_name: linux_arm64
4545
ext: tar.gz
4646
- os: macos-latest
@@ -67,29 +67,33 @@ jobs:
6767
with:
6868
targets: ${{ matrix.target }}
6969

70-
- name: Install aarch64 linux toolchain
71-
if: matrix.target == 'aarch64-unknown-linux-gnu'
72-
run: |
73-
sudo apt-get update
74-
sudo apt-get install -y gcc-aarch64-linux-gnu
70+
- name: Install cross
71+
if: runner.os == 'Linux'
72+
uses: taiki-e/install-action@v2
73+
with:
74+
tool: cross
7575

76-
- name: Configure aarch64 linux linker
77-
if: matrix.target == 'aarch64-unknown-linux-gnu'
76+
- name: Build release (Linux musl)
77+
if: runner.os == 'Linux'
7878
run: |
79-
mkdir -p .cargo
80-
cat > .cargo/config.toml <<'EOF'
81-
[target.aarch64-unknown-linux-gnu]
82-
linker = "aarch64-linux-gnu-gcc"
83-
ar = "aarch64-linux-gnu-ar"
84-
EOF
85-
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
86-
echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar" >> "$GITHUB_ENV"
87-
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
79+
cross build --release --locked --target ${{ matrix.target }}
8880
8981
- name: Build release
82+
if: runner.os != 'Linux'
9083
run: |
9184
cargo build --release --locked --target ${{ matrix.target }}
9285
86+
- name: Verify Linux binary is fully static
87+
if: runner.os == 'Linux'
88+
shell: bash
89+
run: |
90+
set -euxo pipefail
91+
BIN="target/${{ matrix.target }}/release/sshpod"
92+
readelf -d "$BIN" > dynamic-deps.txt
93+
! grep -F "Shared library:" dynamic-deps.txt
94+
readelf -l "$BIN" > program-headers.txt
95+
! grep -F "Requesting program interpreter" program-headers.txt
96+
9397
- name: Verify dynamic dependencies (unix)
9498
if: runner.os != 'Windows'
9599
shell: bash

0 commit comments

Comments
 (0)