Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .github/workflows/release-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Build & Upload Release Artifacts

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
workflow_dispatch:

jobs:
build-artifacts:
name: Build Native Artifact (${{ matrix.target.os }}-${{ matrix.target.arch }})
runs-on: ${{ matrix.target.runner }}
strategy:
fail-fast: false
matrix:
target:
- os: linux
arch: x64
runner: ubuntu-latest
artifact: libwebcrypto.so
asset_name: webcrypto-linux-x64-libwebcrypto.so
- os: macos
arch: x64
runner: macos-13
artifact: libwebcrypto.dylib
asset_name: webcrypto-macOS-x64-libwebcrypto.dylib
- os: macos
arch: arm64
runner: macos-14
artifact: libwebcrypto.dylib
asset_name: webcrypto-macOS-arm64-libwebcrypto.dylib
- os: windows
arch: x64
runner: windows-latest
artifact: webcrypto.dll
asset_name: webcrypto-windows-x64-webcrypto.dll
- os: android
arch: arm64
abi: arm64-v8a
runner: ubuntu-latest
artifact: libwebcrypto.so
asset_name: webcrypto-android-arm64-libwebcrypto.so
- os: android
arch: arm
abi: armeabi-v7a
runner: ubuntu-latest
artifact: libwebcrypto.so
asset_name: webcrypto-android-arm-libwebcrypto.so
- os: android
arch: x64
abi: x86_64
runner: ubuntu-latest
artifact: libwebcrypto.so
asset_name: webcrypto-android-x64-libwebcrypto.so
- os: iOS
arch: arm64
runner: macos-14
artifact: libwebcrypto.dylib
asset_name: webcrypto-iOS-arm64-libwebcrypto.dylib

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@f37a2a73da312e3e63f5c0b9634526d2b0e7fe88
with:
channel: 'stable'
cache: true

- name: Configure Linux Dependencies
if: matrix.target.os == 'linux'
run: |
sudo apt-get update -y
sudo apt-get install -y cmake ninja-build libgtk-3-dev

- name: Build Native Library (native_toolchain_cmake)
run: |
dart pub get
dart run tool/build_native.dart --target-os ${{ matrix.target.os }} --target-architecture ${{ matrix.target.arch }} --output-dir ./build_native

- name: Locate, Rename, and Hash Artifact
shell: bash
run: |
LIBRARY_PATH=$(find build_native -name "${{ matrix.target.artifact }}" | head -n 1)
if [ -z "$LIBRARY_PATH" ]; then
echo "Error: Could not find ${{ matrix.target.artifact }}"
exit 1
fi
cp "$LIBRARY_PATH" "./${{ matrix.target.asset_name }}"
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "./${{ matrix.target.asset_name }}" > "./${{ matrix.target.asset_name }}.sha256"
else
shasum -a 256 "./${{ matrix.target.asset_name }}" > "./${{ matrix.target.asset_name }}.sha256"
fi

- name: Upload Build Artifacts (Workflow Debugging)
uses: actions/upload-artifact@b4b15b348d6a79ff96702e61a5847e68810fe949
with:
name: ${{ matrix.target.asset_name }}
path: |
./${{ matrix.target.asset_name }}
./${{ matrix.target.asset_name }}.sha256

- name: Upload Release Asset (Release Tags Only)
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@c95fe0c20b7ea1f2c1494446929e7f3e254c693a
with:
files: |
./${{ matrix.target.asset_name }}
./${{ matrix.target.asset_name }}.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/treeshake-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Link Hook Treeshake Test

on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:

jobs:
test-treeshake-desktop:
name: Link Hook Treeshake (${{ matrix.os }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os: linux
runner: ubuntu-latest
- os: macos
runner: macos-14
- os: windows
runner: windows-latest

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- uses: subosito/flutter-action@f37a2a73da312e3e63f5c0b9634526d2b0e7fe88
with:
channel: 'stable'
cache: true

- name: Setup Windows NASM
if: matrix.os == 'windows'
uses: ilammy/setup-nasm@141b71216503c14c57c5f87b1c312781b012d093

- name: Configure Linux Dependencies
if: matrix.os == 'linux'
run: |
sudo apt-get update -y
sudo apt-get install -y cmake ninja-build libgtk-3-dev

- name: Get Dependencies
run: flutter pub get

- name: Run Treeshake Test with dart build & Size Limit Verification
run: dart test test/ffi/treeshake_test.dart
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 0.6.2-wip
* Fixed JS interop to enable WebAssembly.
* Upgrade `ffigen` and `hooks` versions.

# 0.6.1
* Added Dart native build hooks and native asset lookup for the bundled
Expand Down
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,29 @@ see `doc/design-rationale-md`.

## System dependencies

When you have a dependency on `package:webcrypto`, it will use
[hooks](https://dart.dev/tools/hooks) to build BoringSSL. Thus, your system
must have:
By default, `package:webcrypto` uses [hooks](https://dart.dev/tools/hooks) to fetch prebuilt native binaries, so no additional system dependencies are required for supported target platforms.

### Build Configuration

You can configure the build mode in `pubspec.yaml`:

```yaml
hooks:
user_defines:
webcrypto:
buildMode: fetch # Options: 'fetch' (default), 'build', 'local'
```

* `fetch` (default): Downloads prebuilt binaries from release assets (falls back to building from source if prebuilt binaries are unavailable).
* `build`: Always builds BoringSSL locally from source using CMake.
* `local`: Uses a prebuilt binary from a specified local path (`localPath`).

If you configure `package:webcrypto` to build from source, your system must have:

* `cmake`, and,
* a C compiler (like `gcc` or `clang`)


## Limitations
This package has a few limitations compared to the
[Web Cryptography API][webcrypto-spec]. For a discussion of parity with
Expand Down
Loading
Loading