Skip to content

ci: publish to Maven Central only when the libraries changed - #612

Merged
linroid merged 1 commit into
mainfrom
ci/publish-changed-libraries
Oct 24, 2026
Merged

linroid merged 1 commit into
mainfrom
ci/publish-changed-libraries

Conversation

@linroid

@linroid linroid commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Summary

Maven Central now limits how much an organization publishes each month (80 MB, 1,000 files, 7 releases). Every v* tag published all 14 library modules (about 90 publications, ~1,450 files, ~19 MB), including releases that changed only the apps. Now the publish-maven-central job publishes only when the published libraries changed since the last version on Maven Central.

  • Detection: .github/scripts/library-changes.py
    • Reads the last published version from com/linroid/ketch/api/maven-metadata.xml (<release>, else <latest>).
    • Fetches that version's tag (shallow-safe) and diffs it against the checked-out tag.
    • Counts: files of the published modules, found by the build scripts that apply com.vanniktech.maven.publish on either side. Test source sets (src/test/, src/*Test/) and *.md are left out.
    • Also counts: the root build.gradle.kts, settings.gradle.kts, gradle.properties and gradle/libs.versions.toml. For these, comment-only edits are ignored, and so are the Gradle and Kotlin daemon settings in gradle.properties (org.gradle.*, kotlin.daemon.*). The version is passed with -PVERSION_NAME, and the group and POM come from gradle.properties and each module's own gradle.properties, so both are covered.
    • Fails open: it publishes if the metadata can't be read, the tag is missing, or the comparison fails. It skips if the release's version is already on Maven Central (a re-run).
  • Workflow:
    • The decision is a step, not a job condition. On a skip, the job succeeds and release still runs.
    • The job summary and a run annotation say whether it published and why, and list the changed library files.
  • Manual runs: there is a new workflow_dispatch input, force-maven-central. A manual run on a tag publishes that tag's libraries and nothing else.
    • The builds are skipped on manual runs (the four root jobs have if: github.event_name == 'push'), so their dependents skip too. A full re-run of an older tag would have pushed Docker latest and touched the GitHub release.
    • The publish job has if: !cancelled() && !failure(), so it runs on manual runs and still needs successful builds on tag pushes.
    • A manual run on a branch fails with an error.
  • Docs: docs/api.md says library versions skip app-only releases, so users should take the latest version on Maven Central. AGENTS.md notes the rule.

Verification

I ran the script locally against each tag and the one before it:

Tag Compared with Result
v0.0.4 v0.0.3 Skipped (only org.gradle.parallel changed)
v0.0.5 v0.0.4 Skipped
v0.1.0 v0.0.5 Publishes, see below
v0.2.1 v0.2.0 Skipped
v0.2.3 v0.2.1 Skipped
v0.9.1 v0.9.0 Skipped
v0.10.1 v0.10.0 Skipped
v0.9.0 v0.8.1 Publishes (35 files)
v0.10.0 v0.9.1 Publishes (166 files)

v0.1.0 publishes. It changed no published library, but it added real code to the root build.gradle.kts: the compilePublishedMetadata verification task. That script also sets the JVM target and compiler flags of every published module. A task like this can't be told apart from a compiler-option change without building both versions, so root-script code changes still publish. Across all 20 tag pairs, the root script changed without library changes only this once.

Other checks:

  • Real metadata with --tag v0.10.1: skipped (already on Maven Central). With --tag v0.10.2 against main: skipped (nothing published changed since v0.10.1).
  • A 404 metadata URL, a missing tag and --force each publish.
  • In a --depth 1 clone, the base tag was fetched at depth 1 and diffed correctly.
  • GITHUB_OUTPUT and GITHUB_STEP_SUMMARY are written as expected.
  • actionlint is clean for this change. It still reports 12 SC2086 notes in other jobs; there were 13 before, and this change quotes one.

Not covered: the workflow itself hasn't run on GitHub yet. The next tag push will be its first run.

Maven Central now limits how much an organization publishes each month, and every release tag
published all 14 library modules, also for releases that changed only the apps.

The publish job now compares the release with the tag of the last version on Maven Central (read
from the api artifact's maven-metadata.xml) and publishes only when a published module changed
outside its test source sets, or a root build file changed in a way that can affect the output
(comments and the Gradle and Kotlin daemon settings in gradle.properties do not count). It
publishes anyway when the version or the tag cannot be found. A skip leaves the job successful,
so the release still runs, and the job summary says what it decided and why.

Running the workflow on a tag publishes only that tag's libraries, with force-maven-central to
publish them even if unchanged; the builds, the Docker image and the GitHub release run for tag
pushes alone, so a manual run never moves the latest release or image.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-23T13:31:24.129823Z 843a315 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 23, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 2 193 files  ±0   2 221 suites  ±0   56m 21s ⏱️ -20s
15 247 tests ±0  14 979 ✅ ±0  268 💤 ±0  0 ❌ ±0 
18 598 runs  ±0  18 330 ✅ ±0  268 💤 ±0  0 ❌ ±0 

Results for commit 843a315. ± Comparison against base commit 94bd6b5.

@linroid
linroid merged commit 892bb34 into main Oct 24, 2026
15 checks passed
@linroid
linroid deleted the ci/publish-changed-libraries branch October 24, 2026 02:15
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.

1 participant