Skip to content

Commit 8342b51

Browse files
committed
Setup GH actions for testing and manual release. Added small flow for windows/.NET 4.8
1 parent 8aa44c4 commit 8342b51

File tree

10 files changed

+151
-58
lines changed

10 files changed

+151
-58
lines changed

.github/workflows/dev-packages.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# The version is pulled from the CHANGELOG.md file of the package.
2+
# Add a `-dev.xxx` suffix to the version.
3+
name: Create Dev Release
4+
5+
on: workflow_dispatch
6+
7+
jobs:
8+
dev-release:
9+
name: Publish Dev Packages
10+
runs-on: windows-latest
11+
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup .NET SDK
17+
uses: actions/setup-dotnet@v4
18+
with:
19+
dotnet-version: '8.0'
20+
21+
- name: Download PowerSync extension
22+
run: dotnet run --project Tools/Setup
23+
24+
- name: Restore dependencies
25+
run: dotnet restore
26+
27+
- name: Extract Version from CHANGELOG.md
28+
id: extract_version
29+
shell: bash
30+
run: |
31+
VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+/ {print $2; exit}' PowerSync/PowerSync.Common/CHANGELOG.md)
32+
echo "Detected Version: $VERSION"
33+
echo "VERSION=$VERSION" >> $GITHUB_ENV
34+
35+
- name: Run Pack
36+
run: dotnet pack -c Release -o ${{ github.workspace }}/output
37+
38+
- name: Run Push
39+
run: dotnet nuget push ${{ github.workspace }}\output\*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
40+

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# The version is pulled from the CHANGELOG.md file of the package.
2+
name: Release
3+
4+
on: workflow_dispatch
5+
6+
jobs:
7+
release:
8+
name: Release
9+
runs-on: windows-latest
10+
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v4
14+
15+
- name: Setup .NET SDK
16+
uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: '8.0'
19+
20+
- name: Download PowerSync extension
21+
run: dotnet run --project Tools/Setup
22+
23+
- name: Restore dependencies
24+
run: dotnet restore
25+
26+
- name: Extract Version from CHANGELOG.md
27+
id: extract_version
28+
shell: bash
29+
run: |
30+
VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+/ {print $2; exit}' PowerSync/PowerSync.Common/CHANGELOG.md)
31+
echo "Detected Version: $VERSION"
32+
echo "VERSION=$VERSION" >> $GITHUB_ENV
33+
34+
- name: Run Pack
35+
run: dotnet pack -c Release -o ${{ github.workspace }}/output
36+
37+
- name: Run Push
38+
run: dotnet nuget push ${{ github.workspace }}\output\*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
39+

.github/workflows/dotnet-test.yml renamed to .github/workflows/test.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
build:
8-
name: Build and Test .NET Project
8+
name: Test Packages
99
runs-on: windows-latest
1010

1111
steps:
@@ -17,8 +17,11 @@ jobs:
1717
with:
1818
dotnet-version: '8.0'
1919

20+
- name: Download PowerSync extension
21+
run: dotnet run --project Tools/Setup
22+
2023
- name: Restore dependencies
2124
run: dotnet restore
22-
25+
2326
- name: Run tests
24-
run: dotnet test -v n
27+
run: dotnet test -v n --framework net8.0

CHANGELOG.md

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## 0.0.2-alpha.1
2+
3+
- Introduce package. Support for Desktop .NET use cases.
4+
5+
### Platform Runtime Support Added
6+
* linux-arm64
7+
* linux-x64
8+
* osx-arm64
9+
* osx-x64
10+
* wind-x64

