-
Notifications
You must be signed in to change notification settings - Fork 1
232 lines (207 loc) · 7.89 KB
/
sodium.yml
File metadata and controls
232 lines (207 loc) · 7.89 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: Build sodium
on:
workflow_dispatch:
push:
branches:
- master
paths:
- '.github/workflows/sodium.yml'
jobs:
build:
name: Build sodium
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 sodium repo
uses: actions/checkout@v4.2.2
with:
repository: jedisct1/libsodium
submodules: recursive
# - name: Checkout latest Tag
# id: print-version
# shell: bash
# run: |
# git fetch --tags
# LATEST_TAG=$(git tag --sort=-v:refname | head -1)
# git checkout "$LATEST_TAG"
# VERSION="${LATEST_TAG%-RELEASE}"
# VERSION="${VERSION%-FINAL}"
# echo "version=$VERSION" >> $GITHUB_OUTPUT
# 1.0.21 is broken, there is no 1.0.22 (yet), main dev says 'just clone stable': https://github.com/jedisct1/libsodium/issues/1509 and https://github.com/jedisct1/libsodium/issues/1502
- name: Checkout latest Tag
id: print-version
shell: bash
run: |
git fetch
git checkout stable
echo "version=1.0.21" >> $GITHUB_OUTPUT
- name: Install Visual Studio 2022 Build Tools
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
choco install visualstudio2022buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --includeRecommended --includeOptional"
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
if: matrix.os == 'windows-latest'
- name: Build sodium on Windows
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
foreach ($arch in "x64", "ARM64") {
New-Item -ItemType Directory -Name output/$arch
msbuild builds/msvc/vs2022/libsodium.sln /p:Configuration=DynRelease /p:Platform=$arch /t:Clean,Build # Clean between builds
cp bin/$arch/Release/v143/dynamic/libsodium.dll output/$arch/libsodium.dll # TODO: Figure out if we can detect the version part (v143) when it changes
}
- name: Build sodium
if: matrix.os != 'windows-latest'
shell: bash
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
for arch in x64 ARM64; do
mkdir -p output/$arch
if [[ "$arch" == "ARM64" ]]; then
sudo apt update
sudo apt install cmake gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
./configure --enable-static=off --host=aarch64-linux-gnu
else
./configure --enable-static=off --host=x86_64-linux-gnu
fi
make -j4
cp src/libsodium/.libs/libsodium.so output/$arch/libsodium.so
make clean # Clean between builds
done
else
for arch in x64 ARM64; do
mkdir -p output/$arch
if [[ "$arch" == "ARM64" ]]; then
./configure --enable-static=off --host=arm-apple-darwin
else
./configure --enable-static=off --host=x86_64-apple-darwin
fi
make -j4
cp src/libsodium/.libs/libsodium.dylib output/$arch/libsodium.dylib
make clean # Clean between builds
done
fi
- name: Publish Artifacts
uses: actions/upload-artifact@v4.4.3
with:
name: sodium-${{ matrix.os }}
path: output
compression-level: 9 # Prefer smaller downloads over a shorter workflow runtime
build-musl:
name: Build sodium (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 sodium repo
uses: actions/checkout@v4.2.2
with:
repository: jedisct1/libsodium
submodules: recursive
# - name: Checkout latest Tag
# shell: bash
# run: |
# git fetch --tags
# LATEST_TAG=$(git tag --sort=-v:refname | head -1)
# git checkout "$LATEST_TAG"
# VERSION="${LATEST_TAG%-RELEASE}"
# VERSION="${VERSION%-FINAL}"
# echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Checkout latest Tag
id: print-version
shell: bash
run: |
git fetch
git checkout stable
echo "version=1.0.21" >> $GITHUB_OUTPUT
- name: Setup Alpine Linux for x64
uses: jirutka/setup-alpine@v1
with:
packages: >
build-base
cmake
git
make
gcc
g++
- name: Build sodium for x64 (musl)
shell: alpine.sh {0}
run: |
mkdir -p output/x64
./configure --enable-static=off
make -j4
cp src/libsodium/.libs/libsodium.so output/x64/libsodium.musl.so
make clean # Clean between builds
- name: Setup Alpine Linux for ARM64
uses: jirutka/setup-alpine@v1
with:
arch: aarch64
packages: >
build-base
cmake
git
make
gcc
g++
- name: Build sodium for ARM64 (musl)
shell: alpine.sh {0}
run: |
mkdir -p output/ARM64
./configure --enable-static=off
make -j4
cp src/libsodium/.libs/libsodium.so output/ARM64/libsodium.musl.so
- name: Publish Artifacts
uses: actions/upload-artifact@v4.4.3
with:
name: sodium-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: sodium-*
merge-multiple: true
- name: Move Artifacts
run: |
mkdir -p lib/sodium/win-x64/native
mkdir -p lib/sodium/linux-x64/native
mkdir -p lib/sodium/osx-x64/native
mkdir -p lib/sodium/win-arm64/native
mkdir -p lib/sodium/linux-arm64/native
mkdir -p lib/sodium/osx-arm64/native
mkdir -p lib/sodium/linux-musl-x64/native
mkdir -p lib/sodium/linux-musl-arm64/native
cp temp/x64/libsodium.dll lib/sodium/win-x64/native/libsodium.dll
cp temp/x64/libsodium.so lib/sodium/linux-x64/native/libsodium.so
cp temp/x64/libsodium.dylib lib/sodium/osx-x64/native/libsodium.dylib
cp temp/ARM64/libsodium.dll lib/sodium/win-arm64/native/libsodium.dll
cp temp/ARM64/libsodium.so lib/sodium/linux-arm64/native/libsodium.so
cp temp/ARM64/libsodium.dylib lib/sodium/osx-arm64/native/libsodium.dylib
cp temp/x64/libsodium.musl.so lib/sodium/linux-musl-x64/native/libsodium.so
cp temp/ARM64/libsodium.musl.so lib/sodium/linux-musl-arm64/native/libsodium.so
- name: Pack DSharpPlus.Natives.Sodium
shell: bash
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
VERSION: ${{ needs.build.outputs.version }}
run: |
VERSION="${VERSION%%-*}"
dotnet pack ./build/DSharpPlus.Natives.Sodium.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