Skip to content

Commit 3758ee4

Browse files
authored
Merge pull request #7 from AaronBeier/master
Add musl builds for zstd, opus and libsodium
2 parents 17bd180 + f5a0b7d commit 3758ee4

File tree

3 files changed

+261
-37
lines changed

3 files changed

+261
-37
lines changed

.github/workflows/opus.yml

Lines changed: 87 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
paths:
88
- '.github/workflows/opus.yml'
99

10+
env:
11+
COMMON_CMAKE_FLAGS: "-DOPUS_BUILD_SHARED_LIBRARY=ON -DCMAKE_BUILD_TYPE=Release"
12+
1013
jobs:
1114
build:
1215
name: Build opus
@@ -28,15 +31,12 @@ jobs:
2831
submodules: recursive
2932

3033
- name: Checkout latest Tag
31-
shell: bash
32-
run: git fetch --tags && git checkout "$(git describe --tags "$(git rev-list --tags --max-count=1)")"
33-
34-
- name: Print Version
35-
id: print-version
3634
shell: bash
3735
run: |
38-
git fetch --tags
39-
echo "version=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_OUTPUT
36+
git fetch --tags
37+
LATEST_TAG=$(git tag | grep -E ^v[0-9]+.[0-9]+.[0-9]+$ | tail -1)
38+
git checkout "$LATEST_TAG"
39+
echo "version=$LATEST_TAG" >> $GITHUB_OUTPUT
4040
4141
- name: Build opus
4242
shell: bash
@@ -46,9 +46,8 @@ jobs:
4646
mkdir -p output/$arch
4747
mkdir build-$arch
4848
cd build-$arch
49-
cmake -DOPUS_BUILD_SHARED_LIBRARY=ON -DCMAKE_BUILD_TYPE=Release -A $arch ..
49+
cmake $COMMON_CMAKE_FLAGS -A $arch ..
5050
cmake --build . -j 4 --config Release
51-
ls
5251
cp Release/opus.dll ../output/$arch/libopus.dll
5352
cd ..
5453
done
@@ -60,9 +59,9 @@ jobs:
6059
if [[ "$arch" == "ARM64" ]]; then
6160
sudo apt update
6261
sudo apt install cmake gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
63-
cmake -DOPUS_BUILD_SHARED_LIBRARY=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ ..
62+
cmake $COMMON_CMAKE_FLAGS -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ ..
6463
else
65-
cmake -DOPUS_BUILD_SHARED_LIBRARY=ON -DCMAKE_BUILD_TYPE=Release ..
64+
cmake $COMMON_CMAKE_FLAGS ..
6665
fi
6766
cmake --build . -j 4
6867
cp libopus.so ../output/$arch/libopus.so
@@ -71,7 +70,7 @@ jobs:
7170
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
7271
mkdir build output
7372
cd build
74-
cmake -DOPUS_BUILD_SHARED_LIBRARY=ON -DCMAKE_BUILD_TYPE=Release "-DCMAKE_OSX_ARCHITECTURES=arm64;arm64e;x86_64;x86_64h" ..
73+
cmake $COMMON_CMAKE_FLAGS "-DCMAKE_OSX_ARCHITECTURES=arm64;arm64e;x86_64;x86_64h" ..
7574
cmake --build . -j 4 --config Release
7675
cp libopus.dylib ../output/libopus.dylib
7776
cd ..
@@ -84,9 +83,79 @@ jobs:
8483
path: output
8584
compression-level: 9 # Prefer smaller downloads over a shorter workflow runtime
8685

87-
86+
build-musl:
87+
name: Build opus (alpine-musl)
88+
runs-on: ubuntu-latest
89+
90+
# We sadly cant use a matrix to run x64 and ARM64, because it would give use 2 artifacts
91+
steps:
92+
- name: Clone opus repo
93+
uses: actions/checkout@v4.2.2
94+
with:
95+
repository: xiph/opus
96+
submodules: recursive
97+
98+
- name: Checkout latest Tag
99+
shell: bash
100+
run: |
101+
git fetch --tags
102+
LATEST_TAG=$(git tag | grep -E ^v[0-9]+.[0-9]+.[0-9]+$ | tail -1)
103+
git checkout "$LATEST_TAG"
104+
105+
- name: Setup Alpine Linux for x64
106+
uses: jirutka/setup-alpine@v1
107+
with:
108+
packages: >
109+
build-base
110+
cmake
111+
git
112+
make
113+
gcc
114+
g++
115+
116+
- name: Build opus for x64 (musl)
117+
shell: alpine.sh {0}
118+
run: |
119+
mkdir -p output/x64
120+
mkdir build-x64
121+
cd build-x64
122+
cmake $COMMON_CMAKE_FLAGS ..
123+
cmake --build . -j 4
124+
cp libopus.so ../output/x64/libopus.musl.so
125+
cd ..
126+
127+
- name: Setup Alpine Linux for ARM64
128+
uses: jirutka/setup-alpine@v1
129+
with:
130+
arch: aarch64
131+
packages: >
132+
build-base
133+
cmake
134+
git
135+
make
136+
gcc
137+
g++
138+
139+
- name: Build opus for ARM64 (musl)
140+
shell: alpine.sh {0}
141+
run: |
142+
mkdir -p output/ARM64
143+
mkdir build-ARM64
144+
cd build-ARM64
145+
cmake $COMMON_CMAKE_FLAGS ..
146+
cmake --build . -j 4
147+
cp libopus.so ../output/ARM64/libopus.musl.so
148+
cd ..
149+
150+
- name: Publish Artifacts
151+
uses: actions/upload-artifact@v4.4.3
152+
with:
153+
name: opus-alpine-latest
154+
path: output
155+
compression-level: 9 # Prefer smaller downloads over a shorter workflow runtime
156+
88157
publish-nuget:
89-
needs: build
158+
needs: [build, build-musl]
90159
runs-on: ubuntu-latest
91160
steps:
92161
- name: Checkout CSPROJ files
@@ -111,11 +180,15 @@ jobs:
111180
mkdir -p lib/opus/win-arm64/native
112181
mkdir -p lib/opus/linux-arm64/native
113182
mkdir -p lib/opus/osx/native
183+
mkdir -p lib/opus/linux-musl-x64/native
184+
mkdir -p lib/opus/linux-musl-arm64/native
114185
cp temp/x64/libopus.dll lib/opus/win-x64/native/libopus.dll
115186
cp temp/x64/libopus.so lib/opus/linux-x64/native/libopus.so
116187
cp temp/ARM64/libopus.dll lib/opus/win-arm64/native/libopus.dll
117188
cp temp/ARM64/libopus.so lib/opus/linux-arm64/native/libopus.so
118189
cp temp/libopus.dylib lib/opus/osx/native/libopus.dylib
190+
cp temp/x64/libopus.musl.so lib/opus/linux-musl-x64/native/libopus.so
191+
cp temp/ARM64/libopus.musl.so lib/opus/linux-musl-arm64/native/libopus.so
119192
120193
- name: Pack DSharpPlus.Natives.Opus
121194
shell: bash

.github/workflows/sodium.yml

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ jobs:
2828
submodules: recursive
2929

3030
- name: Checkout latest Tag
31-
shell: bash
32-
run: git fetch --tags && git checkout "$(git describe --tags "$(git rev-list --tags --max-count=1)")"
33-
34-
- name: Print Version
35-
id: print-version
3631
shell: bash
3732
run: |
38-
git fetch --tags
39-
echo "version=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_OUTPUT
33+
git fetch --tags
34+
LATEST_TAG=$(git tag --sort=-v:refname | head -1)
35+
git checkout "$LATEST_TAG"
36+
VERSION="${LATEST_TAG%-RELEASE}"
37+
VERSION="${VERSION%-FINAL}"
38+
echo "version=$VERSION" >> $GITHUB_OUTPUT
4039
4140
- name: Install Visual Studio 2022 Build Tools
4241
if: matrix.os == 'windows-latest'
@@ -97,8 +96,77 @@ jobs:
9796
path: output
9897
compression-level: 9 # Prefer smaller downloads over a shorter workflow runtime
9998

99+
build-musl:
100+
name: Build sodium (alpine-musl)
101+
runs-on: ubuntu-latest
102+
103+
# We sadly cant use a matrix to run x64 and ARM64, because it would give use 2 artifacts
104+
steps:
105+
- name: Clone sodium repo
106+
uses: actions/checkout@v4.2.2
107+
with:
108+
repository: jedisct1/libsodium
109+
submodules: recursive
110+
111+
- name: Checkout latest Tag
112+
shell: bash
113+
run: |
114+
git fetch --tags
115+
LATEST_TAG=$(git tag --sort=-v:refname | head -1)
116+
git checkout "$LATEST_TAG"
117+
VERSION="${LATEST_TAG%-RELEASE}"
118+
VERSION="${VERSION%-FINAL}"
119+
echo "version=$VERSION" >> $GITHUB_OUTPUT
120+
121+
- name: Setup Alpine Linux for x64
122+
uses: jirutka/setup-alpine@v1
123+
with:
124+
packages: >
125+
build-base
126+
cmake
127+
git
128+
make
129+
gcc
130+
g++
131+
132+
- name: Build sodium for x64 (musl)
133+
shell: alpine.sh {0}
134+
run: |
135+
mkdir -p output/x64
136+
./configure --enable-static=off
137+
make -j4
138+
cp src/libsodium/.libs/libsodium.so output/x64/libsodium.musl.so
139+
make clean # Clean between builds
140+
141+
- name: Setup Alpine Linux for ARM64
142+
uses: jirutka/setup-alpine@v1
143+
with:
144+
arch: aarch64
145+
packages: >
146+
build-base
147+
cmake
148+
git
149+
make
150+
gcc
151+
g++
152+
153+
- name: Build sodium for ARM64 (musl)
154+
shell: alpine.sh {0}
155+
run: |
156+
mkdir -p output/ARM64
157+
./configure --enable-static=off
158+
make -j4
159+
cp src/libsodium/.libs/libsodium.so output/ARM64/libsodium.musl.so
160+
161+
- name: Publish Artifacts
162+
uses: actions/upload-artifact@v4.4.3
163+
with:
164+
name: sodium-alpine-latest
165+
path: output
166+
compression-level: 9 # Prefer smaller downloads over a shorter workflow runtime
167+
100168
publish-nuget:
101-
needs: build
169+
needs: [build, build-musl]
102170
runs-on: ubuntu-latest
103171
steps:
104172
- name: Checkout CSPROJ files
@@ -124,12 +192,16 @@ jobs:
124192
mkdir -p lib/sodium/win-arm64/native
125193
mkdir -p lib/sodium/linux-arm64/native
126194
mkdir -p lib/sodium/osx-arm64/native
195+
mkdir -p lib/sodium/linux-musl-x64/native
196+
mkdir -p lib/sodium/linux-musl-arm64/native
127197
cp temp/x64/libsodium.dll lib/sodium/win-x64/native/libsodium.dll
128198
cp temp/x64/libsodium.so lib/sodium/linux-x64/native/libsodium.so
129199
cp temp/x64/libsodium.dylib lib/sodium/osx-x64/native/libsodium.dylib
130200
cp temp/ARM64/libsodium.dll lib/sodium/win-arm64/native/libsodium.dll
131201
cp temp/ARM64/libsodium.so lib/sodium/linux-arm64/native/libsodium.so
132202
cp temp/ARM64/libsodium.dylib lib/sodium/osx-arm64/native/libsodium.dylib
203+
cp temp/x64/libsodium.musl.so lib/zstd/linux-musl-x64/native/libsodium.so
204+
cp temp/ARM64/libsodium.musl.so lib/zstd/linux-musl-arm64/native/libsodium.so
133205
134206
- name: Pack DSharpPlus.Natives.Sodium
135207
shell: bash

0 commit comments

Comments
 (0)