Skip to content

Commit 8aa44c4

Browse files
committed
Preparing release setup and CI/CD.
1 parent 7f795ab commit 8aa44c4

File tree

6 files changed

+84
-92
lines changed

6 files changed

+84
-92
lines changed

.github/workflows/dotnet-test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Test Packages
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
name: Build and Test .NET Project
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: Restore dependencies
21+
run: dotnet restore
22+
23+
- name: Run tests
24+
run: dotnet test -v n

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## 0.0.1 Pre-Alpha
2+
3+
Introduce package.
4+
5+
### Platform Support Added
6+
* linux-arm64
7+
* linux-x64
8+
* osx-arm64
9+
* osx-x64
10+
* wind-x64

PowerSync/PowerSync.Common/Client/PowerSyncDatabase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ public async Task<T> WriteTransaction<T>(Func<ITransaction, Task<T>> fn, DBLockO
573573
/// </summary>
574574
public Task Watch<T>(string query, object[]? parameters, WatchHandler<T> handler, SQLWatchOptions? options = null)
575575
{
576-
var tcs = new TaskCompletionSource();
576+
var tcs = new TaskCompletionSource<bool>();
577577
Task.Run(async () =>
578578
{
579579
try
@@ -603,7 +603,7 @@ public Task Watch<T>(string query, object[]? parameters, WatchHandler<T> handler
603603
Signal = options?.Signal,
604604
ThrottleMs = options?.ThrottleMs
605605
});
606-
tcs.SetResult();
606+
tcs.SetResult(true);
607607
}
608608
catch (Exception ex)
609609
{

PowerSync/PowerSync.Common/PowerSync.Common.csproj

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@
55
<LangVersion>12</LangVersion>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
<Title>PowerSync.Common</Title>
9+
<Authors>PowerSync</Authors>
10+
<owners>powersync</owners>
11+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
12+
<PackageProjectUrl>https://github.com/powersync-ja/powersync-dotnet</PackageProjectUrl>
13+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
14+
<PackageReleaseNotes>https://github.com/powersync-ja/powersync-dotnet/CHANGELOG.md</PackageReleaseNotes>
15+
<PackageTags>powersync local-first local-storage state-management offline sql db persistence sqlite sync </PackageTags>
16+
<PackageIcon>icon.png</PackageIcon>
817
<VersionPrefix>0.0.1</VersionPrefix>
9-
<VersionSuffix>alpha</VersionSuffix>
18+
<VersionSuffix>pre-alpha</VersionSuffix>
1019
</PropertyGroup>
1120

1221
<ItemGroup>
@@ -18,10 +27,20 @@
1827
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
1928
</ItemGroup>
2029

30+
<!-- For monorepo, test if we can remove this in monorepo -->
2131
<ItemGroup>
2232
<Content Include="runtimes\**\*.*">
2333
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2434
</Content>
2535
</ItemGroup>
2636

37+
<!-- For releasing runtimes -->
38+
<ItemGroup>
39+
<None Include="runtimes\**\*.*" Pack="true" PackagePath="runtimes\" />
40+
</ItemGroup>
41+
42+
43+
<ItemGroup>
44+
<None Include="..\..\icon.png" Pack="true" PackagePath=""/>
45+
</ItemGroup>
2746
</Project>

Tools/Setup/Setup.cs

Lines changed: 28 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using System.IO;
33
using System.Net.Http;
4-
using System.Runtime.InteropServices;
54
using System.Threading.Tasks;
5+
using System.Collections.Generic;
66

77
public class Setup
88
{
@@ -11,103 +11,42 @@ static async Task Main(string[] args)
1111
const string baseUrl = "https://github.com/powersync-ja/powersync-sqlite-core/releases/download/v0.3.8";
1212
string powersyncCorePath = Path.Combine(AppContext.BaseDirectory, "../../../../..", "PowerSync/PowerSync.Common/");
1313

14-
string rid = GetRuntimeIdentifier();
15-
string nativeDir = Path.Combine(powersyncCorePath, "runtimes", rid, "native");
16-
17-
Directory.CreateDirectory(nativeDir);
18-
19-
string sqliteCoreFilename = GetLibraryForPlatform();
20-
string sqliteCorePath = Path.Combine(nativeDir, sqliteCoreFilename);
14+
var runtimeIdentifiers = new Dictionary<string, (string originalFile, string newFile)>
15+
{
16+
{ "osx-x64", ("libpowersync_x64.dylib", "libpowersync.dylib") },
17+
{ "osx-arm64", ("libpowersync_aarch64.dylib", "libpowersync.dylib") },
18+
{ "linux-x64", ("libpowersync_x64.so", "libpowersync.so") },
19+
{ "linux-arm64", ("libpowersync_aarch64.so", "libpowersync.so") },
20+
{ "win-x64", ("powersync_x64.dll", "powersync.dll") }
21+
};
2122

22-
try
23+
foreach (var (rid, (originalFile, newFile)) in runtimeIdentifiers)
2324
{
24-
await DownloadFile($"{baseUrl}/{sqliteCoreFilename}", sqliteCorePath);
25+
string nativeDir = Path.Combine(powersyncCorePath, "runtimes", rid, "native");
26+
Directory.CreateDirectory(nativeDir);
2527

26-
string newFileName = GetFileNameForPlatform();
27-
string newFilePath = Path.Combine(nativeDir, newFileName);
28+
string sqliteCorePath = Path.Combine(nativeDir, originalFile);
29+
string newFilePath = Path.Combine(nativeDir, newFile);
2830

29-
if (File.Exists(sqliteCorePath))
31+
try
3032
{
31-
File.Move(sqliteCorePath, newFilePath, overwrite: true);
32-
Console.WriteLine($"File renamed successfully from {sqliteCoreFilename} to {newFileName}");
33+
await DownloadFile($"{baseUrl}/{originalFile}", sqliteCorePath);
34+
35+
if (File.Exists(sqliteCorePath))
36+
{
37+
File.Move(sqliteCorePath, newFilePath, overwrite: true);
38+
Console.WriteLine($"File renamed successfully from {originalFile} to {newFile} in {nativeDir}");
39+
}
40+
else
41+
{
42+
throw new IOException($"File {originalFile} does not exist.");
43+
}
3344
}
34-
else
45+
catch (Exception ex)
3546
{
36-
throw new IOException($"File {sqliteCoreFilename} does not exist.");
47+
Console.Error.WriteLine($"Error processing {rid}: {ex.Message}");
3748
}
3849
}
39-
catch (Exception ex)
40-
{
41-
Console.Error.WriteLine($"Error: {ex.Message}");
42-
Environment.Exit(1);
43-
}
44-
}
45-
46-
static string GetRuntimeIdentifier()
47-
{
48-
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
49-
{
50-
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
51-
return "osx-arm64";
52-
else
53-
return "osx-x64";
54-
}
55-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
56-
{
57-
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
58-
return "linux-arm64";
59-
else
60-
return "linux-x64";
61-
}
62-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
63-
{
64-
return "win-x64";
65-
}
66-
throw new PlatformNotSupportedException("Unsupported platform.");
67-
}
68-
69-
static string GetFileNameForPlatform()
70-
{
71-
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
72-
{
73-
return "libpowersync.dylib";
74-
}
75-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
76-
{
77-
return "libpowersync.so";
78-
}
79-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
80-
{
81-
return "powersync.dll";
82-
}
83-
else
84-
{
85-
throw new PlatformNotSupportedException("Unsupported platform.");
86-
}
87-
}
88-
89-
static string GetLibraryForPlatform()
90-
{
91-
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
92-
{
93-
return RuntimeInformation.ProcessArchitecture == Architecture.Arm64
94-
? "libpowersync_aarch64.dylib"
95-
: "libpowersync_x64.dylib";
96-
}
97-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
98-
{
99-
return RuntimeInformation.ProcessArchitecture == Architecture.Arm64
100-
? "libpowersync_aarch64.so"
101-
: "libpowersync_x64.so";
102-
}
103-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
104-
{
105-
return "powersync_x64.dll";
106-
}
107-
else
108-
{
109-
throw new PlatformNotSupportedException("Unsupported platform.");
110-
}
11150
}
11251

11352
static async Task DownloadFile(string url, string outputPath)

icon.png

1.8 KB
Loading

0 commit comments

Comments
 (0)