Skip to content

Commit

Permalink
Merge pull request #233 from powersync-ja/new-web-build
Browse files Browse the repository at this point in the history
New WASM build
  • Loading branch information
simolus3 authored Feb 12, 2025
2 parents 1f9268f + 9b02dbc commit c0d44cb
Show file tree
Hide file tree
Showing 14 changed files with 404 additions and 146 deletions.
24 changes: 24 additions & 0 deletions .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Prepare
description: Prepare CI environment

runs:
using: composite
steps:
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: "3.x"
channel: "stable"
- name: Download sqlite3.wasm
uses: actions/download-artifact@v4
with:
name: sqlite3-wasm
path: packages/sqlite3_wasm_build/dist/
- name: Install Melos
shell: sh
run: flutter pub global activate melos
- name: Install dependencies
shell: sh
env:
IS_IN_POWERSYNC_CI: 1
run: melos prepare
61 changes: 61 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Check packages and demos

concurrency:
group: packages-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

on:
push:
branches:
- "**"

jobs:
setup:
uses: ./.github/workflows/prepare_wasm.yml

build:
runs-on: ubuntu-latest
needs: [setup]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- name: Check formatting
run: melos format:check:packages
- name: Lint
run: melos analyze:packages
- name: Publish dry-run
run: melos publish --dry-run --yes

pana:
runs-on: ubuntu-latest
needs: [setup]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- name: Check pana score
run: |
flutter pub global activate pana
melos analyze:packages:pana --no-select
test:
runs-on: ubuntu-latest
needs: [setup]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- name: Run flutter tests
run: melos test
- name: Run dart tests
run: melos test:web

check_demos:
runs-on: ubuntu-latest
needs: [setup]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- name: Check formatting
run: melos format:check:demos
- name: Lint
run: |
./.github/workflows/scripts/copy-config.sh
melos analyze:demos
31 changes: 0 additions & 31 deletions .github/workflows/demos.yml

This file was deleted.

68 changes: 0 additions & 68 deletions .github/workflows/packages.yml

This file was deleted.

53 changes: 53 additions & 0 deletions .github/workflows/prepare_wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build SQLite3 WASM

on:
workflow_call:

jobs:
compile_sqlite3_wasm:
name: Compile sqlite3 wasm
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
id: cache_build
with:
path: packages/sqlite3_wasm_build/dist/
key: wasm-${{ runner.os }}-${{ hashFiles('packages/sqlite3_wasm_build/build.sh') }}

- name: Setup Homebrew
if: steps.cache_build.outputs.cache-hit != 'true'
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Install Dart SDK
if: steps.cache_build.outputs.cache-hit != 'true'
uses: dart-lang/setup-dart@v1
- name: Setup macOS build dependencies
if: steps.cache_build.outputs.cache-hit != 'true'
run: brew install cmake llvm lld binaryen wasi-libc wasi-runtimes
- name: Compile sqlite3.wasm on macOS
if: steps.cache_build.outputs.cache-hit != 'true'
working-directory: packages/sqlite3_wasm_build
run: ./build.sh

- name: Upload built sqlite3 binaries
uses: actions/upload-artifact@v4
with:
name: sqlite3-wasm
path: packages/sqlite3_wasm_build/dist/
if-no-files-found: error
retention-days: 1

- name: Setup Node.js
uses: actions/setup-node@v4
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
run_install: false
version: 10
- name: Dry-run npm publish
working-directory: packages/sqlite3_wasm_build
run: |
pnpm i
pnpm publish --no-git-checks --dry-run
35 changes: 22 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- 'powersync-v[0-9]+.[0-9]+.[0-9]+'

jobs:
setup:
uses: ./.github/workflows/prepare_wasm.yml

build:
runs-on: ubuntu-latest
permissions:
Expand All @@ -15,18 +18,7 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.x'
channel: 'stable'

- name: Install Melos
run: flutter pub global activate melos

- name: Install Dependencies and Compile Assets
run: melos prepare
- uses: ./.github/actions/prepare

- name: Create Draft Release
env:
Expand All @@ -39,4 +31,21 @@ jobs:
body="Release $tag
$changes"
gh release create "$tag" --title "$tag" --notes "$body"
gh release upload "${{ github.ref_name }}" packages/powersync/assets/powersync_db.worker.js packages/powersync/assets/powersync_sync.worker.js
gh release upload "${{ github.ref_name }}" packages/powersync/assets/powersync_db.worker.js packages/powersync/assets/powersync_sync.worker.js packages/sqlite3_wasm_build/dist/*.wasm
- name: Setup Node.js
uses: actions/setup-node@v4
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
run_install: false
version: 10
- name: Publish npm package with WASM files
working-directory: packages/sqlite3_wasm_build
run: |
pnpm i
npm version --allow-same-version --no-git-tag-version $(echo $GITHUB_REF_NAME | sed -E 's/powersync-v//')
pnpm publish --no-git-checks --access public
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Loading

0 comments on commit c0d44cb

Please sign in to comment.