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
33 changes: 18 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,32 @@ jobs:
with:
artifact-ids: ${{ needs.fetch_prebuilts.outputs.artifact_id }}
path: internal/prebuild-binaries/build/output/
- name: Gradle publish
- name: Generate publications
run: |
./gradlew \
--no-configuration-cache \
-PhasPrebuiltAssets=true \
-PsigningInMemoryKey="${{ secrets.SIGNING_KEY }}" \
-PsigningInMemoryKeyId="${{ secrets.SIGNING_KEY_ID }}" \
-PsigningInMemoryKeyPassword="${{ secrets.SIGNING_PASSWORD }}" \
-PcentralPortal.username="${{secrets.SONATYPE_USERNAME}}" \
-PcentralPortal.password="${{secrets.SONATYPE_PASSWORD}}" \
-Ppowersync.binaries.allPlatforms="true" \
publishAllPublicationsToSonatypeLocalRepository
generatePublishingBundle

./gradlew \
--no-configuration-cache \
-PhasPrebuiltAssets=true \
-PsigningInMemoryKey="${{ secrets.SIGNING_KEY }}" \
-PsigningInMemoryKeyId="${{ secrets.SIGNING_KEY_ID }}" \
-PsigningInMemoryKeyPassword="${{ secrets.SIGNING_PASSWORD }}" \
-PcentralPortal.username="${{secrets.SONATYPE_USERNAME}}" \
-PcentralPortal.password="${{secrets.SONATYPE_PASSWORD}}" \
-Ppowersync.binaries.allPlatforms="true" \
publishAllPublicationsToSonatypeRepository
shell: bash
- name: Inspect publication
run: |
./internal/analyze-bundle.py
zip -r build/sonatypeBundle.zip build/sonatypeBundle/

- name: Upload to Maven Central
env:
# printf "$SONATYPE_USERNAME:$SONATYPE_PASSWORD" | base64
SONATYPE_CREDENTIALS: ${{ secrets.SONATYPE_CREDENTIALS }}
run: |
tag=$(basename "${{ github.ref }}")
curl --fail-with-body --request POST \
--header "Authorization: Bearer $SONATYPE_CREDENTIALS" \
--form bundle=@build/sonatypeBundle.zip \
"https://central.sonatype.com/api/v1/publisher/upload?name=$tag&publishingType=AUTOMATIC"

add_assets:
permissions:
Expand Down Expand Up @@ -108,3 +110,4 @@ jobs:
GH_REPO: ${{ github.repository }}
run: |
gh release upload "${{ needs.draft_release.outputs.tag }}" prebuilt_libraries.zip

3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ jobs:
- name: Set up XCode
if: runner.os == 'macOS'
uses: maxim-lobanov/setup-xcode@v1
with:
# TODO: Update to latest-stable once GH installs iOS 26 simulators
xcode-version: '^16.4.0'
- name: Download prebuilts
uses: actions/download-artifact@v8
with:
Expand Down
47 changes: 40 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.powersync.plugins.sonatype.SonatypeCentralUploadPlugin

import com.sun.net.httpserver.HttpExchange
import com.sun.net.httpserver.HttpServer
import java.net.InetSocketAddress
Expand All @@ -21,21 +23,29 @@ plugins {
alias(libs.plugins.androidx.room) apply false
id("org.jetbrains.dokka") version libs.versions.dokkaBase
id("dokka-convention")
id("com.powersync.plugins.sonatype") apply false
}

tasks.getByName<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}

val sonatypePublishingBundleConfiguration by configurations.creating {
isCanBeConsumed = false
}

// Merges individual module docs into a single HTML output
dependencies {
dokka(projects.common)
dokka(projects.core)
dokka(projects.compose)
dokka(projects.integrations.room)
dokka(projects.integrations.sqldelight)
dokka(projects.integrations.supabase)
dokka(projects.sqlite3multipleciphers)
// Internal published projects we don't include in the Dokka overview.
val undocumentedProjects = listOf(":static-sqlite-driver", ":internal:sqlite3mcandroid")

for (projectPath in SonatypeCentralUploadPlugin.publishedProjects) {
if (!undocumentedProjects.contains(projectPath)) {
dokka(project(path=projectPath))
}

sonatypePublishingBundleConfiguration(project(path=projectPath, configuration="sonatypePublishingBundleConfiguration"))
}
}

dokka {
Expand Down Expand Up @@ -100,3 +110,26 @@ tasks.register("serveDokka") {
Thread.currentThread().join()
}
}

val generatePublishingBundle by tasks.registering(Copy::class) {
group = "publishing"

val subprojects: FileCollection = sonatypePublishingBundleConfiguration
inputs.files(subprojects)

from(subprojects.files.toTypedArray()) {
exclude { fileTreeElement ->
val name = fileTreeElement.relativePath.lastName
// Skip some files: We don't need to upload maven metadata as Sonatype generates
// those files for us. There's no way to disable sha512 hashes in Gradle (and it
// insists on hashing signatures), we don't need those files either.
name.startsWith("maven-metadata") ||
name.endsWith(".sha512") ||
name.endsWith(".asc.md5") ||
name.endsWith(".asc.sha1") ||
name.endsWith(".asc.sha256") ||
name.endsWith(".asc.sha512")
}
}
into(layout.buildDirectory.dir("sonatypeBundle").get())
}
73 changes: 73 additions & 0 deletions internal/analyze-bundle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env python3
"""Analyze a sonatypeBundle directory and report size breakdown."""

import os
import sys
from collections import defaultdict
from pathlib import Path


def human(size: int) -> str:
for unit in ("B", "KB", "MB", "GB"):
if size < 1024:
return f"{size:.1f} {unit}"
size /= 1024
return f"{size:.1f} TB"


def classify(name: str) -> str:
if name.endswith("-javadoc.jar"):
return "javadoc jar"
if name.endswith("-sources.jar"):
return "sources jar"
if name.endswith(".klib"):
return ".klib"
if name.endswith(".aar"):
return ".aar"
if name.endswith(".jar"):
return ".jar"
if name.endswith(".pom"):
return ".pom"
if name.endswith(".module"):
return ".module"
if name.endswith(".asc"):
return ".asc signature"
for ext in (".sha512", ".sha256", ".sha1", ".md5"):
if name.endswith(ext):
return "checksum"
return "other"


def main(bundle_dir: str) -> None:
root = Path(bundle_dir)
if not root.is_dir():
print(f"error: {bundle_dir} is not a directory", file=sys.stderr)
sys.exit(1)

files: list[tuple[int, Path]] = []
by_type: dict[str, int] = defaultdict(int)
by_type_count: dict[str, int] = defaultdict(int)

for path in root.rglob("*"):
if not path.is_file():
continue
size = path.stat().st_size
files.append((size, path))

kind = classify(path.name)
by_type[kind] += size
by_type_count[kind] += 1

total = sum(s for s, _ in files)
print(f"Total: {human(total)} ({len(files)} files)\n")

# --- By file type ---
print("By file type:")
print(f" {'Type':<20} {'Size':>10} {'Count':>6}")
print(f" {'-'*20} {'-'*10} {'-'*6}")
for kind, size in sorted(by_type.items(), key=lambda x: -x[1]):
print(f" {kind:<20} {human(size):>10} {by_type_count[kind]:>6}")

if __name__ == "__main__":
target = sys.argv[1] if len(sys.argv) > 1 else "build/sonatypeBundle"
main(target)

This file was deleted.

Loading
Loading