Skip to content

Try use an env var

Try use an env var #41

Workflow file for this run

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,
target: "aarch64-linux-android",
output-file: "libsodium.so",
file: "libsodium.so",
rid: "android-arm64",
}
- {
name: "Linux x64 (glibc)",
os: ubuntu-latest,
target: "x86_64-linux-gnu",
output-file: "libsodium.so",
file: "libsodium.so",
rid: "linux-x64",
}
- {
name: "Linux x64 (musl)",
os: ubuntu-latest,
target: "x86_64-linux-musl",
output-file: "libsodium.so",
file: "libsodium.so",
rid: "linux-x64-musl",
}
- {
name: "Linux Arm64 (glibc)",
os: ubuntu-latest,
target: "aarch64-linux-gnu",
output-file: "libsodium.so",
file: "libsodium.so",
rid: "linux-arm64",
}
- {
name: "Linux Arm64 (musl)",
os: ubuntu-latest,
target: "aarch64-linux-musl",
output-file: "libsodium.so",
file: "libsodium.so",
rid: "linux-arm64-musl",
}
- {
name: "MacOS x64",
os: macos-latest,
target: "x86_64-macos",
output-file: "libsodium.dylib",
file: "libsodium.dylib",
rid: "osx-x64",
}
- {
name: "iOS",
os: macos-latest,
target: "aarch64-ios",
output-file: "libsodium.dylib",
file: "libsodium.dylib",
rid: "ios-arm64",
}
- {
name: "Windows x86",
os: windows-latest,
target: "x86-windows-gnu",
output-file: "libsodium.dll",
file: "sodium.dll",
rid: "win-x86",
arch: "x86"
}
- {
name: "Windows x64",
os: windows-latest,
target: "x86_64-windows-gnu",
output-file: "libsodium.dll",
file: "sodium.dll",
rid: "win-x64",
arch: "x64"
}
- {
name: "Windows Arm64",
os: windows-latest,
target: "aarch64-windows-gnu",
output-file: "libsodium.dll",
file: "sodium.dll",
rid: "win-arm64",
arch: "arm64"
}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout Sodium
uses: actions/checkout@v4
with:
repository: jedisct1/libsodium
path: libs/sodium
fetch-tags: true
ref: fb4533b0a941b3a5b1db5687d1b008a5853d1f29
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.11.0
cache: false
- name: Set up MSBuild
if: contains(matrix.config.rid, 'win')
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: ${{ matrix.config.arch }}
- 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: Workaround for iOS
if: contains(matrix.config.rid, 'ios')
shell: bash
run: |
SDK_IPHONE_PATH="$(xcrun --show-sdk-path --sdk iphoneos)"
zig libc > libc.txt
brew install gnu-sed
gsed -i "s|include_dir=|include_dir=$SDK_IPHONE_PATH|" libc.txt
gsed -i "s|sys_include_dir=|sys_include_dir=$SDK_IPHONE_PATH|" libc.txt
echo "ZIG_LIBC=$(pwd)/libc.txt" >> $GITHUB_ENV
cat libc.txt
- name: Build on ${{ matrix.config.name }}
shell: bash
run: |
cd libs/sodium
zig build -Dshared=true -Doptimize=ReleaseFast -Dtarget=${{ matrix.config.target }}
mkdir -p "${{ github.workspace }}/libs/libsodium/${{ matrix.config.rid }}/native"
rm -f "${{ github.workspace }}/libs/libsodium/${{ matrix.config.rid }}/native/${{ matrix.config.file }}"
mv zig-out/lib/${{ matrix.config.output-file }} "${{ github.workspace }}/libs/libsodium/${{ matrix.config.rid }}/native/${{ matrix.config.file }}"
- 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