Skip to content

Commit 22aa155

Browse files
Add musl build action
1 parent 9ef71de commit 22aa155

File tree

4 files changed

+73
-68
lines changed

4 files changed

+73
-68
lines changed

.github/workflows/build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,41 @@ jobs:
4141
- name: Run Gradle Build
4242
run: ./gradlew build -Ptarget=${{ matrix.target }}
4343

44+
linux-musl:
45+
strategy:
46+
matrix:
47+
include:
48+
- target: x86_64-unknown-linux-musl
49+
arch: x86_64
50+
- target: aarch64-unknown-linux-musl
51+
arch: aarch64
52+
53+
name: Build ${{ matrix.target }}
54+
runs-on: ubuntu-latest
55+
container:
56+
image: clux/muslrust:stable
57+
steps:
58+
- name: Checkout sources
59+
uses: taiki-e/checkout-action@v1
60+
- name: Install Essentials
61+
run: |
62+
apt-get update -y
63+
apt-get upgrade -y
64+
apt-get install -y gcc wget curl openjdk-17-jdk-headless
65+
- name: Install Rust toolchain
66+
run: |
67+
rustup target add x86_64-unknown-linux-musl ${{ matrix.target }}
68+
- name: Install linker dependencies
69+
run: |
70+
mkdir -p /opt/musl
71+
wget -4cO- https://musl.cc/${{ matrix.arch }}-linux-musl-cross.tgz | tar xz -C /opt/musl
72+
export PATH="/opt/musl/${{ matrix.arch }}-linux-musl-cross/bin:$PATH"
73+
- name: Run Gradle Build
74+
env:
75+
RUSTFLAGS: "-C target-feature=-crt-static -C link-args=-static-libgcc"
76+
run: |
77+
./gradlew build -Ptarget=${{ matrix.target }}
78+
4479
windows:
4580
strategy:
4681
matrix:

.github/workflows/musl.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,41 @@ jobs:
5050
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
5151
run: ./gradlew native:publish native:jreleaserRelease -Ptarget=${{ matrix.target }}
5252

53+
linux-musl:
54+
strategy:
55+
matrix:
56+
include:
57+
- target: x86_64-unknown-linux-musl
58+
arch: x86_64
59+
- target: aarch64-unknown-linux-musl
60+
arch: aarch64
61+
62+
name: Publish ${{ matrix.target }}
63+
environment: MavenRelease
64+
runs-on: ubuntu-latest
65+
container:
66+
image: ghcr.io/blackdex/rust-musl:${{ matrix.arch }}-musl-stable
67+
steps:
68+
- name: Checkout sources
69+
uses: taiki-e/checkout-action@v1
70+
- name: Install Essentials
71+
run: |
72+
apt-get update -y
73+
apt-get install -y openjdk-17-jdk-headless
74+
- name: Install Rust toolchain
75+
uses: dtolnay/rust-toolchain@stable
76+
with:
77+
toolchain: stable
78+
target: x86_64-unknown-linux-musl ${{ matrix.target }} # requires native target installed to build proc-macros2
79+
- name: Build and Publish
80+
env:
81+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }}
82+
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.MAVENCENTRAL_TOKEN }}
83+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
84+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
85+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
86+
run: ./gradlew native:publish native:jreleaserRelease -Ptarget=${{ matrix.target }}
87+
5388
windows:
5489
strategy:
5590
matrix:
@@ -85,6 +120,7 @@ jobs:
85120

86121
macos:
87122
name: Build macOS universal binary
123+
environment: MavenRelease
88124
runs-on: macos-14
89125
steps:
90126
- name: Checkout sources

native/.cargo/config.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,8 @@ linker = "arm-linux-gnueabihf-gcc"
66

77
[target.x86_64-unknown-linux-musl]
88
rustflags = ["-C", "target-feature=-crt-static", "-C", "link-args=-static-libgcc"]
9-
linker = "/root/musl/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc"
9+
linker = "x86_64-linux-musl-gcc"
1010

1111
[target.aarch64-unknown-linux-musl]
1212
rustflags = ["-C", "target-feature=-crt-static", "-C", "link-args=-static-libgcc"]
13-
linker = "/root/musl/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc"
14-
15-
# [target.i686-unknown-linux-musl]
16-
# rustflags = ["-C", "target-feature=-crt-static"]
17-
# [target.armv7-unknown-linux-musleabihf]
18-
# rustflags = ["-C", "target-feature=-crt-static"]
19-
# linker = "arm-linux-gnueabihf-gcc"
13+
linker = "aarch64-linux-musl-gcc"

0 commit comments

Comments
 (0)