PowerSync/PowerSync.Common/PowerSync.Common.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
<LangVersion>12</LangVersion>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
<PackageId>PowerSync.Common</PackageId>
89
<Title>PowerSync.Common</Title>
10+
<Description>PowerSync.Common is a package that enables local-first and real-time reactive apps with embedded SQLite for .NET clients</Description>
911
<Authors>PowerSync</Authors>
1012
<owners>powersync</owners>
1113
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
12-
<PackageProjectUrl>https://github.com/powersync-ja/powersync-dotnet</PackageProjectUrl>
14+
<RepositoryUrl>https://github.com/powersync-ja/powersync-dotnet</RepositoryUrl>
15+
<PackageProjectUrl>https://powersync.com</PackageProjectUrl>
1316
<PublishRepositoryUrl>true</PublishRepositoryUrl>
14-
<PackageReleaseNotes>https://github.com/powersync-ja/powersync-dotnet/CHANGELOG.md</PackageReleaseNotes>
17+
<PackageReleaseNotes>https://github.com/powersync-ja/powersync-dotnet/PowerSync/PowerSync.Common/CHANGELOG.md</PackageReleaseNotes>
1518
<PackageTags>powersync local-first local-storage state-management offline sql db persistence sqlite sync </PackageTags>
1619
<PackageIcon>icon.png</PackageIcon>
17-
<VersionPrefix>0.0.1</VersionPrefix>
18-
<VersionSuffix>pre-alpha</VersionSuffix>
20+
<NoWarn>NU5100</NoWarn>
21+
<PackageReadmeFile>README.md</PackageReadmeFile>
1922
</PropertyGroup>
2023

2124
<ItemGroup>
@@ -42,5 +45,6 @@
4245

4346
<ItemGroup>
4447
<None Include="..\..\icon.png" Pack="true" PackagePath=""/>
48+
<None Include="README.md" Pack="true" PackagePath=""/>
4549
</ItemGroup>
4650
</Project>

PowerSync/PowerSync.Common/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
This package contains a .NET implementation of a PowerSync database connector and streaming sync bucket implementation.
44

