Skip to content

Commit 1af02a6

Browse files
Release: support for statically linked musl
1 parent c98959a commit 1af02a6

File tree

2 files changed

+81
-16
lines changed

2 files changed

+81
-16
lines changed

.github/workflows/release.yaml

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ jobs:
3838
- target: aarch64-unknown-linux-gnu
3939
os: ubuntu-24.04-arm
4040
target_rustflags: ''
41+
# Linux musl, x86-64 (static, for Alpine)
42+
- target: x86_64-unknown-linux-musl
43+
os: ubuntu-22.04
44+
target_rustflags: ''
45+
# Linux musl, aarch64 (static, for Alpine)
46+
- target: aarch64-unknown-linux-musl
47+
os: ubuntu-24.04-arm
48+
target_rustflags: ''
4149

4250
permissions:
4351
id-token: write
@@ -79,7 +87,7 @@ jobs:
7987

8088
- name: Build an rabbitmqadmin release archive on x86-64 Linux
8189
id: release-build-amd64-linux
82-
if: ${{ matrix.os == 'ubuntu-24.04' || matrix.os == 'ubuntu-22.04' }}
90+
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }}
8391
run: nu ./scripts/release-linux.nu
8492
env:
8593
OS: ${{ matrix.os }}
@@ -88,7 +96,7 @@ jobs:
8896
SRC: ${{ github.workspace }}
8997
- name: Store x86-64 Linux build artifact
9098
id: upload-amd64-linux-artifact
91-
if: ${{ matrix.os == 'ubuntu-24.04' || matrix.os == 'ubuntu-22.04' }}
99+
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }}
92100
uses: actions/upload-artifact@v4
93101
with:
94102
name: "rabbitmqadmin-${{ vars.NEXT_RELEASE_VERSION }}-${{ matrix.target }}"
@@ -97,7 +105,7 @@ jobs:
97105

98106
- name: Build an rabbitmqadmin release archive on aarch64 Linux
99107
id: release-build-aarch64-linux
100-
if: ${{ matrix.os == 'ubuntu-24.04-arm' }}
108+
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
101109
run: nu ./scripts/release-linux.nu
102110
env:
103111
OS: ${{ matrix.os }}
@@ -106,7 +114,43 @@ jobs:
106114
SRC: ${{ github.workspace }}
107115
- name: Store aarch64 Linux build artifact
108116
id: upload-aarch64-linux-artifact
109-
if: ${{ matrix.os == 'ubuntu-24.04-arm' }}
117+
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: "rabbitmqadmin-${{ vars.NEXT_RELEASE_VERSION }}-${{ matrix.target }}"
121+
path: "${{ github.workspace }}/target/${{ matrix.target }}/release/rabbitmqadmin-${{ vars.NEXT_RELEASE_VERSION }}-${{ matrix.target }}"
122+
retention-days: 2
123+
124+
- name: Build a static rabbitmqadmin release archive on x86-64 Linux (musl)
125+
id: release-build-amd64-linux-musl
126+
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
127+
run: nu ./scripts/release-linux.nu
128+
env:
129+
OS: ${{ matrix.os }}
130+
TARGET: ${{ matrix.target }}
131+
TARGET_RUSTFLAGS: ${{ matrix.target_rustflags }}
132+
SRC: ${{ github.workspace }}
133+
- name: Store x86-64 Linux musl build artifact
134+
id: upload-amd64-linux-musl-artifact
135+
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
136+
uses: actions/upload-artifact@v4
137+
with:
138+
name: "rabbitmqadmin-${{ vars.NEXT_RELEASE_VERSION }}-${{ matrix.target }}"
139+
path: "${{ github.workspace }}/target/${{ matrix.target }}/release/rabbitmqadmin-${{ vars.NEXT_RELEASE_VERSION }}-${{ matrix.target }}"
140+
retention-days: 2
141+
142+
- name: Build a static rabbitmqadmin release archive on aarch64 Linux (musl)
143+
id: release-build-aarch64-linux-musl
144+
if: ${{ matrix.target == 'aarch64-unknown-linux-musl' }}
145+
run: nu ./scripts/release-linux.nu
146+
env:
147+
OS: ${{ matrix.os }}
148+
TARGET: ${{ matrix.target }}
149+
TARGET_RUSTFLAGS: ${{ matrix.target_rustflags }}
150+
SRC: ${{ github.workspace }}
151+
- name: Store aarch64 Linux musl build artifact
152+
id: upload-aarch64-linux-musl-artifact
153+
if: ${{ matrix.target == 'aarch64-unknown-linux-musl' }}
110154
uses: actions/upload-artifact@v4
111155
with:
112156
name: "rabbitmqadmin-${{ vars.NEXT_RELEASE_VERSION }}-${{ matrix.target }}"
@@ -150,6 +194,16 @@ jobs:
150194
with:
151195
name: "rabbitmqadmin-${{ vars.NEXT_RELEASE_VERSION }}-aarch64-unknown-linux-gnu"
152196
path: ./artifacts
197+
- name: Fetch x86-64 Linux musl (static) archive
198+
uses: actions/download-artifact@v4
199+
with:
200+
name: "rabbitmqadmin-${{ vars.NEXT_RELEASE_VERSION }}-x86_64-unknown-linux-musl"
201+
path: ./artifacts
202+
- name: Fetch aarch64 Linux musl (static) archive
203+
uses: actions/download-artifact@v4
204+
with:
205+
name: "rabbitmqadmin-${{ vars.NEXT_RELEASE_VERSION }}-aarch64-unknown-linux-musl"
206+
path: ./artifacts
153207
- name: Fetch Windows archive
154208
uses: actions/download-artifact@v4
155209
with:

scripts/release-linux.nu

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,42 @@ rm -rf $release_dir
2020
mkdir $release_dir
2121

2222
print $'Building on Linux in ($src)...'
23-
build-with-cargo
2423

2524
#
2625
# Linux
2726
#
2827

29-
if $os in ['ubuntu', 'ubuntu-latest'] {
30-
print "Building on Ubuntu..."
31-
if $target == 'aarch64-unknown-linux-gnu' {
32-
sudo apt-get install -y gcc-aarch64-linux-gnu
28+
if ($os | str starts-with 'ubuntu') {
29+
print $"Building on Ubuntu \(($os)\)..."
30+
if $target == 'x86_64-unknown-linux-gnu' {
31+
build-with-cargo
32+
} else if $target == 'aarch64-unknown-linux-gnu' {
3333
build-with-cargo
34+
} else if $target == 'x86_64-unknown-linux-musl' {
35+
sudo apt-get update
36+
sudo apt-get install -y musl-tools
37+
build-static-with-cargo
38+
} else if $target == 'aarch64-unknown-linux-musl' {
39+
sudo apt-get update
40+
sudo apt-get install -y musl-tools
41+
build-static-with-cargo
3442
} else if $target == 'armv7-unknown-linux-gnueabihf' {
3543
sudo apt-get install pkg-config gcc-arm-linux-gnueabihf -y
36-
# $env.CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER = "arm-linux-gnueabihf-gcc"
3744
build-with-cargo
3845
} else {
39-
# musl-tools to fix 'Failed to find tool. Is `musl-gcc` installed?'
40-
sudo apt-get install musl-tools -y
4146
build-with-cargo
4247
}
4348
}
4449

45-
if $os in ['fedora', 'fedora-latest'] {
46-
print "Building on Fedora..."
50+
if ($os | str starts-with 'fedora') {
51+
print $"Building on Fedora \(($os)\)..."
4752
if $target == 'aarch64-unknown-linux-gnu' {
4853
sudo dnf install -y gcc-aarch64-linux-gnu
4954
build-with-cargo
5055
} else if $target == 'armv7-unknown-linux-gnueabihf' {
5156
sudo dnf install pkg-config gcc-arm-linux-gnueabihf -y
52-
# $env.CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER = 'arm-linux-gnueabihf-gcc'
57+
build-with-cargo
58+
} else {
5359
build-with-cargo
5460
}
5561
}
@@ -83,4 +89,9 @@ echo $'artifact=($artifact_filename)' | save --append $env.GITHUB_OUTPUT
8389

8490
def 'build-with-cargo' [] {
8591
cargo rustc --bin $binary --target $target --release
86-
}
92+
}
93+
94+
def 'build-static-with-cargo' [] {
95+
$env.RUSTFLAGS = '-C target-feature=+crt-static'
96+
cargo rustc --bin $binary --target $target --release
97+
}

0 commit comments

Comments
 (0)