Round 3 #69
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: | |
release: | |
types: | |
- published | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
paths: | |
- '.github/workflows/sodium.yml' | |
permissions: | |
contents: write | |
jobs: | |
build: | |
name: Build Sodium for ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: "Android Arm64", | |
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", | |
} | |
- { | |
name: "Linux x64 (glibc)", | |
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", | |
} | |
- { | |
name: "Linux x64 (musl)", | |
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-x64-musl", | |
} | |
- { | |
name: "Linux Arm64 (glibc)", | |
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", | |
} | |
- { | |
name: "Linux Arm64 (musl)", | |
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-arm64-musl", | |
} | |
- { | |
name: "MacOS x64", | |
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", | |
} | |
- { | |
name: "MacOS Arm64", | |
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", | |
} | |
- { | |
name: "iOS Arm64", | |
os: macos-latest, | |
command: "export LIBSODIUM_SKIP_SIMULATORS=1; \ | |
bash -x dist-build/apple-xcframework.sh; \ | |
find .", | |
output-file: "zig-out/lib/libsodium.dylib", | |
file: "libsodium.dylib", | |
rid: "ios-arm64", | |
} | |
- { | |
name: "Windows x86", | |
os: ubuntu-latest, | |
command: "zig build -Dshared=true -Doptimize=ReleaseFast -Dtarget=x86-windows", | |
output-file: "zig-out/lib/sodium_shared.dll", | |
file: "sodium.dll", | |
rid: "win-x86", | |
arch: "x86" | |
} | |
- { | |
name: "Windows x64", | |
os: ubuntu-latest, | |
command: "zig build -Dshared=true -Doptimize=ReleaseFast -Dtarget=x86_64-windows", | |
output-file: "zig-out/lib/sodium_shared.dll", | |
file: "sodium.dll", | |
rid: "win-x64", | |
arch: "x64" | |
} | |
- { | |
name: "Windows Arm64", | |
os: ubuntu-latest, | |
command: "zig build -Dshared=true -Doptimize=ReleaseFast -Dtarget=aarch64-windows", | |
output-file: "zig-out/lib/sodium_shared.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.11.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 on ${{ matrix.config.name }} | |
shell: bash | |
continue-on-error: true | |
run: | | |
git clone https://github.com/jedisct1/libsodium.git libs/sodium | |
cd libs/sodium | |
git fetch --tags | |
SODIUM_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1)) | |
echo "SODIUM_VERSION=$SODIUM_VERSION" >> $GITHUB_ENV | |
git checkout $SODIUM_VERSION | |
${{ matrix.config.command }} | |
mkdir -p "${{ github.workspace }}/libs/libsodium/${{ matrix.config.rid }}/native" | |
rm -f "${{ github.workspace }}/libs/libsodium/${{ matrix.config.rid }}/native/${{ matrix.config.file }}" | |
mv ${{ matrix.config.output-file }} "${{ github.workspace }}/libs/libsodium/${{ matrix.config.rid }}/native/${{ matrix.config.file }}" | |
sleep $(( ${{ strategy.job-index }} * 2 )) | |
- name: "Update ${{ matrix.config.file }}" | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: "libs/libsodium/" | |
default_author: github_actions | |
message: Update ${{ matrix.config.file }} to ${{ env.SODIUM_VERSION }} | |
pull: '--rebase --autostash' | |
push: true |