Skip to content

Add KMP protobuf publishing with Wire#924

Merged
jamesarich merged 10 commits into
masterfrom
jamesarich/kmp-proto-library
May 30, 2026
Merged

Add KMP protobuf publishing with Wire#924
jamesarich merged 10 commits into
masterfrom
jamesarich/kmp-proto-library

Conversation

@jamesarich

@jamesarich jamesarich commented May 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a Kotlin Multiplatform library (packages/kmp/) that generates and publishes Wire models from the protobuf schema in this repo. Provides a single "source of truth" artifact for downstream KMP consumers.

graph TD
    repo[protobufs repo] -->|publishes| artifact["org.meshtastic:protobufs<br/>(KMP)"]
    artifact --> takpacket[takpacket-sdk]
    artifact --> sdk[meshtastic-sdk]
    artifact --> android[Meshtastic-Android]
    artifact --> other[Other KMP/JVM consumers]
    takpacket --> android
Loading

Published coordinates

implementation("org.meshtastic:protobufs:<version>")

Platform artifacts resolved automatically by Gradle:

  • protobufs-android
  • protobufs-jvm
  • protobufs-iosx64 / protobufs-iosarm64 / protobufs-iossimulatorarm64

Snapshots

Snapshots (published from master) live in the Central Portal snapshots repository, not the main Maven Central CDN. Consumers must add it explicitly:

repositories {
    mavenCentral()
    maven("https://central.sonatype.com/repository/maven-snapshots/")
}

implementation("org.meshtastic:protobufs:2.7.24-SNAPSHOT")

Versioning

Version is derived entirely from git tags — no file to maintain:

Context Version
Tag push (v2.7.23) 2.7.23
Snapshot (master push) 2.7.24-SNAPSHOT
Local dev (no flag) auto-SNAPSHOT from git describe

Stack

  • Kotlin 2.3.21 (Multiplatform)
  • Wire 6.4.0 — Square's protobuf library (boxOneOfsMinSize=5000, makeImmutableCopies=false)
  • AGP 9.2.1 (com.android.kotlin.multiplatform.library)
  • Gradle 9.5.1
  • vanniktech maven-publish 0.36.0 (automaticRelease, conditional signing)

CI Workflows

  • kmp-pull-request.yml — build validation on PRs
  • publish-kmp.yml — tag-triggered release to Maven Central
  • snapshot-kmp.yml — SNAPSHOT on master push (proto/kmp path filter)

Publishing alignment

Matches conventions from takpacket-sdk / mqttastic-client-kmp:

  • publishToMavenCentral(automaticRelease = true)
  • Inline POM block (license, SCM, developers)
  • Conditional signing (signingInMemoryKey.isPresent)
  • Secret names: MAVEN_CENTRAL_USERNAME / MAVEN_CENTRAL_PASSWORD / MAVEN_SIGNING_KEY
  • Snapshot version computed from latest tag (patch + 1)

Licensing

GPLv3 is declared at three layers:

  • POM <licenses> block (name, URL, distribution)
  • Repo root LICENSE bundled into all JARs via tasks.withType<Jar>
  • GitHub repo license detection (GPL-3.0)

Downstream consumers

@github-actions

