-
Notifications
You must be signed in to change notification settings - Fork 1
202 lines (181 loc) · 6.33 KB
/
opus.yml
File metadata and controls
202 lines (181 loc) · 6.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Build opus
on:
workflow_dispatch:
push:
branches:
- master
paths:
- '.github/workflows/opus.yml'
env:
COMMON_CMAKE_FLAGS: "-DOPUS_BUILD_SHARED_LIBRARY=ON -DCMAKE_BUILD_TYPE=Release"
jobs:
build:
name: Build opus
runs-on: ${{ matrix.os }}
outputs:
version: ${{ steps.print-version.outputs.version }}
strategy:
fail-fast: false # Run the other two OSs even if one fails
matrix:
os: [ windows-latest, ubuntu-latest, macos-latest ]
steps:
- name: Clone opus repo
uses: actions/checkout@v4.2.2
with:
repository: DSharpPlus/opus
submodules: recursive
- name: Checkout latest Tag
id: print-version
shell: bash
run: |
git fetch --tags
LATEST_TAG=$(git tag | grep -E ^v[0-9]+.[0-9]+.[0-9]+$ | tail -1)
git checkout "$LATEST_TAG"
echo "version=$LATEST_TAG" >> $GITHUB_OUTPUT
- name: Build opus
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
for arch in x64 ARM64; do # We dont want Win32
mkdir -p output/$arch
mkdir build-$arch
cd build-$arch
cmake $COMMON_CMAKE_FLAGS -A $arch ..
cmake --build . -j 4 --config Release
cp Release/opus.dll ../output/$arch/libopus.dll
cd ..
done
elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
for arch in x64 ARM64; do
mkdir -p output/$arch
mkdir build-$arch
cd build-$arch
if [[ "$arch" == "ARM64" ]]; then
sudo apt update
sudo apt install cmake gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
cmake $COMMON_CMAKE_FLAGS -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ ..
else
cmake $COMMON_CMAKE_FLAGS ..
fi
cmake --build . -j 4
cp libopus.so ../output/$arch/libopus.so
cd ..
done
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
mkdir build output
cd build
cmake $COMMON_CMAKE_FLAGS "-DCMAKE_OSX_ARCHITECTURES=arm64;arm64e;x86_64;x86_64h" ..
cmake --build . -j 4 --config Release
cp libopus.dylib ../output/libopus.dylib
cd ..
fi
- name: Publish Artifacts
uses: actions/upload-artifact@v4.4.3
with:
name: opus-${{ matrix.os }}
path: output
compression-level: 9 # Prefer smaller downloads over a shorter workflow runtime
build-musl:
name: Build opus (alpine-musl)
runs-on: ubuntu-latest
# We sadly cant use a matrix to run x64 and ARM64, because it would give use 2 artifacts
steps:
- name: Clone opus repo
uses: actions/checkout@v4.2.2
with:
repository: DSharpPlus/opus
submodules: recursive
- name: Checkout latest Tag
shell: bash
run: |
git fetch --tags
LATEST_TAG=$(git tag | grep -E ^v[0-9]+.[0-9]+.[0-9]+$ | tail -1)
git checkout "$LATEST_TAG"
- name: Setup Alpine Linux for x64
uses: jirutka/setup-alpine@v1
with:
packages: >
build-base
cmake
git
make
gcc
g++
- name: Build opus for x64 (musl)
shell: alpine.sh {0}
run: |
mkdir -p output/x64
mkdir build-x64
cd build-x64
cmake $COMMON_CMAKE_FLAGS ..
cmake --build . -j 4
cp libopus.so ../output/x64/libopus.musl.so
cd ..
- name: Setup Alpine Linux for ARM64
uses: jirutka/setup-alpine@v1
with:
arch: aarch64
packages: >
build-base
cmake
git
make
gcc
g++
- name: Build opus for ARM64 (musl)
shell: alpine.sh {0}
run: |
mkdir -p output/ARM64
mkdir build-ARM64
cd build-ARM64
cmake $COMMON_CMAKE_FLAGS ..
cmake --build . -j 4
cp libopus.so ../output/ARM64/libopus.musl.so
cd ..
- name: Publish Artifacts
uses: actions/upload-artifact@v4.4.3
with:
name: opus-alpine-latest
path: output
compression-level: 9 # Prefer smaller downloads over a shorter workflow runtime
publish-nuget:
needs: [build, build-musl]
runs-on: ubuntu-latest
steps:
- name: Checkout CSPROJ files
uses: actions/checkout@v4.2.2
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: temp
pattern: opus-*
merge-multiple: true
- name: Move Artifacts
run: |
mkdir -p lib/opus/win-x64/native
mkdir -p lib/opus/linux-x64/native
mkdir -p lib/opus/win-arm64/native
mkdir -p lib/opus/linux-arm64/native
mkdir -p lib/opus/osx/native
mkdir -p lib/opus/linux-musl-x64/native
mkdir -p lib/opus/linux-musl-arm64/native
cp temp/x64/libopus.dll lib/opus/win-x64/native/opus.dll
cp temp/x64/libopus.so lib/opus/linux-x64/native/libopus.so
cp temp/ARM64/libopus.dll lib/opus/win-arm64/native/opus.dll
cp temp/ARM64/libopus.so lib/opus/linux-arm64/native/libopus.so
cp temp/libopus.dylib lib/opus/osx/native/libopus.dylib
cp temp/x64/libopus.musl.so lib/opus/linux-musl-x64/native/libopus.so
cp temp/ARM64/libopus.musl.so lib/opus/linux-musl-arm64/native/libopus.so
- name: Pack DSharpPlus.Natives.Opus
shell: bash
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
VERSION: ${{ needs.build.outputs.version }}
run: |
VERSION="${VERSION:1}"
dotnet pack ./build/DSharpPlus.Natives.Opus.csproj -c Release -p:Version="$VERSION.${{ github.run_number }}"
dotnet nuget push "artifacts/**" --skip-duplicate -k "$NUGET_API_KEY" -s https://api.nuget.org/v3/index.json