Compile native libsodium binaries #256
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: Compile native libsodium binaries | |
on: | |
workflow_dispatch: | |
inputs: | |
force-rebuild: | |
type: boolean | |
description: Force a rebuild | |
required: false | |
default: false | |
push: | |
branches: | |
- main | |
paths: | |
- packages/sodium_libs/libsodium_version.dart | |
- packages/sodium_libs/tool/libsodium/** | |
- .github/workflows/libsodium.yaml | |
schedule: | |
- cron: "47 2 * * 2" | |
jobs: | |
detect_modified: | |
name: Check if binaries need to be updated | |
runs-on: ubuntu-latest | |
outputs: | |
modified: ${{ steps.check.outputs.modified }} | |
version: ${{ steps.check.outputs.version }} | |
last-modified-content: ${{ steps.check.outputs.last-modified-content }} | |
steps: | |
- name: Install Flutter-SDK (stable) | |
uses: subosito/flutter-action@v2 | |
with: | |
cache: true | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install dart dependencies | |
run: dart pub get | |
working-directory: packages/sodium_libs | |
- id: check | |
name: Check if upstream stable archives have been update | |
run: dart run tool/libsodium/detect_modified.dart | |
working-directory: packages/sodium_libs | |
build: | |
name: Update binaries if required | |
needs: | |
- detect_modified | |
if: needs.detect_modified.outputs.modified == 'true' || inputs.force-rebuild | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- linux_x86_64 | |
- linux_aarch64 | |
- android_arm64-v8a | |
- android_armeabi-v7a | |
- android_x86_64 | |
- android_x86 | |
- ios_arm64 | |
- ios_arm64e | |
- ios_simulator_arm64 | |
- ios_simulator_arm64e | |
- ios_simulator_x86_64 | |
- macos_arm64 | |
- macos_arm64e | |
- macos_x86_64 | |
- windows | |
include: | |
- platform: linux_aarch64 | |
install: gcc-aarch64-linux-gnu | |
- platform: ios_arm64 | |
runs-on: macos-latest | |
- platform: ios_arm64e | |
runs-on: macos-latest | |
- platform: ios_simulator_arm64 | |
runs-on: macos-latest | |
- platform: ios_simulator_arm64e | |
runs-on: macos-latest | |
- platform: ios_simulator_x86_64 | |
runs-on: macos-latest | |
- platform: macos_arm64 | |
runs-on: macos-latest | |
- platform: macos_arm64e | |
runs-on: macos-latest | |
- platform: macos_x86_64 | |
runs-on: macos-latest | |
runs-on: ${{ matrix.runs-on || 'ubuntu-latest' }} | |
steps: | |
- name: Install Flutter-SDK (stable) | |
uses: subosito/flutter-action@v2 | |
with: | |
cache: true | |
- name: Install extra tools | |
if: runner.os == 'Linux' && matrix.install | |
run: sudo apt update && sudo apt install -y ${{ matrix.install }} | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install minisign | |
uses: Skycoder42/dart_test_tools/.github/actions/install-minisign@main | |
- name: Install gnu coreutils | |
if: runner.os == 'macOS' | |
run: brew install coreutils | |
- name: Install dart dependencies | |
run: dart pub get | |
working-directory: packages/sodium_libs | |
- name: Build libsodium binaries | |
run: dart run tool/libsodium/build.dart ${{ matrix.platform }} | |
working-directory: packages/sodium_libs | |
- name: Create artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libsodium-${{ matrix.platform }} | |
path: ${{ runner.temp }}/libsodium-${{ matrix.platform }} | |
if-no-files-found: error | |
retention-days: 1 | |
create_release: | |
name: Create release with new binaries | |
needs: | |
- detect_modified | |
- build | |
if: needs.detect_modified.outputs.modified == 'true' || inputs.force-rebuild | |
runs-on: macos-latest # needed for lipo | |
permissions: | |
contents: write | |
outputs: | |
hash-sums: ${{ steps.publish.outputs.hash-sums }} | |
release-assets: ${{ steps.release.outputs.assets }} | |
steps: | |
- name: Install Flutter-SDK (stable) | |
uses: subosito/flutter-action@v2 | |
with: | |
cache: true | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install minisign | |
uses: Skycoder42/dart_test_tools/.github/actions/install-minisign@main | |
- name: Install dart dependencies | |
run: dart pub get | |
working-directory: packages/sodium_libs | |
- name: Download all binary artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Create secret key for minisign | |
run: echo '${{ secrets.MINISIGN_SECRET_KEY }}' > '${{ runner.temp }}/minisign.key' | |
- id: publish | |
name: Build release archives | |
run: dart run tool/libsodium/publish.dart | |
working-directory: packages/sodium_libs | |
- name: Cleanup minisign key | |
if: always() | |
run: rm -f '${{ runner.temp }}/minisign.key' | |
- id: release | |
name: Create or update release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: libsodium-binaries/v${{ needs.detect_modified.outputs.version }}+${{ github.run_id}} | |
name: "[INTERNAL] Precompiled libsodium binaries v${{ needs.detect_modified.outputs.version }}" | |
body: | | |
Internal release of precompiled libsodium binaries, required for the sodium_libs package. | |
``` | |
${{ needs.detect_modified.outputs.last-modified-content }} | |
``` | |
prerelease: true | |
files: publish/* | |
fail_on_unmatched_files: true | |
update_hashsums: | |
name: Update hashsums | |
needs: | |
- detect_modified | |
- create_release | |
if: needs.detect_modified.outputs.modified == 'true' || inputs.force-rebuild | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Install Flutter-SDK (stable) | |
uses: subosito/flutter-action@v2 | |
with: | |
cache: true | |
- name: Install dart_test_tools | |
run: dart pub global activate dart_test_tools | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install dart dependencies | |
run: dart pub get | |
working-directory: packages/sodium_libs | |
- name: Update hashsums | |
run: >- | |
dart run tool/libsodium/update.dart | |
'${{ needs.create_release.outputs.hash-sums }}' | |
'${{ needs.create_release.outputs.release-assets }}' | |
working-directory: packages/sodium_libs | |
- name: Update last-modified.txt | |
run: | | |
cat << 'EOF' > tool/libsodium/.last-modified.txt | |
${{ needs.detect_modified.outputs.last-modified-content }} | |
EOF | |
working-directory: packages/sodium_libs | |
- name: Update changelog and bump build number | |
run: | | |
set -eo pipefail | |
dart pub global run dart_test_tools:cider log changed 'Updated embedded libsodium binaries' | |
dart pub global run dart_test_tools:cider bump build | |
dart pub global run dart_test_tools:cider version-sync | |
dart pub global run dart_test_tools:cider release | |
working-directory: packages/sodium_libs | |
- id: create-pull-request | |
name: Create Pull Request | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
commit-message: Update hashsums | |
branch: last-modified-${{ github.run_id }} | |
delete-branch: true | |
assignees: Skycoder42 | |
title: Update hashsums with new stable updates | |
body: | | |
Upstream archives for libsodium v${{ needs.detect_modified.outputs.version }} have changed. | |
The new timestamps are: | |
``` | |
${{ needs.detect_modified.outputs.last-modified-content }} | |
``` | |
token: ${{ secrets.GH_PAT }} | |
- name: Mention assignees | |
uses: thollander/actions-comment-pull-request@v3 | |
with: | |
pr-number: ${{ steps.create-pull-request.outputs.pull-request-number }} | |
message: Your review has been requested @Skycoder42 |