Skip to content

Commit c0d44cb

Browse files
authored
Merge pull request #233 from powersync-ja/new-web-build
New WASM build
2 parents 1f9268f + 9b02dbc commit c0d44cb

File tree

14 files changed

+404
-146
lines changed

14 files changed

+404
-146
lines changed

.github/actions/prepare/action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Prepare
2+
description: Prepare CI environment
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Install Flutter
8+
uses: subosito/flutter-action@v2
9+
with:
10+
flutter-version: "3.x"
11+
channel: "stable"
12+
- name: Download sqlite3.wasm
13+
uses: actions/download-artifact@v4
14+
with:
15+
name: sqlite3-wasm
16+
path: packages/sqlite3_wasm_build/dist/
17+
- name: Install Melos
18+
shell: sh
19+
run: flutter pub global activate melos
20+
- name: Install dependencies
21+
shell: sh
22+
env:
23+
IS_IN_POWERSYNC_CI: 1
24+
run: melos prepare

.github/workflows/check.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Check packages and demos
2+
3+
concurrency:
4+
group: packages-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
5+
6+
on:
7+
push:
8+
branches:
9+
- "**"
10+
11+
jobs:
12+
setup:
13+
uses: ./.github/workflows/prepare_wasm.yml
14+
15+
build:
16+
runs-on: ubuntu-latest
17+
needs: [setup]
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: ./.github/actions/prepare
21+
- name: Check formatting
22+
run: melos format:check:packages
23+
- name: Lint
24+
run: melos analyze:packages
25+
- name: Publish dry-run
26+
run: melos publish --dry-run --yes
27+
28+
pana:
29+
runs-on: ubuntu-latest
30+
needs: [setup]
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: ./.github/actions/prepare
34+
- name: Check pana score
35+
run: |
36+
flutter pub global activate pana
37+
melos analyze:packages:pana --no-select
38+
39+
test:
40+
runs-on: ubuntu-latest
41+
needs: [setup]
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: ./.github/actions/prepare
45+
- name: Run flutter tests
46+
run: melos test
47+
- name: Run dart tests
48+
run: melos test:web
49+
50+
check_demos:
51+
runs-on: ubuntu-latest
52+
needs: [setup]
53+
steps:
54+
- uses: actions/checkout@v4
55+
- uses: ./.github/actions/prepare
56+
- name: Check formatting
57+
run: melos format:check:demos
58+
- name: Lint
59+
run: |
60+
./.github/workflows/scripts/copy-config.sh
61+
melos analyze:demos

.github/workflows/demos.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/packages.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

.github/workflows/prepare_wasm.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build SQLite3 WASM
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
compile_sqlite3_wasm:
8+
name: Compile sqlite3 wasm
9+
runs-on: macos-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/cache@v4
14+
id: cache_build
15+
with:
16+
path: packages/sqlite3_wasm_build/dist/
17+
key: wasm-${{ runner.os }}-${{ hashFiles('packages/sqlite3_wasm_build/build.sh') }}
18+
19+
- name: Setup Homebrew
20+
if: steps.cache_build.outputs.cache-hit != 'true'
21+
id: set-up-homebrew
22+
uses: Homebrew/actions/setup-homebrew@master
23+
- name: Install Dart SDK
24+
if: steps.cache_build.outputs.cache-hit != 'true'
25+
uses: dart-lang/setup-dart@v1
26+
- name: Setup macOS build dependencies
27+
if: steps.cache_build.outputs.cache-hit != 'true'
28+
run: brew install cmake llvm lld binaryen wasi-libc wasi-runtimes
29+
- name: Compile sqlite3.wasm on macOS
30+
if: steps.cache_build.outputs.cache-hit != 'true'
31+
working-directory: packages/sqlite3_wasm_build
32+
run: ./build.sh
33+
34+
- name: Upload built sqlite3 binaries
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: sqlite3-wasm
38+
path: packages/sqlite3_wasm_build/dist/
39+
if-no-files-found: error
40+
retention-days: 1
41+
42+
- name: Setup Node.js
43+
uses: actions/setup-node@v4
44+
- uses: pnpm/action-setup@v2
45+
name: Install pnpm
46+
with:
47+
run_install: false
48+
version: 10
49+
- name: Dry-run npm publish
50+
working-directory: packages/sqlite3_wasm_build
51+
run: |
52+
pnpm i
53+
pnpm publish --no-git-checks --dry-run

.github/workflows/release.yml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
- 'powersync-v[0-9]+.[0-9]+.[0-9]+'
88

99
jobs:
10+
setup:
11+
uses: ./.github/workflows/prepare_wasm.yml
12+
1013
build:
1114
runs-on: ubuntu-latest
1215
permissions:
@@ -15,18 +18,7 @@ jobs:
1518
steps:
1619
- name: Checkout Repository
1720
uses: actions/checkout@v4
18-
19-
- name: Install Flutter
20-
uses: subosito/flutter-action@v2
21-
with:
22-
flutter-version: '3.x'
23-
channel: 'stable'
24-
25-
- name: Install Melos
26-
run: flutter pub global activate melos
27-
28-
- name: Install Dependencies and Compile Assets
29-
run: melos prepare
21+
- uses: ./.github/actions/prepare
3022

3123
- name: Create Draft Release
3224
env:
@@ -39,4 +31,21 @@ jobs:
3931
body="Release $tag
4032
$changes"
4133
gh release create "$tag" --title "$tag" --notes "$body"
42-
gh release upload "${{ github.ref_name }}" packages/powersync/assets/powersync_db.worker.js packages/powersync/assets/powersync_sync.worker.js
34+
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
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v4
38+
- uses: pnpm/action-setup@v2
39+
name: Install pnpm
40+
with:
41+
run_install: false
42+
version: 10
43+
- name: Publish npm package with WASM files
44+
working-directory: packages/sqlite3_wasm_build
45+
run: |
46+
pnpm i
47+
npm version --allow-same-version --no-git-tag-version $(echo $GITHUB_REF_NAME | sed -E 's/powersync-v//')
48+
pnpm publish --no-git-checks --access public
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)