Skip to content

Automate package publishing #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Aug 19, 2024
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
33 changes: 24 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: Publish packages
on: workflow_dispatch
on:
push:
tags:
- "powersync-v[0-9]+.[0-9]+.[0-9]+"
- "powersync_attachments_helper-v[0-9]+.[0-9]+.[0-9]+*"
- "powersync_flutter_libs-v[0-9]+.[0-9]+.[0-9]+*"
workflow_dispatch:

jobs:
publish-packages:
Expand All @@ -9,11 +15,20 @@ jobs:
id-token: write # Required for authentication using OIDC
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.x'
channel: 'stable'
- uses: bluefireteam/melos-action@v3
with:
publish: true
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@v1 # Creates and configures token for publishing

- name: Install melos
run: dart pub global activate melos

- name: Set powersync core version
run: echo "CORE_VERSION=v0.1.8" >> $GITHUB_ENV

- name: Publish packages dry run
run: |
melos publish

- name: Publish packages
run: |
melos publish --no-dry-run
7 changes: 1 addition & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ name: Compile Assets and Create Draft Release
on:
push:
tags:
# Trigger on tags beginning with 'v'
# Note that `melos version ...` adds the package name as a suffix
# This action is not compatible with tags such as `powersync-v1.1.1`
# marvinpinto/action-automatic-releases struggles to generate changelogs
# Be sure to manually tag the commit to trigger this action
- "powersync-v[0-9]+.[0-9]+.[0-9]+"

jobs:
Expand Down Expand Up @@ -40,5 +35,5 @@ jobs:
run: |
tag="${{ github.ref_name }}"
body="Release $tag"
gh release create --draft "$tag" --title "$tag" --notes "$body" --generate-notes --prerelease
gh release create --draft "$tag" --title "$tag" --notes "$body" --generate-notes
gh release upload "${{ github.ref_name }}" packages/powersync/assets/powersync_db.worker.js
28 changes: 28 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Preparing Release

Bump the version of the packages to be released using `melos`:

```
melos version
```

if melos does not pick up changes or does not bump the version correctly, you can manually version the packages using

```
melos version -V ${PACKAGE_NAME}:M.M.P
for e.g melos version -V powersync:1.6.3
```

This will create a tag for all packages updated in the format of ${PACKAGE_NAME}-vM.M.P

```
e.g powersync-v1.6.4, powersync_attachments_helper-v0.6.3+1, etc.
```

# Perform Release

```
git push --follow-tags
```

