Update Sodium #104
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Sodium | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
paths: | |
- '.github/workflows/sodium.yml' | |
- '.github/scripts/package-sodium.sh' | |
# Once every 2 months | |
schedule: | |
- cron: '0 0 1 */2 *' | |
permissions: | |
contents: write | |
jobs: | |
build: | |
name: Build Sodium for ${{ matrix.config.rid }} | |
runs-on: ${{ matrix.config.os }} | |
outputs: | |
version: ${{ steps.build.outputs.version }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
os: ubuntu-latest, | |
command: "./dist-build/android-armv8-a.sh", | |
output-file: "libsodium-android-armv8-a+crypto/lib/libsodium.so", | |
file: "libsodium.so", | |
rid: "android-arm64", | |
} | |
- { | |
os: ubuntu-latest, | |
command: "zig build -Dshared=true -Doptimize=ReleaseFast -Dtarget=x86_64-linux-gnu", | |
output-file: "zig-out/lib/libsodium.so", | |
file: "libsodium.so", | |
rid: "linux-x64", | |
} | |
- { | |
os: ubuntu-latest, | |
command: "zig build -Dshared=true -Doptimize=ReleaseFast -Dtarget=x86_64-linux-musl", | |
output-file: "zig-out/lib/libsodium.so", | |
file: "libsodium.so", | |
rid: "linux-musl-x64", | |
} | |
- { | |
os: ubuntu-latest, | |
command: "zig build -Dshared=true -Doptimize=ReleaseFast -Dtarget=aarch64-linux-gnu", | |
output-file: "zig-out/lib/libsodium.so", | |
file: "libsodium.so", | |
rid: "linux-arm64", | |
} | |
- { | |
os: ubuntu-latest, | |
command: "zig build -Dshared=true -Doptimize=ReleaseFast -Dtarget=aarch64-linux-musl", | |
output-file: "zig-out/lib/libsodium.so", | |
file: "libsodium.so", | |
rid: "linux-musl-arm64", | |
} | |
- { | |
os: macos-latest, | |
command: "zig build -Dshared=true -Doptimize=ReleaseFast -Dtarget=x86_64-macos", | |
output-file: "zig-out/lib/libsodium.dylib", | |
file: "libsodium.dylib", | |
rid: "osx-x64", | |
} | |
- { | |
os: macos-latest, | |
command: "zig build -Dshared=true -Doptimize=ReleaseFast -Dtarget=aarch64-macos", | |
output-file: "zig-out/lib/libsodium.dylib", | |
file: "libsodium.dylib", | |
rid: "osx-arm64", | |
} | |
- { | |
os: macos-latest, | |
command: "bash ../../.github/scripts/apple-xcframework.sh", | |
output-file: "libsodium-apple/ios/lib/libsodium.dylib", | |
file: "libsodium.dylib", | |
rid: "ios-arm64", | |
} | |
- { | |
os: ubuntu-latest, | |
command: "zig build -Dshared=true -Doptimize=ReleaseFast -Dtarget=x86-windows", | |
output-file: "zig-out/lib/libsodium.dll", | |
file: "sodium.dll", | |
rid: "win-x86", | |
arch: "x86" | |
} | |
- { | |
os: ubuntu-latest, | |
command: "zig build -Dshared=true -Doptimize=ReleaseFast -Dtarget=x86_64-windows", | |
output-file: "zig-out/lib/libsodium.dll", | |
file: "sodium.dll", | |
rid: "win-x64", | |
arch: "x64" | |
} | |
- { | |
os: ubuntu-latest, | |
command: "zig build -Dshared=true -Doptimize=ReleaseFast -Dtarget=aarch64-windows", | |
output-file: "zig-out/lib/libsodium.dll", | |
file: "sodium.dll", | |
rid: "win-arm64", | |
arch: "arm64" | |
} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Setup Zig | |
uses: goto-bus-stop/setup-zig@v2 | |
if: contains(matrix.config.command, 'zig') | |
with: | |
version: 0.12.0 | |
- name: Set up JDK 17 | |
if: contains(matrix.config.rid, 'android') | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Setup Android SDK | |
if: contains(matrix.config.rid, 'android') | |
uses: android-actions/setup-android@v3 | |
- name: "Build ${{ matrix.config.file }}" | |
id: build | |
shell: bash | |
run: | | |
export WORKSPACE='${{ github.workspace }}' | |
export COMMAND='${{ matrix.config.command }}' | |
export OUTPUT_FILE='${{ matrix.config.output-file }}' | |
export FILE='${{ matrix.config.file }}' | |
export RID='${{ matrix.config.rid }}' | |
export JOB_INDEX='${{ strategy.job-index }}' | |
bash '${{ github.workspace }}/.github/scripts/package-sodium.sh' | |
- name: "Update ${{ matrix.config.rid }}" | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: "libs/libsodium/" | |
default_author: github_actions | |
message: Update Sodium ${{ matrix.config.rid }} to ${{ steps.build.outputs.version }} | |
pull: "--rebase --autostash" | |
push: true | |
- name: "Upload Artifact" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sodium-${{ steps.build.outputs.version }}-${{ matrix.config.rid }} | |
path: libs/libsodium/${{ matrix.config.rid }}/native/${{ matrix.config.file }} | |
update-version: | |
name: Update .NET project version | |
needs: build | |
runs-on: ubuntu-latest | |
if: needs.build.outputs.version != '' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Update version | |
run: | | |
sed -i "s|<Version>.*</Version>|<Version>${{ needs.build.outputs.version }}</Version>|g" "${{ github.workspace }}/src/DSharpPlus.VoiceLink.Natives.Sodium/DSharpPlus.VoiceLink.Natives.Sodium.csproj" | |
shell: bash | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Push changes" | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: "src/DSharpPlus.VoiceLink.Natives.Sodium/DSharpPlus.VoiceLink.Natives.Sodium.csproj" | |
default_author: github_actions | |
message: Update Sodium version to ${{ needs.build.outputs.version }} | |
pull: "--rebase --autostash" | |
push: true |