From 667ca6b657207f355beeb45f1ec6e001589e848f Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 7 May 2025 10:26:40 +0200 Subject: [PATCH 1/9] Simplify publishing for Swift SDK --- .github/workflows/deploy-swit.yml | 96 ++++++++++++++ .github/workflows/deploy.yml | 14 --- Package.swift | 25 ---- PowerSyncKotlin/build.gradle.kts | 200 ++++-------------------------- build.gradle.kts | 2 - gradle.properties | 4 - gradle/libs.versions.toml | 2 - 7 files changed, 118 insertions(+), 225 deletions(-) create mode 100644 .github/workflows/deploy-swit.yml delete mode 100644 Package.swift diff --git a/.github/workflows/deploy-swit.yml b/.github/workflows/deploy-swit.yml new file mode 100644 index 00000000..a8b1665f --- /dev/null +++ b/.github/workflows/deploy-swit.yml @@ -0,0 +1,96 @@ +name: Create Swift release + +on: + push: + # TODO Remove + branches: + - refactor-swift-release +# tags: +# - 'v[0-9]+.[0-9]+.[0-9]+SWIFT' + +jobs: + draft_release: + name: Create Draft Release on GitHub + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.tag.outputs.tag }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set tag name + id: tag + # TODO Remove, adding this for testing + run: | + tag="1.1.0+SWIFT" + echo "tag=$tag" >> $GITHUB_OUTPUT +# run: | +# tag=$(basename "${{ github.ref }}") +# echo "tag=$tag" >> $GITHUB_OUTPUT + - name: Create Release + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: | + tag="${{ steps.tag.outputs.tag }}" + body="Pending release for XCFramework, $tag" + gh release create --draft "$tag" --title "$tag" --notes "$body" + + build_xcframeworks: + name: Build XCFrameworks + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + - uses: actions/cache@v3 + with: + path: ~/.konan + key: ${{ runner.os }}-${{ hashFiles('**/.lock') }} + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + - name: Build frameworks + run: "./gradlew PowerSyncKotlin:buildRelease" + + - uses: actions/upload-artifact@v4 + with: + name: XCFramework + retention-days: 1 # Only used temporarily + compression-level: 0 # We're already uploading a compressed file + path: PowerSyncKotlin/build/FrameworkArchives/PowersyncKotlinRelease.zip + if-no-files-found: error + + add_assets: + needs: [draft_release, build_xcframeworks] + name: Add assets to pending release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/download-artifact@v4 + - name: Upload XCFramework + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: | + gh release upload "${{ needs.draft_release.outputs.tag }}" PowersyncKotlinRelease.zip + + - name: "Update checksum" + shell: zsh + run: | + checksums=$(sha256sum PowersyncKotlinRelease.zip) + cat > RELEASE_NOTES <<- NOTES_END + File hashes: + \`\`\` + $checksums + \`\`\` + NOTES_END + + gh release edit "${{ needs.draft_release.outputs.tag }}" -F RELEASE_NOTES diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index df3d892b..7c69bc15 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -38,17 +38,3 @@ jobs: -Ppowersync.binaries.allPlatforms="true" \ publishAllPublicationsToSonatypeRepository shell: bash - # This will change Package.swift in Github packages to direct to new maven central KMMBridge zip file - call-kmmbridge-publish: - needs: deploy - permissions: - contents: write - packages: write - uses: touchlab/KMMBridgeGithubWorkflow/.github/workflows/faktorybuildautoversion.yml@v1.2 - with: - jvmVersion: 17 - versionBaseProperty: SWIFT_LIBRARY_VERSION - publishTask: kmmBridgePublish - secrets: - gradle_params: -PsigningInMemoryKey="${{ secrets.SIGNING_KEY }}" -PsigningInMemoryKeyId="${{ secrets.SIGNING_KEY_ID }}" -PsigningInMemoryKeyPassword="${{ secrets.SIGNING_PASSWORD }}" - diff --git a/Package.swift b/Package.swift deleted file mode 100644 index ace85123..00000000 --- a/Package.swift +++ /dev/null @@ -1,25 +0,0 @@ -// swift-tools-version:5.3 -import PackageDescription - -let packageName = "PowerSyncKotlin" - -let package = Package( - name: packageName, - platforms: [ - .iOS(.v13), - .macOS(.v10_15) - ], - products: [ - .library( - name: packageName, - targets: [packageName] - ), - ], - targets: [ - .binaryTarget( - name: packageName, - path: "./PowerSyncKotlin/build/XCFrameworks/debug/\(packageName).xcframework" - ) - , - ] -) \ No newline at end of file diff --git a/PowerSyncKotlin/build.gradle.kts b/PowerSyncKotlin/build.gradle.kts index 24cb4ca3..797c14c2 100644 --- a/PowerSyncKotlin/build.gradle.kts +++ b/PowerSyncKotlin/build.gradle.kts @@ -1,19 +1,15 @@ -import co.touchlab.faktory.KmmBridgeExtension -import co.touchlab.faktory.artifactmanager.ArtifactManager -import co.touchlab.faktory.capitalized import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget -import java.security.MessageDigest +import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework plugins { alias(libs.plugins.kotlinMultiplatform) - alias(libs.plugins.kmmbridge) alias(libs.plugins.skie) - alias(libs.plugins.mavenPublishPlugin) alias(libs.plugins.kotlinter) - id("com.powersync.plugins.sonatype") } kotlin { + val xcf = XCFramework() + listOf( iosX64(), iosArm64(), @@ -22,8 +18,14 @@ kotlin { macosX64(), ).forEach { it.binaries.framework { + baseName = "PowerSyncKotlin" + xcf.add(this) + export(project(":core")) isStatic = true + + binaryOption("bundleId", "PowerSyncKotlin") + binaryOption("bundleVersion", project.version.toString()) } } @@ -64,180 +66,22 @@ configurations.all { } } -kmmbridge { - artifactManager.set(SonatypePortalPublishArtifactManager(project, repositoryName = null)) - artifactManager.finalizeValue() - spm() -} - -// We need this so that when a user includes the package in XCode they are able to -// import the package using Github -if (System.getenv().containsKey("CI")) { - // Setup github publishing based on GitHub action variables - addGithubPackagesRepository() -} - -// This is required for KMMBridge zip to be uploaded to Sonatype (Maven Central) -// Since this will only ever be used in this build file it does not make sense to make a -// plugin to use this. -class SonatypePortalPublishArtifactManager( - val project: Project, - private val publicationName: String = "KMMBridgeFramework", - artifactSuffix: String = "kmmbridge", - private val repositoryName: String? -) : ArtifactManager { - private val group: String = project.group.toString().replace(".", "/") - private val kmmbridgeArtifactId = - "${project.name}-$artifactSuffix" - private val zipName = "powersync-$artifactSuffix" - private val LIBRARY_VERSION: String by project - - // This is the URL that will be added to Package.swift in Github package so that - // KMMBridge is downloaded when a user includes the package in XCode - private val MAVEN_CENTRAL_PACKAGE_ZIP_URL = "https://repo1.maven.org/maven2/com/powersync/${zipName}/${LIBRARY_VERSION}/${zipName}-${LIBRARY_VERSION}.zip" - - override fun deployArtifact( - project: Project, - zipFilePath: File, - version: String - ): String = MAVEN_CENTRAL_PACKAGE_ZIP_URL - - override fun configure( - project: Project, - version: String, - uploadTask: TaskProvider, - kmmPublishTask: TaskProvider - ) { - val zipXCFramework = project.tasks.named("zipXCFramework") - zipXCFramework.configure { - // KMMBridge uses the Gradle Zip tasks to create XCFramework archives, but Gradle - // doesn't support symlinks. XCFrameworks for macOS need to use symlinks though, so we - // patch the task to generate zip files properly. - doLast { - val bridge = project.extensions.getByName("kmmbridge") - val source = project.layout.buildDirectory.map { it.dir("XCFrameworks/${bridge.buildType.get().name}") }.get().asFile - - val out = archiveFile.get().asFile - out.delete() +listOf("Debug", "Release").forEach { buildType -> + tasks.register("build$buildType") { + group = "build" + description = "Create an XCFramework archive for $buildType" - providers.exec { - executable = "zip" - args("-r", "--symlinks", out.absolutePath, "PowerSyncKotlin.xcframework") - workingDir(source) - }.result.get().assertNormalExitValue() - } - } - - project.extensions.getByType().publications.create( - publicationName, - MavenPublication::class.java, - ) { - this.version = version - val archiveProvider = zipXCFramework.flatMap { - it.archiveFile - } - artifact(archiveProvider) { - extension = "zip" - } - artifactId = kmmbridgeArtifactId - } - - // Register the task - project.tasks.register("updatePackageSwiftChecksum") { - artifactId.set(kmmbridgeArtifactId) - zipUrl.set(MAVEN_CENTRAL_PACKAGE_ZIP_URL) - dependsOn("updatePackageSwift") - } - - // Make sure this task runs after updatePackageSwift - project.tasks.named("kmmBridgePublish") { - dependsOn("updatePackageSwiftChecksum") - } + val originalFramework = tasks.getByName("assemblePowerSyncKotlin${buildType}XCFramework") + dependsOn(originalFramework) - publishingTasks().forEach { - uploadTask.configure { - dependsOn(it) - } - } - try { - project.tasks.named("publish").also { task -> - task.configure { - dependsOn(kmmPublishTask) - } - } - } catch (_: UnknownTaskException) { - project.logger.warn("Gradle publish task not found") - } - } - - private fun publishingTasks(): List> { - val publishingExtension = project.extensions.getByType() - - // Either the user has supplied a correct name, or we use the default. If neither is found, fail. - val publicationNameCap = - publishingExtension.publications - .getByName( - publicationName, - ).name - .capitalized() - - return publishingExtension.repositories - .filterIsInstance() - .map { repo -> - val repositoryName = repo.name.capitalized() - val publishTaskName = - "publish${publicationNameCap}PublicationTo${repositoryName}Repository" - // Verify that the "publish" task exists before collecting - project.tasks.named(publishTaskName) - } - } -} - -// This task is used to update Package.swift with the checksum of the zip file -// located on maven central. -abstract class UpdatePackageSwiftChecksumTask : DefaultTask() { - @get:Input - abstract val artifactId: Property - - @get:Input - abstract val zipUrl: Property - - @TaskAction - fun updateChecksum() { - val LIBRARY_VERSION: String by project - - val zipFile = project.file("${project.layout.buildDirectory.get()}/tmp/${artifactId.get().lowercase()}-$LIBRARY_VERSION.zip") - - // Download the zip file - zipFile.parentFile.mkdirs() - project.uri(zipUrl.get()).toURL().openStream().use { input -> - zipFile.outputStream().use { output -> - input.copyTo(output) - } - } - - // Compute the checksum - val checksum = - zipFile.inputStream().use { input -> - val digest = MessageDigest.getInstance("SHA-256") - val buffer = ByteArray(8192) - var bytes = input.read(buffer) - while (bytes >= 0) { - digest.update(buffer, 0, bytes) - bytes = input.read(buffer) - } - digest.digest().joinToString("") { "%02x".format(it) } - } + val source = project.layout.buildDirectory.map { it.dir("XCFrameworks/${buildType.lowercase()}") }.get().asFile + val archiveFile = project.layout.buildDirectory.map { it.file("FrameworkArchives/PowersyncKotlin$buildType.zip") }.get().asFile - // Update Package.swift - val packageSwiftFile = project.rootProject.file("Package.swift") - val updatedContent = - packageSwiftFile.readText().replace( - Regex("let remoteKotlinChecksum = \"[a-f0-9]+\""), - "let remoteKotlinChecksum = \"$checksum\"", - ) - packageSwiftFile.writeText(updatedContent) + archiveFile.parentFile.mkdirs() + archiveFile.delete() - println("Updated Package.swift with new checksum: $checksum") + executable = "zip" + args("-r", "--symlinks", archiveFile.absolutePath, "PowerSyncKotlin.xcframework") + workingDir(source) } } diff --git a/build.gradle.kts b/build.gradle.kts index 17e391ee..b8bff3d1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,8 +10,6 @@ plugins { alias(libs.plugins.androidApplication) apply false alias(libs.plugins.androidLibrary) apply false alias(libs.plugins.kotlinMultiplatform) apply false - alias(libs.plugins.cocoapods) apply false - alias(libs.plugins.kmmbridge) apply false alias(libs.plugins.skie) apply false alias(libs.plugins.kotlin.jvm) apply false alias(libs.plugins.kotlin.android) apply false diff --git a/gradle.properties b/gradle.properties index 03fe5a6e..47dddbbe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,10 +18,6 @@ RELEASE_SIGNING_ENABLED=true # Library config GROUP=com.powersync LIBRARY_VERSION=1.1.0 -# The Swift KMM bridge artifacts are published to SPM via a unique tag version -# The version is the same as the LIBRARY_VERSION, but with a suffix of +SWIFT -# Please update this when updating the LIBRARY_VERSION -SWIFT_LIBRARY_VERSION=1.1.0+SWIFT GITHUB_REPO=https://github.com/powersync-ja/powersync-kotlin.git # POM POM_URL=https://github.com/powersync-ja/powersync-kotlin/ diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a617db08..ef5207fe 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -34,7 +34,6 @@ androidxSqlite = "2.4.0" # plugins android-gradle-plugin = "8.9.0" -kmmBridge = "0.5.7" skie = "0.10.1" maven-publish = "0.27.0" download-plugin = "5.5.0" @@ -125,7 +124,6 @@ kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } skie = { id = "co.touchlab.skie", version.ref = "skie" } -kmmbridge = { id = "co.touchlab.kmmbridge", version.ref = "kmmBridge" } sqldelight = { id = "app.cash.sqldelight", version.ref = "sqlDelight" } grammarKitComposer = { id = "com.alecstrong.grammar.kit.composer", version.ref = "grammarkit-composer" } mavenPublishPlugin = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" } From 9fe1906ceebd0b328b086b768dfd753a346139a9 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 7 May 2025 10:30:00 +0200 Subject: [PATCH 2/9] Add write permission --- .github/workflows/deploy-swit.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/deploy-swit.yml b/.github/workflows/deploy-swit.yml index a8b1665f..763d4a9f 100644 --- a/.github/workflows/deploy-swit.yml +++ b/.github/workflows/deploy-swit.yml @@ -10,6 +10,8 @@ on: jobs: draft_release: + permissions: + contents: write name: Create Draft Release on GitHub runs-on: ubuntu-latest outputs: @@ -67,6 +69,8 @@ jobs: if-no-files-found: error add_assets: + permissions: + contents: write needs: [draft_release, build_xcframeworks] name: Add assets to pending release runs-on: ubuntu-latest From 43b31a1eea7745011aba30e1f6c68d158655e237 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 7 May 2025 10:51:47 +0200 Subject: [PATCH 3/9] Set merge-multiple --- .github/workflows/deploy-swit.yml | 5 +- .github/workflows/deploy.yml | 99 ++++++++++++++++++++++++++++--- 2 files changed, 95 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy-swit.yml b/.github/workflows/deploy-swit.yml index 763d4a9f..c5b5771d 100644 --- a/.github/workflows/deploy-swit.yml +++ b/.github/workflows/deploy-swit.yml @@ -79,6 +79,9 @@ jobs: with: fetch-depth: 0 - uses: actions/download-artifact@v4 + with: + merge-multiple: true + - run: "ls -al" - name: Upload XCFramework env: GH_TOKEN: ${{ github.token }} @@ -86,7 +89,7 @@ jobs: run: | gh release upload "${{ needs.draft_release.outputs.tag }}" PowersyncKotlinRelease.zip - - name: "Update checksum" + - name: "Update release description" shell: zsh run: | checksums=$(sha256sum PowersyncKotlinRelease.zip) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7c69bc15..6697c99d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,15 +1,35 @@ -name: Deploy to Sonatype +name: Release on: workflow_dispatch -permissions: - contents: read - jobs: - test: - uses: ./.github/workflows/test.yml - deploy: - needs: [test] + draft_release: + permissions: + contents: write + name: Create Draft Release on GitHub + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.tag.outputs.tag }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set tag name + id: tag + run: | + tag=$(basename "${{ github.ref }}") + echo "tag=$tag" >> $GITHUB_OUTPUT + - name: Create Release + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: | + tag="${{ steps.tag.outputs.tag }}" + body="Pending release for XCFramework, $tag" + gh release create --draft "$tag" --title "$tag" --notes "$body" + + maven_publish: runs-on: macos-latest steps: - uses: actions/checkout@v4 @@ -38,3 +58,66 @@ jobs: -Ppowersync.binaries.allPlatforms="true" \ publishAllPublicationsToSonatypeRepository shell: bash + + build_xcframeworks: + name: Build XCFrameworks + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + - uses: actions/cache@v3 + with: + path: ~/.konan + key: ${{ runner.os }}-${{ hashFiles('**/.lock') }} + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + - name: Build frameworks + run: "./gradlew PowerSyncKotlin:buildRelease" + + - uses: actions/upload-artifact@v4 + with: + name: XCFramework + retention-days: 1 # Only used temporarily + compression-level: 0 # We're already uploading a compressed file + path: PowerSyncKotlin/build/FrameworkArchives/PowersyncKotlinRelease.zip + if-no-files-found: error + + add_assets: + permissions: + contents: write + needs: [draft_release, build_xcframeworks] + name: Add assets to pending release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/download-artifact@v4 + with: + merge-multiple: true + - run: "ls -al" + - name: Upload XCFramework + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: | + gh release upload "${{ needs.draft_release.outputs.tag }}" PowersyncKotlinRelease.zip + + - name: "Update release description" + shell: zsh + run: | + checksums=$(sha256sum PowersyncKotlinRelease.zip) + cat > RELEASE_NOTES <<- NOTES_END + File hashes: + \`\`\` + $checksums + \`\`\` + NOTES_END + + gh release edit "${{ needs.draft_release.outputs.tag }}" -F RELEASE_NOTES From 62630e610b128cc7df168b29ca345d55052290f6 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 7 May 2025 10:55:35 +0200 Subject: [PATCH 4/9] Upload release instructions --- docs/Release.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/Release.md b/docs/Release.md index 958848d9..14379796 100644 --- a/docs/Release.md +++ b/docs/Release.md @@ -2,7 +2,15 @@ ## How to make a release -1. Update `LIBRARY_VERSION` and `SWIFT_LIBRARY_VERSION` in `gradle.properties` in the root. +1. Update `LIBRARY_VERSION` in `gradle.properties` in the root. 2. Add an entry to the `CHANGELOG.md`. 3. Make a PR and merge it. -4. Once the PR is merged and in the `main` branch then manually run the Github action `Deploy to Sonatype`. This will create a release to Maven Central and will also update the version of the `powersync-kotlin` SPM package used in the Swift SDK. If the release contains changes pertaining to the Swift SDK you will need to update the `powersync-kotlin` SPM package version in that repo and make a release there as well. +4. Pull `main` (which now contains your merged PR) and create a tag matching the version, e.g. + `git tag v1.1.0`. +5. Push that tag and manually trigger the GitHub action `Release` on that tag. This will: + - Create a release to Maven Central. + - Create a draft release on Github. + - Attach a prebuild `XCFramework` zip-archive for the Swift SDK to the draft release. +6. Copy relevant entries from the changelog into the draft release and make it public! +7. To apply this release to the Swift SDK, update the `Package.swift` file to point at the framework + from that release. You can copy the SHA256 hashsum from the generated draft release notes. From 388bef3f528983ae9a246bbcc0ab998ad861379a Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 7 May 2025 11:10:06 +0200 Subject: [PATCH 5/9] Fix shell to change release notes --- .github/workflows/deploy-swit.yml | 2 +- .github/workflows/deploy.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-swit.yml b/.github/workflows/deploy-swit.yml index c5b5771d..8c7c4f8a 100644 --- a/.github/workflows/deploy-swit.yml +++ b/.github/workflows/deploy-swit.yml @@ -90,7 +90,7 @@ jobs: gh release upload "${{ needs.draft_release.outputs.tag }}" PowersyncKotlinRelease.zip - name: "Update release description" - shell: zsh + shell: bash run: | checksums=$(sha256sum PowersyncKotlinRelease.zip) cat > RELEASE_NOTES <<- NOTES_END diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6697c99d..d49498b6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -110,7 +110,7 @@ jobs: gh release upload "${{ needs.draft_release.outputs.tag }}" PowersyncKotlinRelease.zip - name: "Update release description" - shell: zsh + shell: bash run: | checksums=$(sha256sum PowersyncKotlinRelease.zip) cat > RELEASE_NOTES <<- NOTES_END From 9826184f6ec8dac6ab86b03cd4859bee9521e66e Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 7 May 2025 11:45:00 +0200 Subject: [PATCH 6/9] Use token --- .github/workflows/deploy-swit.yml | 3 +++ .github/workflows/deploy.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/deploy-swit.yml b/.github/workflows/deploy-swit.yml index 8c7c4f8a..5ce95156 100644 --- a/.github/workflows/deploy-swit.yml +++ b/.github/workflows/deploy-swit.yml @@ -90,6 +90,9 @@ jobs: gh release upload "${{ needs.draft_release.outputs.tag }}" PowersyncKotlinRelease.zip - name: "Update release description" + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} shell: bash run: | checksums=$(sha256sum PowersyncKotlinRelease.zip) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d49498b6..88071bb5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -110,6 +110,9 @@ jobs: gh release upload "${{ needs.draft_release.outputs.tag }}" PowersyncKotlinRelease.zip - name: "Update release description" + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} shell: bash run: | checksums=$(sha256sum PowersyncKotlinRelease.zip) From 2edc6cbf7c2af56bf5187615effa409090c5a4e8 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 7 May 2025 12:49:28 +0200 Subject: [PATCH 7/9] Move into regular builds --- .github/workflows/deploy-swit.yml | 106 ------------------------------ .github/workflows/deploy.yml | 2 +- 2 files changed, 1 insertion(+), 107 deletions(-) delete mode 100644 .github/workflows/deploy-swit.yml diff --git a/.github/workflows/deploy-swit.yml b/.github/workflows/deploy-swit.yml deleted file mode 100644 index 5ce95156..00000000 --- a/.github/workflows/deploy-swit.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: Create Swift release - -on: - push: - # TODO Remove - branches: - - refactor-swift-release -# tags: -# - 'v[0-9]+.[0-9]+.[0-9]+SWIFT' - -jobs: - draft_release: - permissions: - contents: write - name: Create Draft Release on GitHub - runs-on: ubuntu-latest - outputs: - tag: ${{ steps.tag.outputs.tag }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set tag name - id: tag - # TODO Remove, adding this for testing - run: | - tag="1.1.0+SWIFT" - echo "tag=$tag" >> $GITHUB_OUTPUT -# run: | -# tag=$(basename "${{ github.ref }}") -# echo "tag=$tag" >> $GITHUB_OUTPUT - - name: Create Release - env: - GH_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - run: | - tag="${{ steps.tag.outputs.tag }}" - body="Pending release for XCFramework, $tag" - gh release create --draft "$tag" --title "$tag" --notes "$body" - - build_xcframeworks: - name: Build XCFrameworks - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v1 - - uses: actions/cache@v3 - with: - path: ~/.konan - key: ${{ runner.os }}-${{ hashFiles('**/.lock') }} - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: Set up Gradle - uses: gradle/actions/setup-gradle@v4 - - name: Build frameworks - run: "./gradlew PowerSyncKotlin:buildRelease" - - - uses: actions/upload-artifact@v4 - with: - name: XCFramework - retention-days: 1 # Only used temporarily - compression-level: 0 # We're already uploading a compressed file - path: PowerSyncKotlin/build/FrameworkArchives/PowersyncKotlinRelease.zip - if-no-files-found: error - - add_assets: - permissions: - contents: write - needs: [draft_release, build_xcframeworks] - name: Add assets to pending release - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/download-artifact@v4 - with: - merge-multiple: true - - run: "ls -al" - - name: Upload XCFramework - env: - GH_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - run: | - gh release upload "${{ needs.draft_release.outputs.tag }}" PowersyncKotlinRelease.zip - - - name: "Update release description" - env: - GH_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - shell: bash - run: | - checksums=$(sha256sum PowersyncKotlinRelease.zip) - cat > RELEASE_NOTES <<- NOTES_END - File hashes: - \`\`\` - $checksums - \`\`\` - NOTES_END - - gh release edit "${{ needs.draft_release.outputs.tag }}" -F RELEASE_NOTES diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 88071bb5..122556ca 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,7 +27,7 @@ jobs: run: | tag="${{ steps.tag.outputs.tag }}" body="Pending release for XCFramework, $tag" - gh release create --draft "$tag" --title "$tag" --notes "$body" + gh release create --draft "$tag" --title "$tag" --notes "$body" maven_publish: runs-on: macos-latest From 56730d84ba86f39252d14e491b8cc4c6f0aef699 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 7 May 2025 12:55:14 +0200 Subject: [PATCH 8/9] Typo --- docs/Release.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Release.md b/docs/Release.md index 14379796..bd59291d 100644 --- a/docs/Release.md +++ b/docs/Release.md @@ -10,7 +10,7 @@ 5. Push that tag and manually trigger the GitHub action `Release` on that tag. This will: - Create a release to Maven Central. - Create a draft release on Github. - - Attach a prebuild `XCFramework` zip-archive for the Swift SDK to the draft release. + - Build and attach an `XCFramework` zip archive for the Swift SDK to the draft release. 6. Copy relevant entries from the changelog into the draft release and make it public! 7. To apply this release to the Swift SDK, update the `Package.swift` file to point at the framework from that release. You can copy the SHA256 hashsum from the generated draft release notes. From c9b8184072c22b7388efb6480864f6bae4d25619 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 7 May 2025 14:09:33 +0200 Subject: [PATCH 9/9] Add Package.swift --- PowerSyncKotlin/Package.swift | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 PowerSyncKotlin/Package.swift diff --git a/PowerSyncKotlin/Package.swift b/PowerSyncKotlin/Package.swift new file mode 100644 index 00000000..e387a08b --- /dev/null +++ b/PowerSyncKotlin/Package.swift @@ -0,0 +1,25 @@ +// swift-tools-version: 5.7 + +// NOTE! This is never released, we're only using this to support local Kotlin SDK builds for the +// Swift SDK. +import PackageDescription +let packageName = "PowerSyncKotlin" + +let package = Package( + name: packageName, + platforms: [ + .iOS(.v13), + .macOS(.v10_15) + ], + products: [ + .library( + name: packageName, + targets: [packageName]), + ], + targets: [ + .binaryTarget( + name: packageName, + path: "build/XCFrameworks/debug/PowerSyncKotlin.xcframework" + ) + ] +)