A version bump and tag push for `powersync` will also create a draft github release for the powersync web worker. The worker needs to be manually published in the GitHub [releases](https://github.com/powersync-ja/powersync.dart/releases).
5 changes: 5 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ command:
changelog: false
packageFilters:
noPrivate: true
publish:
hooks:
pre: sh tool/download_binaries.sh
packageFilters:
noPrivate: true

scripts:
prepare:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ class PowerSyncOpenFactory extends AbstractPowerSyncOpenFactory {
case Abi.macosX64:
return 'libpowersync.dylib';
case Abi.linuxX64:
return 'libpowersync.so';
case Abi.windowsArm64:
return 'libpowersync_x64.so';
case Abi.linuxArm64:
return 'libpowersync_aarch64.so';
case Abi.windowsX64:
return 'powersync.dll';
return 'powersync_x64.dll';
case Abi.androidIA32:
throw PowersyncNotReadyException(
'Unsupported processor architecture. X86 Android emulators are not '
Expand Down
143 changes: 0 additions & 143 deletions packages/powersync/test/util.dart

This file was deleted.

2 changes: 1 addition & 1 deletion packages/powersync/test/utils/native_test_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class TestOpenFactory extends PowerSyncOpenFactory {
case Abi.macosX64:
return '$path/libpowersync.dylib';
case Abi.linuxX64:
case Abi.linuxArm64:
return '$path/libpowersync.so';
case Abi.windowsArm64:
case Abi.windowsX64:
return '$path/powersync.dll';
case Abi.androidIA32:
Expand Down
14 changes: 5 additions & 9 deletions packages/powersync_flutter_libs/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,19 @@ target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)

# ----------------------------------------------------------------------
# Download and add powersync prebuilt library.
# Add powersync prebuilt library.

set(POWERSYNC_VERSION 0.1.6)
set(CORE_FILE_NAME "libpowersync.so")

set(POWERSYNC_ARCH ${CMAKE_SYSTEM_PROCESSOR})
if (${POWERSYNC_ARCH} MATCHES "x86_64" OR ${POWERSYNC_ARCH} MATCHES "AMD64")
set(POWERSYNC_ARCH x64)
set(CORE_FILE_NAME "libpowersync_x64.so")
elseif (${POWERSYNC_ARCH} MATCHES "^arm64" OR ${POWERSYNC_ARCH} MATCHES "^armv8")
set(POWERSYNC_ARCH aarch64)
set(CORE_FILE_NAME "libpowersync_aarch64.so")
endif ()

set(POWERSYNC_FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libpowersync.so")

file(DOWNLOAD
"https://github.com/powersync-ja/powersync-sqlite-core/releases/download/v${POWERSYNC_VERSION}/libpowersync_${POWERSYNC_ARCH}.so"
${POWERSYNC_FILE_PATH}
)
set(POWERSYNC_FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${CORE_FILE_NAME}")

# ----------------------------------------------------------------------

Expand Down
17 changes: 6 additions & 11 deletions packages/powersync_flutter_libs/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,18 @@ target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)

# ----------------------------------------------------------------------
# Download and add powersync prebuilt library.

set(POWERSYNC_VERSION 0.1.6)
# Add powersync prebuilt library.

set(POWERSYNC_ARCH ${CMAKE_SYSTEM_PROCESSOR})
set(CORE_FILE_NAME "powersync.dll")

if (${POWERSYNC_ARCH} MATCHES "x86_64" OR ${POWERSYNC_ARCH} MATCHES "AMD64")
set(POWERSYNC_ARCH x64)
set(CORE_FILE_NAME "powersync_x64.dll")
elseif (${POWERSYNC_ARCH} MATCHES "^arm64" OR ${POWERSYNC_ARCH} MATCHES "^armv8")
set(POWERSYNC_ARCH aarch64)
message(FATAL_ERROR "Unsupported architecture: ${POWERSYNC_ARCH}, we are working on adding support for windows arm.")
endif ()

set(POWERSYNC_FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/powersync.dll")

file(DOWNLOAD
"https://github.com/powersync-ja/powersync-sqlite-core/releases/download/v${POWERSYNC_VERSION}/powersync_${POWERSYNC_ARCH}.dll"
${POWERSYNC_FILE_PATH}
)
set(POWERSYNC_FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/powersync_x64.dll")

# ----------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion scripts/init_powersync_core_binary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dart:io';
import 'package:melos/melos.dart';

final sqliteUrl =
'https://github.com/powersync-ja/powersync-sqlite-core/releases/download/v0.1.7';
'https://github.com/powersync-ja/powersync-sqlite-core/releases/download/v0.1.8';

void main() async {
final sqliteCoreFilename = getLibraryForPlatform();
Expand Down
12 changes: 12 additions & 0 deletions tool/download_binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

if [ -z "$CORE_VERSION" ]; then
echo "CORE_VERSION is not set";
exit 2;
fi

github="https://github.com/powersync-ja/powersync-sqlite-core/releases/download/$CORE_VERSION"

curl "${github}/libpowersync_aarch64.so" -o packages/powersync_flutter_libs/linux/libpowersync_aarch64.so --create-dirs -L -f
curl "${github}/libpowersync_x64.so" -o packages/powersync_flutter_libs/linux/libpowersync_x64.so --create-dirs -L -f
curl "${github}/powersync_x64.dll" -o packages/powersync_flutter_libs/windows/powersync_x64.dll --create-dirs -L -f
Loading