github-actions Bot commented May 26, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow pull-request / build (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMay 30, 2026, 4:47 PM

jamesarich and others added 8 commits May 29, 2026 10:06
Kotlin Multiplatform library (Android, JVM, iOS) generated from the
proto schema using Square Wire. Includes:

- packages/kmp/ build with Wire plugin, maven-publish, and signing
- CI workflow for PR validation (kmp-pull-request.yml)
- CI workflow for tagged release publishing (publish-kmp.yml)
- CI workflow for SNAPSHOT publishing on master push (snapshot-kmp.yml)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
These two options are required for ABI compatibility with all existing
consumers (Meshtastic-Android, TAKPacket-SDK):

- boxOneOfsMinSize = 5000: flattens oneof fields to nullable properties
  on the parent class instead of sealed-class wrappers
- makeImmutableCopies = false: skips defensive copies of repeated/map
  fields on decode for better performance

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add publishToMavenCentral(automaticRelease = true) for auto-promotion
- Add inline POM block (name, description, license, scm, developers)
- Add VERSION_NAME to gradle.properties; workflows use -PVERSION_NAME
- Compute snapshot version as major.minor.(patch+1)-SNAPSHOT
- Align CI secret names with org conventions (OSSRH_USERNAME/PASSWORD)
- Add org.gradle.caching=true and org.gradle.parallel=true
- Remove redundant POM_* properties from gradle.properties

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
VERSION_NAME in gradle.properties tracks the current proto version.
Snapshots publish as major.minor.(patch+1)-SNAPSHOT (e.g. 2.7.24-SNAPSHOT).
Updated README with versioning docs and corrected publish commands.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove VERSION_NAME from gradle.properties. Version is now computed:
- CI release: tag name stripped of 'v' prefix, passed via -PVERSION_NAME
- CI snapshot: git describe + patch bump, computed in workflow
- Local dev: git describe fallback in build.gradle.kts (auto-SNAPSHOT)
- Override: -PVERSION_NAME=x.y.z always wins

No file to keep in sync — tagging a release is the only action needed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds LICENSE as a commonMain resource so it is included in all
platform JARs/klibs alongside the POM license declaration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace static copy with tasks.withType<Jar> { from(...) } that reads
the repo root LICENSE at packaging time. No file duplication needed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Kotlin Multiplatform package under packages/kmp/ that generates Wire Kotlin models from the protobuf schema in this repo and publishes them as a KMP library for downstream consumers (Android/JVM/iOS), along with CI workflows to validate and publish the artifacts.

Changes:

  • Introduce a new Gradle-based KMP/Wire build (packages/kmp) with Maven Central publishing configuration.
  • Add GitHub Actions workflows for PR validation, tag-based releases, and master-branch snapshot publishing.
  • Update repo documentation and ignore rules to account for the new package.

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Documents the newly added generated client packages, including the new KMP/Wire package.
.gitignore Ignores Gradle and build outputs for the new packages/kmp project.
packages/kmp/settings.gradle.kts Configures plugin and dependency repositories for the standalone KMP build.
packages/kmp/README.md Documents usage, versioning, and publishing commands for the KMP artifact.
packages/kmp/build.gradle.kts Defines KMP targets, Wire generation, version derivation, and Maven Central publishing.
packages/kmp/gradle.properties Sets Gradle/Kotlin build properties and publishing coordinates (GROUP/artifact ID).
packages/kmp/gradlew Adds Gradle wrapper script for POSIX.
packages/kmp/gradlew.bat Adds Gradle wrapper script for Windows.
packages/kmp/gradle/wrapper/gradle-wrapper.properties Pins the Gradle distribution used by the wrapper.
.github/workflows/kmp-pull-request.yml Validates the KMP build on PRs affecting protos or the KMP package.
.github/workflows/publish-kmp.yml Publishes releases on tag pushes (and supports manual dispatch).
.github/workflows/snapshot-kmp.yml Attempts to publish snapshot builds on master pushes (proto/kmp changes).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/kmp/build.gradle.kts
Comment thread .github/workflows/snapshot-kmp.yml
jamesarich and others added 2 commits May 30, 2026 11:36
The local-dev fallback merged git stderr into stdout, so a failed
git describe (no git, shallow/tagless clone) left an error string in
`tag` — defeating the empty-string guard and throwing IndexOutOfBounds
at configuration time. Drop redirectErrorStream, check the exit code,
and parse each segment defensively so it degrades to 0.0.1-SNAPSHOT.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Snapshots publish to the Central Portal snapshots repository rather than
the main Maven Central CDN, so consumers must add that repo explicitly to
resolve -SNAPSHOT artifacts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jamesarich jamesarich merged commit 93d6c0a into master May 30, 2026
3 checks passed
@jamesarich jamesarich deleted the jamesarich/kmp-proto-library branch May 30, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants