Skip to content

Commit 4128531

Browse files
committed
adapt changes on zstd.yml to opus.yml
1 parent 0b12965 commit 4128531

File tree

1 file changed

+87
-14
lines changed

1 file changed

+87
-14
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

0 commit comments

Comments
 (0)