Skip to content
Merged
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
42 changes: 24 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+

jobs:
draft_release:
name: Create Draft GitHub Release
Expand Down Expand Up @@ -33,8 +34,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build Linux
uses: ./.github/actions/linux

Expand All @@ -43,8 +42,6 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build macOS
uses: ./.github/actions/macos

Expand All @@ -53,8 +50,6 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build Windows
uses: ./.github/actions/windows

Expand All @@ -63,8 +58,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build Android
uses: ./.github/actions/android
with:
Expand All @@ -76,8 +69,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build wasm
uses: ./.github/actions/wasm
Expand All @@ -87,8 +78,6 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build XCFramework
uses: ./.github/actions/xcframework

Expand Down Expand Up @@ -119,8 +108,6 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Download libs
uses: actions/download-artifact@v5
Expand Down Expand Up @@ -176,8 +163,6 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Download Linux libraries
uses: actions/download-artifact@v5
Expand Down Expand Up @@ -220,8 +205,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Download wasm bundle
uses: actions/download-artifact@v5
Expand Down Expand Up @@ -249,6 +232,26 @@ jobs:
file-name: libpowersync-wasm.a
tag: ${{ needs.draft_release.outputs.tag }}

publish_crates_io:
runs-on: ubuntu-latest
permissions:
id-token: write # Required for OIDC token exchange
steps:
- uses: actions/checkout@v5
- uses: rust-lang/crates-io-auth-action@v1
id: auth

- name: Publish powersync_sqlite_nostd
run: cargo publish
working-directory: crates/core
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
- name: Publish powersync_core
run: cargo publish
working-directory: crates/core
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

create_sdk_issue:
name: "Create issue for SDK updates"
permissions:
Expand All @@ -260,6 +263,7 @@ jobs:
- publish_ios_pod_and_spm_package
- publish_desktop
- publish_wasm
- publish_crates_io
steps:
- name: Create issue
run: |
Expand All @@ -277,6 +281,7 @@ jobs:

Core build (this repo):
* [x] GitHub Release
* [x] New version released on crates.io
* [ ] Android aar released on Maven Central
* [ ] Cocoapod released

Expand All @@ -290,3 +295,4 @@ jobs:
* [ ] powersync-js:
* [ ] kotlin:
* [ ] swift:
* [ ] native:
21 changes: 1 addition & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build Linux libraries
uses: ./.github/actions/linux

Expand All @@ -21,8 +19,6 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build macOS
uses: ./.github/actions/macos

Expand All @@ -32,8 +28,7 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build Windows
uses: ./.github/actions/windows

Expand All @@ -43,8 +38,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build Android
uses: ./.github/actions/android
with:
Expand All @@ -56,8 +49,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build wasm
uses: ./.github/actions/wasm
Expand All @@ -68,8 +59,6 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build XCFramework
uses: ./.github/actions/xcframework

Expand All @@ -83,8 +72,6 @@ jobs:
os: [ubuntu-24.04, macos-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Ubuntu setup
if: matrix.os == 'ubuntu-24.04'
Expand Down Expand Up @@ -131,8 +118,6 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: dart-lang/setup-dart@v1

Expand Down Expand Up @@ -190,8 +175,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: dart-lang/setup-dart@v1
- name: Install Rust Stable
Expand Down Expand Up @@ -230,8 +213,6 @@ jobs:
- os: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust Nightly
uses: dtolnay/rust-toolchain@stable
with:
Expand Down
2 changes: 2 additions & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ repository.workspace = true
license.workspace = true
authors.workspace = true
keywords.workspace = true
description = "The PowerSync SQLite extension"
readme = "README.md"

[lib]
name = "powersync_core"
Expand Down
24 changes: 20 additions & 4 deletions crates/core/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
<p align="center">
<a href="https://www.powersync.com" target="_blank"><img src="https://github.com/powersync-ja/.github/assets/7372448/d2538c43-c1a0-4c47-9a76-41462dba484f"/></a>
</p>

_[PowerSync](https://www.powersync.com) is a sync engine for building local-first apps with instantly-responsive UI/UX and simplified state transfer. Syncs between SQLite on the client-side and Postgres, MongoDB or MySQL on the server-side._

# powersync_core

This is the core SQLite extension, containing all the logic.
This is the core SQLite extension, containing all the logic. This is used internally by PowerSync SDKs,
and would typically not be used by users directly.

The role of the extension is to create user-defined functions that higher-level SDKs would use to implement
schema management and a PowerSync client.
Not all of this is documented, but [this directory](https://github.com/powersync-ja/powersync-sqlite-core/tree/main/docs)
provides some hints on how a custom PowerSync SDK could be implemented.

Since the different build configurations (loadable extension, bundled SQLite shell)
use different cargo config, we can't completely separate them just using features.
Instead, we use different crates depending on this core lib.
For this reason, the crate doesn't have much of a public API. In the default build mode, it doesn't expect
SQLite to be linked and exposes a single function: `sqlite3_powersync_init`,
a [loadable extension](https://sqlite.org/loadext.html) entrypoint.

For applications linking SQLite, the `static` feature of this crate can be enabled.
With that feature, `powersync_init_static()` can be called to load the
extension for all new connections.
The application is responsible for linking SQLite in that case.
10 changes: 9 additions & 1 deletion crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ mod view_admin;
mod views;
mod vtab_util;

/// The entrypoint for the PowerSync SQLite core extension.
///
/// When compiling this Rust crate into a dynamic library, it can be used by embedders to load it
/// through [SQLite's opening mechanism](https://sqlite.org/loadext.html#loading_an_extension).
#[unsafe(no_mangle)]
pub extern "C" fn sqlite3_powersync_init(
db: *mut sqlite::sqlite3,
Expand Down Expand Up @@ -85,7 +89,7 @@ fn init_extension(db: *mut sqlite::sqlite3) -> Result<(), PowerSyncError> {
unsafe extern "C" {
#[cfg(feature = "static")]
#[allow(non_snake_case)]
pub fn sqlite3_auto_extension(
fn sqlite3_auto_extension(
xEntryPoint: Option<
extern "C" fn(
*mut sqlite::sqlite3,
Expand All @@ -96,6 +100,10 @@ unsafe extern "C" {
) -> ::core::ffi::c_int;
}

/// Calls `sqlite3_auto_extension` with [sqlite3_powersync_init] to automatically load
/// the PowerSync core extension into new connections.
///
/// For details, see https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
#[cfg(feature = "static")]
#[unsafe(no_mangle)]
pub extern "C" fn powersync_init_static() -> c_int {
Expand Down
2 changes: 2 additions & 0 deletions crates/sqlite_nostd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ repository.workspace = true
license.workspace = true
authors.workspace = true
keywords.workspace = true
description = "Lightweight, semi-unsafe, nostd bindings to sqlite3"
readme = "README.md"

[lib]
name = "powersync_sqlite_nostd"
Expand Down