Skip to content

Commit 0f80936

Browse files
Add musl build action (#15)
1 parent 9ef71de commit 0f80936

File tree

4 files changed

+80
-68
lines changed

4 files changed

+80
-68
lines changed

.github/workflows/build.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,42 @@ 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 musl-tools 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+
curl -L https://github.com/MinnDevelopment/musl-cross-mirror/releases/download/v0.0.1/${{ matrix.arch }}-linux-musl-cross.tgz | tar xz -C /opt/musl
72+
- name: Run Gradle Build
73+
env:
74+
RUSTFLAGS: "-C target-feature=-crt-static -C link-args=-static-libgcc"
75+
run: |
76+
export PATH="/opt/musl/${{ matrix.arch }}-linux-musl-cross/bin:$PATH"
77+
which ${{ matrix.arch }}-linux-musl-gcc
78+
./gradlew build -Ptarget=${{ matrix.target }}
79+
4480
windows:
4581
strategy:
4682
matrix:

.github/workflows/musl.yml

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

.github/workflows/publish.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,47 @@ 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: clux/muslrust: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 upgrade -y
74+
apt-get install -y gcc musl-tools curl openjdk-17-jdk-headless
75+
- name: Install Rust toolchain
76+
run: |
77+
rustup target add x86_64-unknown-linux-musl ${{ matrix.target }}
78+
- name: Install linker dependencies
79+
run: |
80+
mkdir -p /opt/musl
81+
curl -L https://github.com/MinnDevelopment/musl-cross-mirror/releases/download/v0.0.1/${{ matrix.arch }}-linux-musl-cross.tgz | tar xz -C /opt/musl
82+
- name: Build and Publish
83+
env:
84+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }}
85+
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.MAVENCENTRAL_TOKEN }}
86+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
87+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
88+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
89+
RUSTFLAGS: "-C target-feature=-crt-static -C link-args=-static-libgcc"
90+
run: |
91+
export PATH="/opt/musl/${{ matrix.arch }}-linux-musl-cross/bin:$PATH"
92+
./gradlew native:publish native:jreleaserRelease -Ptarget=${{ matrix.target }}
93+
5394
windows:
5495
strategy:
5596
matrix:
@@ -85,6 +126,7 @@ jobs:
85126

86127
macos:
87128
name: Build macOS universal binary
129+
environment: MavenRelease
88130
runs-on: macos-14
89131
steps:
90132
- 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)