5+
## ⚠️ Project Status & Release Note
6+
7+
This package is currently in an alpha state, intended strictly for testing. Expect breaking changes and instability as development continues.
8+
9+
Do not rely on this package for production use.
10+
11+
## Installation
12+
13+
This package is published on [NuGet](https://www.nuget.org/packages/PowerSync.Common).
14+
15+
```bash
16+
dotnet add package PowerSync.Common --prerelease
17+
```
18+
519
## Usage
620

721
### Simple Query

PowerSync/PowerSync.Common/Utils/PowerSyncPathResolver.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ public static class PowerSyncPathResolver
66
{
77
public static string GetNativeLibraryPath(string packagePath)
88
{
9+
10+
// .NET Framework 4.8 on Windows requires a different path (not supporting versions prior to this)
11+
if (RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework 4.8") && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
12+
{
13+
return Path.Combine(AppContext.BaseDirectory, "powersync.dll");
14+
}
15+
916
string rid = GetRuntimeIdentifier();
1017
string nativeDir = Path.Combine(packagePath, "runtimes", rid, "native");
1118

README.md

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@ _[PowerSync](https://www.powersync.com) is a sync engine for building local-firs
88

99
`powersync-dotnet` is the monorepo for PowerSync .NET SDKs.
1010

11-
## ⚠️ Project Status & Release Note
12-
13-
This package is part of a monorepo that is not yet officially released or published. It is currently in a pre-alpha state, intended strictly for closed testing. Expect breaking changes and instability as development continues.
14-
15-
Do not rely on this package for production use.
16-
1711
## Monorepo Structure: Packages
1812

13+
Packages are published to [NuGet](https://www.nuget.org/profiles/PowerSync).
14+
1915
- [PowerSync/Common](./PowerSync/Common/README.md)
2016

2117
- Core package: .NET implementation of a PowerSync database connector and streaming sync bucket implementation. Packages meant for specific platforms will extend functionality of `Common`.
@@ -54,6 +50,18 @@ This PowerSync SDK currently targets the following .NET versions:
5450
<PackageReference Include="System.Net.Http" Version="4.3.4" />
5551
</ItemGroup>
5652
```
53+
54+
and create a `IsExternalInit.cs` file in your project with the following contents:
55+
56+
```cs
57+
using System.ComponentModel;
58+
59+
namespace System.Runtime.CompilerServices
60+
{
61+
[EditorBrowsable(EditorBrowsableState.Never)]
62+
internal class IsExternalInit { }
63+
}
64+
```
5765

5866
-------
5967

@@ -87,29 +95,7 @@ Run a specific test
8795
dotnet test -v n --framework net8.0 --filter "test-file-pattern"
8896
```
8997

90-
## Using the PowerSync.Common package in your project (temporary)
91-
A NuGet package will be available soon, until then you clone this repo and follow these steps:
92-
93-
Add the dependency to your project's .csproj:
94-
```.xml
95-
<ItemGroup>
96-
<ProjectReference Include="..\..\powersync-dotnet\PowerSync\Powersync.Common\PowerSync.Common.csproj" />
97-
</ItemGroup>
98-
```
99-
100-
Which assumes the following directory structure:
101-
```
102-
code/
103-
powersync-dotnet (X)
104-
├── PowerSync/PowerSync.Common
105-
│ ├── PowerSync.Common.csproj
106-
│ ├── Class1.cs
107-
│ └── Utils.cs
108-
└── root.sln
109-
110-
your-project
111-
├── demo
112-
│ ├── Program.csproj
113-
│ └── Program.cs
114-
├── root.sln
98+
## Using the PowerSync.Common package in your project
99+
```bash
100+
dotnet add package PowerSync.Common --prerelease
115101
```

Tests/PowerSync/PowerSync.Common.Tests/Client/PowerSyncDatabaseTransactionTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ await db.Execute(
189189
[Fact(Timeout = 2000)]
190190
public async Task ReadWhileWriteIsRunningTest()
191191
{
192-
var tcs = new TaskCompletionSource();
192+
var tcs = new TaskCompletionSource<bool>();
193193

194194
// This wont resolve or free until another connection free's it
195195
var writeTask = db.WriteLock(async context =>
@@ -200,7 +200,7 @@ public async Task ReadWhileWriteIsRunningTest()
200200
var readTask = db.ReadLock(async context =>
201201
{
202202
// Read logic could execute here while writeLock is still open
203-
tcs.SetResult();
203+
tcs.SetResult(true);
204204
await Task.CompletedTask;
205205
return 42;
206206
});
@@ -238,13 +238,13 @@ await db.WriteLock(async context =>
238238
public async Task CallUpdateHookOnChangesTest()
239239
{
240240
var cts = new CancellationTokenSource();
241-
var result = new TaskCompletionSource();
241+
var result = new TaskCompletionSource<bool>();
242242

243243
db.OnChange(new WatchOnChangeHandler
244244
{
245245
OnChange = (x) =>
246246
{
247-
result.SetResult();
247+
result.SetResult(true);
248248
cts.Cancel();
249249
return Task.CompletedTask;
250250
}
@@ -261,7 +261,7 @@ public async Task CallUpdateHookOnChangesTest()
261261
[Fact(Timeout = 2000)]
262262
public async Task ReflectWriteTransactionUpdatesOnReadConnectionsTest()
263263
{
264-
var watched = new TaskCompletionSource();
264+
var watched = new TaskCompletionSource<bool>();
265265

266266
var cts = new CancellationTokenSource();
267267
await db.Watch("SELECT COUNT(*) as count FROM assets", null, new WatchHandler<CountResult>
@@ -270,7 +270,7 @@ public async Task ReflectWriteTransactionUpdatesOnReadConnectionsTest()
270270
{
271271
if (x.First().count == 1)
272272
{
273-
watched.SetResult();
273+
watched.SetResult(true);
274274
cts.Cancel();
275275
}
276276
}
@@ -292,7 +292,7 @@ public async Task ReflectWriteLockUpdatesOnReadConnectionsTest()
292292
{
293293
var numberOfAssets = 10_000;
294294

295-
var watched = new TaskCompletionSource();
295+
var watched = new TaskCompletionSource<bool>();
296296

297297
var cts = new CancellationTokenSource();
298298
await db.Watch("SELECT COUNT(*) as count FROM assets", null, new WatchHandler<CountResult>
@@ -301,7 +301,7 @@ public async Task ReflectWriteLockUpdatesOnReadConnectionsTest()
301301
{
302302
if (x.First().count == numberOfAssets)
303303
{
304-
watched.SetResult();
304+
watched.SetResult(true);
305305
cts.Cancel();
306306
}
307307
}
@@ -324,12 +324,12 @@ await db.WriteLock(async tx =>
324324
}
325325

326326
[Fact(Timeout = 5000)]
327-
public async Task Insert10000Records_CompleteWithinTimeLimitTest()
327+
public async Task Insert1000Records_CompleteWithinTimeLimitTest()
328328
{
329329
var random = new Random();
330330
var stopwatch = Stopwatch.StartNew();
331331

332-
for (int i = 0; i < 10000; ++i)
332+
for (int i = 0; i < 1000; ++i)
333333
{
334334
int n = random.Next(0, 100000);
335335
await db.Execute(

0 commit comments

Comments
 (0)