From d0b52210263c08648eb6ca0dc36a703d1d8b6b8c Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 6 Sep 2026 11:56:58 +0000 Subject: [PATCH 01/15] build: reference internal modules through ${project.groupId} Every inter-module dependency named the groupId literally, so publishing the reactor under other coordinates meant editing 15 dependency blocks as well as the parent references. With the property, only the root groupId and the blocks name it. --- pom.xml | 10 ++++++---- postgresql-client-bench-jmh/pom.xml | 4 ++-- postgresql-client-coverage/pom.xml | 8 ++++---- postgresql-client-jdbc/pom.xml | 2 +- postgresql-client-native-smoke/pom.xml | 4 ++-- postgresql-client-pgjdbc-compat/pom.xml | 2 +- postgresql-client/pom.xml | 2 +- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index c8acabeb..71c4e9f7 100644 --- a/pom.xml +++ b/pom.xml @@ -4,6 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + org.postgresql postgresql-client-parent 0.1.0-SNAPSHOT @@ -101,22 +103,22 @@ - org.postgresql + ${project.groupId} postgresql-client-protocol ${project.version} - org.postgresql + ${project.groupId} postgresql-client ${project.version} - org.postgresql + ${project.groupId} postgresql-client-jdbc ${project.version} - org.postgresql + ${project.groupId} postgresql-client-pgjdbc-compat ${project.version} diff --git a/postgresql-client-bench-jmh/pom.xml b/postgresql-client-bench-jmh/pom.xml index d2bbe1e3..63dbf311 100644 --- a/postgresql-client-bench-jmh/pom.xml +++ b/postgresql-client-bench-jmh/pom.xml @@ -31,11 +31,11 @@ - org.postgresql + ${project.groupId} postgresql-client - org.postgresql + ${project.groupId} postgresql-client-protocol diff --git a/postgresql-client-coverage/pom.xml b/postgresql-client-coverage/pom.xml index 0b588c6d..71c8b3d0 100644 --- a/postgresql-client-coverage/pom.xml +++ b/postgresql-client-coverage/pom.xml @@ -21,19 +21,19 @@ each module's test phase has written its execution data. --> - org.postgresql + ${project.groupId} postgresql-client-protocol - org.postgresql + ${project.groupId} postgresql-client - org.postgresql + ${project.groupId} postgresql-client-jdbc - org.postgresql + ${project.groupId} postgresql-client-pgjdbc-compat diff --git a/postgresql-client-jdbc/pom.xml b/postgresql-client-jdbc/pom.xml index c0a1f3e8..d7dd8dc3 100644 --- a/postgresql-client-jdbc/pom.xml +++ b/postgresql-client-jdbc/pom.xml @@ -17,7 +17,7 @@ - org.postgresql + ${project.groupId} postgresql-client diff --git a/postgresql-client-native-smoke/pom.xml b/postgresql-client-native-smoke/pom.xml index c3a29aa7..ec4ae865 100644 --- a/postgresql-client-native-smoke/pom.xml +++ b/postgresql-client-native-smoke/pom.xml @@ -26,11 +26,11 @@ - org.postgresql + ${project.groupId} postgresql-client-jdbc - org.postgresql + ${project.groupId} postgresql-client-pgjdbc-compat diff --git a/postgresql-client-pgjdbc-compat/pom.xml b/postgresql-client-pgjdbc-compat/pom.xml index f201e963..1ea3e689 100644 --- a/postgresql-client-pgjdbc-compat/pom.xml +++ b/postgresql-client-pgjdbc-compat/pom.xml @@ -20,7 +20,7 @@ - org.postgresql + ${project.groupId} postgresql-client-jdbc diff --git a/postgresql-client/pom.xml b/postgresql-client/pom.xml index 49ed6785..a7285aac 100644 --- a/postgresql-client/pom.xml +++ b/postgresql-client/pom.xml @@ -17,7 +17,7 @@ - org.postgresql + ${project.groupId} postgresql-client-protocol From 94a23dbc4585abdf265d76ebe0c28356e0a73744 Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 6 Sep 2026 11:56:58 +0000 Subject: [PATCH 02/15] build: skip deploy for the coverage aggregate The other three build-only modules set maven.deploy.skip; the coverage aggregate did not, so a deploy would have pushed its POM. --- postgresql-client-coverage/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/postgresql-client-coverage/pom.xml b/postgresql-client-coverage/pom.xml index 71c8b3d0..bb905804 100644 --- a/postgresql-client-coverage/pom.xml +++ b/postgresql-client-coverage/pom.xml @@ -16,6 +16,11 @@ postgresql-client coverage Aggregates per-module JaCoCo coverage into one combined report. Not published. + + + true + + From 0201c2b1341de22598da4b98a4c5e60e78b40aed Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Fri, 23 Oct 2026 10:44:05 +0000 Subject: [PATCH 03/15] docs(plans): add the Maven Central publishing plan (N7.1) Records how the Central Portal works today (OSSRH is gone, user-token auth only, manual Publish gate, no OIDC), how pgjdbc publishes from its build-logic (nmcp aggregation, release parameter selecting snapshot repo or in-memory PGP signing, CI-held key), and the fork-first rehearsal: snapshots then a release under io.github, with the groupId swapped in one spot and the wiring merged back afterwards. --- docs/plans/overall.md | 1 + docs/plans/publishing.md | 253 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 254 insertions(+) create mode 100644 docs/plans/publishing.md diff --git a/docs/plans/overall.md b/docs/plans/overall.md index d944a83d..dba23332 100644 --- a/docs/plans/overall.md +++ b/docs/plans/overall.md @@ -1048,6 +1048,7 @@ in CI; at least two "pgjdbc can't do this cleanly" capabilities documented. - [ ] **N7.1** Reproducible builds, signing, Maven Central (C24.8); semver + changelog. The reproducible `project.build.outputTimestamp` is set; GPG signing, Central deployment wiring, and the semver/changelog policy remain. + The step-by-step is `docs/plans/publishing.md`. Wire the revapi (or japicmp) binary-compatibility gate as part of this, not after it: it diffs against the last released artifact, so the first release is the moment it becomes possible, and it is what makes the Stable tier mean diff --git a/docs/plans/publishing.md b/docs/plans/publishing.md new file mode 100644 index 00000000..c82d0baa --- /dev/null +++ b/docs/plans/publishing.md @@ -0,0 +1,253 @@ +# Plan: publishing to Maven Central (N7.1 / C24.8) + +Status: **not started.** Two preparatory build changes are in (steps 6a and +6b): inter-module dependencies go through `${project.groupId}`, and the four +build-only modules all set `maven.deploy.skip`. Nothing else is wired. +The running status is in [`overall.md`](overall.md) under N7.1. + +The approach: rehearse the whole pipeline in a fork under a personal +`io.github.` namespace, snapshots first and then a real release, and +merge the wiring back once it works. The final coordinates are `org.postgresql` +(ADR-0022); the fork differs from upstream only in the groupId literal and the +credentials, so the merge is the groupId swap plus whatever landed in the POMs. + +## What gets published + +Five artifacts: `postgresql-client-parent` (POM only, but every module's POM +points at it so it must be on Central), `postgresql-client-protocol`, +`postgresql-client`, `postgresql-client-jdbc`, and +`postgresql-client-pgjdbc-compat`. `postgresql-client-bench`, +`postgresql-client-bench-jmh`, `postgresql-client-coverage`, and +`postgresql-client-native-smoke` set `maven.deploy.skip` and never ship. + +Open question, to settle before the first non-snapshot release: whether the +compat module belongs in a public release at all. It is a migration aid, not a +certified drop-in, and it publishes classes under pgjdbc's own package names, so +adding it next to real pgjdbc produces a split package. Options are to ship it, +ship it with an explicit warning in its POM description, or skip it until it is +certified. Snapshots can carry it either way. + +## How the Central Portal works (verified 2026-10-23) + +- OSSRH is gone (retired 2025-06-30). Everything goes through the Central + Publisher Portal at central.sonatype.com, authenticated by a user token. +- A release deploy creates a *deployment* that is validated and then waits in + VALIDATED state until someone presses Publish in the Portal UI or calls the + publish endpoint. Drop discards it. This is `publishingType=USER_MANAGED`, the + default; `AUTOMATIC` skips the human step. Validated deployments are kept 90 + days. +- The Portal login has no second factor of its own; a Central account is as + strong as the GitHub or Google account linked to it. There is no OIDC or + trusted-publishing flow: CI holds a user token as a secret. +- Snapshots: enabled per namespace in the Portal UI, pushed to + `https://central.sonatype.com/repository/maven-snapshots/`, no validation and + no signing, purged after 90 days. +- Releases: every file needs a detached PGP `.asc` and the public key must be on + `keyserver.ubuntu.com`, `keys.openpgp.org`, or `pgp.mit.edu`. The POM needs + `name`, `description`, `url`, `licenses`, `scm`, and `developers`, and each + jar needs sources and javadoc jars. Sigstore signatures are accepted only in + addition to PGP; GitHub artifact attestations are not consumed by Central or + by Maven at all. +- `central-publishing-maven-plugin` (`org.sonatype.central`, 0.9.0) replaces + the deploy plugin, bundles the whole reactor, and uploads it at the end of the + build. It routes `-SNAPSHOT` versions to the snapshot repository on its own. + +## How pgjdbc publishes (for reference, checked 2026-10-23) + +pgjdbc is Gradle, so the plugins differ, but the shape is the one to copy. The +publishing logic is in `build-logic/publishing/src/main/kotlin/` and +`build-logic/root-build/`, with knobs declared in `build-logic/build-parameters/`. + +- **Central Portal via `com.gradleup.nmcp` 1.5.0.** The root project applies + `nmcp.aggregation` and configures `centralPortal` with username and password + read from the `CENTRAL_PORTAL_USERNAME` / `CENTRAL_PORTAL_PASSWORD` + environment variables, a `publishingType` build parameter (`AUTOMATIC` by + default, `MANUAL` available), and a 60-minute `validationTimeout`. Each + published subproject applies `build-logic.publish-to-central`, which pulls + `maven-publish`, `signing`, and `nmcp`. +- **Snapshot vs release is a build parameter.** `-Prelease` (default false) + switches the version suffix. Without it, the publish plugin registers a + `centralSnapshots` Maven repository at + `https://central.sonatype.com/repository/maven-snapshots` with + `PasswordCredentials`, fed from Gradle properties + `centralSnapshotsUsername` / `centralSnapshotsPassword`. With it, signing is + configured instead and the Portal upload is used. So snapshots never sign + and releases never go to the snapshot repository, by construction. +- **Signing.** Build parameters `signing.pgp.enabled` (`AUTO`, meaning on + for releases, or `OFF`) and `signing.pgp.implementation` (`IN_MEMORY` + default, or `GPG_CLI`). In-memory signing reads `SIGNING_PGP_PRIVATE_KEY` + and `SIGNING_PGP_PASSPHRASE` from the environment and fails the build with a + Gradle Problems report if either is missing. `GPG_CLI` is the local escape + hatch. The key itself is generated and maintained *inside* GitHub Actions by + the reusable workflow `vlsi/provision-release-pgp-key` + (`pgp-key-maintenance.yaml`, `workflow_dispatch` only): key name "pgjdbc + releases", email `pgjdbc-releases@jdbc.postgresql.org`, five-year lifetime, + uploaded to `keyserver.ubuntu.com`, `keys.openpgp.org`, and `pgp.mit.edu`. + Rerunning extends the expiry, so any committer can renew without holding the + key. It needs a fine-grained token with `secrets: write` and + `variables: write` (`RELEASE_PGP_SECRET_UPDATE_TOKEN`). +- **Artifacts and POM.** `withSourcesJar()` always, `withJavadocJar()` unless + `skipJavadoc`. The POM block sets name, description, inceptionYear, url, + licenses, organization, developers (seven named committers), issueManagement, + mailingLists, and scm with `tag` fixed to `HEAD`. Dependency versions in the + POM come from Gradle's resolution result rather than declared ranges. +- **A local staging copy.** `build-logic.publish-to-tmp-maven-repo` adds a + `tmp-maven` repository under `build/local-maven-repo`, cleaned before each + publish. The release workflow publishes to Central and to `tmp-maven` in the + same Gradle run, so the jar and `.asc` attached to the GitHub release are + byte-for-byte what went to Central. A `createReleaseBundle` task gathers + every publishable artifact into `build/release` and mentions SLSA + attestation in its description, but `release.yml` runs no attestation step + today. +- **`nightlysnapshot.yml`** runs on every push to `master`, first checks the + two secrets exist and skips cleanly if not, then runs + `publishAllPublicationsToCentralSnapshotsRepository` with the Portal token + (still stored as `NEXUS_USERNAME` / `NEXUS_PASSWORD`) mapped to the Gradle + properties through `ORG_GRADLE_PROJECT_*`. +- **`release.yml`** is `workflow_dispatch` only with an optional version input + (default from `gradle.properties`). It refuses to run off `master` or + `release/**`, refuses an existing `REL` tag, and bumps the version + through a GitHub App token. The publish step runs + `publishAggregationToCentralPortal` with `release=true` and + `centralPortalPublishingType=AUTOMATIC`, so the manual dispatch is the human + gate rather than the Portal's Publish button. It publishes *before* tagging, + so a failed upload leaves no tag to clean up, then creates the GitHub release + with release-drafter, attaches the staged jar and signature, and bumps to the + next snapshot. Permissions are `contents: write` only: no `id-token`, no + environment protection. + +Worth adopting from that: the generated-in-CI key with the extend-on-rerun +workflow (no developer ever holds the release key), the fail-loud check for +missing signing secrets, the secrets-present guard on the snapshot job, the +branch and tag guards, publishing before tagging, and attaching the same bytes +that went to Central to the GitHub release. The snapshot/release split is +simpler for us: the Central plugin routes `-SNAPSHOT` on its own, and the +`release` profile is what adds signing. Worth doing differently: keep +`autoPublish` off, at least until the pipeline has run clean a few times, so +the Portal's Publish button stays as a second look. + +## Phase 1: account and namespace (once, in the Portal) + +1. Log in at central.sonatype.com, open View Namespaces, Add Namespace, enter + `io.github.`. `io.github.` verifies automatically if the Central + account was created through GitHub login; `io.github.` never does. +2. If it shows Unverified, create a public repository named exactly the + verification key under that account (works for an org too), wait for the + check, then delete the repository. +3. On the namespace's dropdown, choose Enable SNAPSHOTs. +4. Generate a user token at central.sonatype.com/usertoken. Both halves are shown + once; save them. +5. Add the token to `~/.m2/settings.xml`: + + ```xml + + central + TOKEN_USER + TOKEN_PASS + + ``` + +## Phase 2: fork POM changes + +6a. Done: every inter-module dependency's `` is `${project.groupId}` + (15 blocks across the root `dependencyManagement` and the module POMs), so + publishing under other coordinates means editing the root `` and + the `` blocks and nothing else. Parent references cannot be + properties, which is why those stay literal. +6b. Done: `maven.deploy.skip` on `postgresql-client-coverage`, matching the + other three build-only modules; without it a deploy pushed the coverage + POM. +6c. Swap the groupId, the one spot: + + ```sh + git grep -l 'org.postgresql' -- pom.xml '*/pom.xml' \ + | xargs sed -i 's|org.postgresql|io.github.NAME|' + ``` + + After 6a this hits the root `` and the nine `` blocks and + nothing else; no dependency in the reactor shares that literal. Keep this + as its own commit so it can be reverted cleanly at merge time. +7. Add ``, `` (`connection`, `developerConnection`, `url`, `tag`), + and `` to the root POM. +8. Add `central-publishing-maven-plugin` 0.9.0 to the root `` + with `true`, `publishingServerId` `central`, and + `autoPublish` false. +9. Add a `release` profile in the root POM with `maven-source-plugin` + (`jar-no-fork`), `maven-javadoc-plugin` (`jar`), and `maven-gpg-plugin` + 3.2.x (`sign`, `bestPractices` true, passphrase from + `MAVEN_GPG_PASSPHRASE`). Keep them out of the default build so the everyday + `verify` stays fast. +10. Run `./mvnw -ntp -DskipTests -Prelease -Dgpg.skip package` and fix what + doclint reports. Javadoc is the one gate this project has never run, so + expect findings; `doclint` set to `all,-missing` is the usual first cut if + missing-comment noise is the only problem. Doclint fixes are code changes + and get their own commits. + +## Phase 3: first snapshot + +11. `./mvnw -ntp deploy` with the version still `0.1.0-SNAPSHOT`. No signing, + no validation. +12. Check the Portal lists exactly the five artifacts above. If a build-only + module appears, the plugin ignored `maven.deploy.skip`, and each of the four + POMs needs `true` instead. +13. Resolve it from a scratch project: + + ```xml + + central-portal-snapshots + https://central.sonatype.com/repository/maven-snapshots/ + true + + ``` + +## Phase 4: signing key (once) + +Two ways; pick one. + +14a. Local key: `gpg --gen-key` with a project identity, then + `gpg --keyserver keys.openpgp.org --send-keys KEYID` (keys.openpgp.org + serves the identity only after the confirmation email is answered). Export + with `gpg --export-secret-keys -a KEYID` and store it, the passphrase, and + the Central token as GitHub Actions secrets. +14b. CI-held key, pgjdbc style: add a `pgp-key-maintenance.yaml` that calls + `vlsi/provision-release-pgp-key` (digest-pinned) with the project's key + name and email, give it a fine-grained token with `secrets: write` and + `variables: write`, and dispatch it once. The private key lands in + `RELEASE_PGP_PRIVATE_KEY` and never leaves Actions; rerun to extend. + Preferable for upstream, since no individual holds the `org.postgresql` + release key. Local releases are then impossible by design, which is the + point. + +## Phase 5: first release + +15. Set the version with `./mvnw versions:set -DnewVersion=0.1.0`, commit, tag + `v0.1.0`. (Or publish before tagging, as pgjdbc does; either way the tag + must not exist before the upload succeeds.) +16. `./mvnw -ntp -Prelease deploy` with `MAVEN_GPG_PASSPHRASE` set (and the + key imported, for 14a). `waitUntil` defaults to `validated`, so the build + returns once the Portal accepts the bundle. +17. In the Portal, inspect the VALIDATED deployment and press Publish. Central + releases are immutable: a bad `0.1.0` can only be followed by `0.1.1`. +18. Bump to `0.2.0-SNAPSHOT`, commit, and confirm a plain `deploy` still lands + snapshots. + +## Phase 6: CI (optional for the fork, required upstream) + +19. `snapshot.yml`: on push to the main branch, `./mvnw -ntp deploy` with the + Central token from secrets. +20. `release.yml`: `workflow_dispatch` with a version input, guard the branch + and the tag as pgjdbc does, run step 16 with the key from secrets, then + tag and create the GitHub release only after the upload succeeded. Leave + `autoPublish` off so the Portal's Publish button remains the gate; flip it + once the workflow has run clean several times, if the manual dispatch is + judged gate enough. `actions/attest` can be added for provenance at no + cost, but nothing in the Maven ecosystem consumes it. + +## Phase 7: merge back + +21. Revert step 6c in the fork so the diff to merge is steps 7 through 10, 19, + and 20, plus the doclint fixes. +22. Upstream needs its own `central` token with rights on `org.postgresql` and + its own signing key (14b). Everything else carries over unchanged. +23. Tick N7.1 in `overall.md`. Wire the revapi/japicmp gate next, as N7.1 says: + the first published artifact is what makes it possible. From 0ff304b2620e9e7bd9e76bc5d0c654184e95f364 Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 29 Nov 2026 17:43:17 +0000 Subject: [PATCH 04/15] build: add url, scm and developers for Central (N7.1) Central refuses a POM without them. Children inherit them unchanged, not with their artifactId appended. --- pom.xml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 71c4e9f7..7dfe3b97 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,8 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + child.project.url.inherit.append.path="false"> 4.0.0 + + + sehrope + Sehrope Sarkuni + + + + + scm:git:https://github.com/pgjdbc/pg-java.git + scm:git:git@github.com:pgjdbc/pg-java.git + https://github.com/pgjdbc/pg-java + HEAD + + postgresql-client-protocol postgresql-client From 9d7c04bbeb5815c17ceca415f0e87e9081ae3878 Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 29 Nov 2026 17:46:30 +0000 Subject: [PATCH 05/15] fix(protocol): put the request-code shifts in ProtocolConstants Javadoc in {@code} doclint reads a bare << as malformed HTML. --- .../org/postgresql/client/protocol/ProtocolConstants.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/postgresql-client-protocol/src/main/java/org/postgresql/client/protocol/ProtocolConstants.java b/postgresql-client-protocol/src/main/java/org/postgresql/client/protocol/ProtocolConstants.java index 75ca2a26..a47ffbd9 100644 --- a/postgresql-client-protocol/src/main/java/org/postgresql/client/protocol/ProtocolConstants.java +++ b/postgresql-client-protocol/src/main/java/org/postgresql/client/protocol/ProtocolConstants.java @@ -38,13 +38,13 @@ public static int protocolMinor(int versionCode) { // -- Special request codes (sent in place of a protocol version). -- - /** CancelRequest code (80877102 = (1234 << 16) | 5678). */ + /** CancelRequest code ({@code 80877102 = (1234 << 16) | 5678}). */ public static final int CANCEL_REQUEST_CODE = (1234 << 16) | 5678; - /** SSLRequest code (80877103 = (1234 << 16) | 5679). */ + /** SSLRequest code ({@code 80877103 = (1234 << 16) | 5679}). */ public static final int SSL_REQUEST_CODE = (1234 << 16) | 5679; - /** GSSENCRequest code (80877104 = (1234 << 16) | 5680). */ + /** GSSENCRequest code ({@code 80877104 = (1234 << 16) | 5680}). */ public static final int GSSENC_REQUEST_CODE = (1234 << 16) | 5680; // -- Field/parameter format codes (int16 on the wire). -- From 307291ef331e2c94cadaad844eedfdff023ab308 Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 29 Nov 2026 17:46:30 +0000 Subject: [PATCH 06/15] fix(core): name java.sql.Struct in PgComposite Javadoc without linking it Core does not read java.sql, so the link cannot resolve. --- .../src/main/java/org/postgresql/client/core/PgComposite.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgresql-client/src/main/java/org/postgresql/client/core/PgComposite.java b/postgresql-client/src/main/java/org/postgresql/client/core/PgComposite.java index e0402382..0c164be9 100644 --- a/postgresql-client/src/main/java/org/postgresql/client/core/PgComposite.java +++ b/postgresql-client/src/main/java/org/postgresql/client/core/PgComposite.java @@ -10,7 +10,7 @@ * this shape (the type name comes from the catalog), and a bound parameter of this shape resolves * the composite's OID and per-field codecs by name to serialize the record text form * {@code (f0,f1,...)} -- so a decoded value can be re-bound unchanged. The JDBC layer maps it to - * and from {@link java.sql.Struct}. + * and from {@code java.sql.Struct}. * *

Attributes may contain {@code null} (a SQL NULL field), so they are held in a null-tolerant * unmodifiable list rather than {@code List.copyOf}. From 01177c9c7d149954bef89c3aaacae437f86bad5c Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 29 Nov 2026 17:46:30 +0000 Subject: [PATCH 07/15] fix(jdbc): repair two Javadoc references doclint cannot resolve PreparedStatement declares no toString(), and LATEST is Mode.LATEST. --- .../src/main/java/org/postgresql/client/jdbc/SqlLiteral.java | 2 +- .../org/postgresql/client/jdbc/batch/BatchRewriteSetting.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/postgresql-client-jdbc/src/main/java/org/postgresql/client/jdbc/SqlLiteral.java b/postgresql-client-jdbc/src/main/java/org/postgresql/client/jdbc/SqlLiteral.java index 2163f22c..84c37f99 100644 --- a/postgresql-client-jdbc/src/main/java/org/postgresql/client/jdbc/SqlLiteral.java +++ b/postgresql-client-jdbc/src/main/java/org/postgresql/client/jdbc/SqlLiteral.java @@ -2,7 +2,7 @@ /** * A bound parameter value that knows its own SQL-literal rendering, used by - * {@link java.sql.PreparedStatement#toString()}'s interpolated form. The pgjdbc compat layer's + * {@code PreparedStatement.toString()}'s interpolated form. The pgjdbc compat layer's * {@code PGobject} implements this so vendor values render the way pgjdbc renders them (a quoted, * type-cast literal); values with no special rendering use the driver's defaults. */ diff --git a/postgresql-client-jdbc/src/main/java/org/postgresql/client/jdbc/batch/BatchRewriteSetting.java b/postgresql-client-jdbc/src/main/java/org/postgresql/client/jdbc/batch/BatchRewriteSetting.java index dc0a4281..b62b1384 100644 --- a/postgresql-client-jdbc/src/main/java/org/postgresql/client/jdbc/batch/BatchRewriteSetting.java +++ b/postgresql-client-jdbc/src/main/java/org/postgresql/client/jdbc/batch/BatchRewriteSetting.java @@ -4,7 +4,7 @@ /** * The parsed value of the {@code rewriteBatchUsingArrays} connection property, which selects a - * {@link BatchArrayRewriter} (ADR-0014). This classifies the property text; resolving a {@link #LATEST} + * {@link BatchArrayRewriter} (ADR-0014). This classifies the property text; resolving a {@link Mode#LATEST} * or {@link Mode#PINNED} setting to a concrete rewriter happens later against the rewriter registry. * *

    @@ -49,7 +49,7 @@ public boolean enabled() { /** * Parses a {@code rewriteBatchUsingArrays} property value. A null, blank, or off-like value is - * {@link #DISABLED}; an on-like value is {@link #LATEST}; anything else is a {@link Mode#PINNED} + * {@link #DISABLED}; an on-like value is {@link Mode#LATEST}; anything else is a {@link Mode#PINNED} * selector (the original, untrimmed-of-case token, whitespace-trimmed). */ public static BatchRewriteSetting fromProperty(String value) { From 7504d149ede583240212f221034130ad45d96bfb Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 29 Nov 2026 17:46:46 +0000 Subject: [PATCH 08/15] build: deploy through the Central Portal plugin (N7.1) autoPublish is off, so a release waits in the Portal for a manual Publish. The build-only modules are excluded by name. --- pom.xml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pom.xml b/pom.xml index 7dfe3b97..20eaf7b6 100644 --- a/pom.xml +++ b/pom.xml @@ -78,6 +78,8 @@ 0.10.0 3.5.0 + + 0.9.0 + + org.sonatype.central + central-publishing-maven-plugin + ${central-publishing-maven-plugin.version} + true + + central + false + + + postgresql-client-bench + postgresql-client-bench-jmh + postgresql-client-coverage + postgresql-client-native-smoke + + + @@ -461,5 +484,6 @@ + From f361f285e3f856a07d85b28409c112571bdd4e9b Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 29 Nov 2026 17:46:46 +0000 Subject: [PATCH 09/15] build: add a release profile for sources, javadoc and signatures (N7.1) Central requires all three on a release. The profile keeps them out of the everyday build. The build-only modules skip them. --- pom.xml | 63 +++++++++++++++++++++++++- postgresql-client-bench-jmh/pom.xml | 4 ++ postgresql-client-bench/pom.xml | 4 ++ postgresql-client-coverage/pom.xml | 4 ++ postgresql-client-native-smoke/pom.xml | 4 ++ 5 files changed, 78 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 20eaf7b6..d8cd2a28 100644 --- a/pom.xml +++ b/pom.xml @@ -78,8 +78,11 @@ 0.10.0 3.5.0 - + 0.9.0 + 3.3.1 + 3.11.2 + 3.2.7 + + release + + + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin.version} + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + all,-missing + + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + ${maven-gpg-plugin.version} + + true + + + + sign-artifacts + verify + + sign + + + + + + + diff --git a/postgresql-client-bench-jmh/pom.xml b/postgresql-client-bench-jmh/pom.xml index 63dbf311..a556a171 100644 --- a/postgresql-client-bench-jmh/pom.xml +++ b/postgresql-client-bench-jmh/pom.xml @@ -25,6 +25,10 @@ true + + true + true + true 1.37 diff --git a/postgresql-client-bench/pom.xml b/postgresql-client-bench/pom.xml index 4c5e6a0a..bf372a5d 100644 --- a/postgresql-client-bench/pom.xml +++ b/postgresql-client-bench/pom.xml @@ -23,6 +23,10 @@ true + + true + true + true diff --git a/postgresql-client-coverage/pom.xml b/postgresql-client-coverage/pom.xml index bb905804..c2fd7702 100644 --- a/postgresql-client-coverage/pom.xml +++ b/postgresql-client-coverage/pom.xml @@ -19,6 +19,10 @@ true + + true + true + true true + + true + true + true From ff2acc54b5b7825d3bda6b716ad396d4c63f17d0 Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 29 Nov 2026 17:54:10 +0000 Subject: [PATCH 10/15] build: read the Central token from the environment for deploy Holds no secret, so it can be committed. Passed with -s on the deploy only: in maven.config it would replace ~/.m2/settings.xml for every build. --- .mvn/settings.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .mvn/settings.xml diff --git a/.mvn/settings.xml b/.mvn/settings.xml new file mode 100644 index 00000000..a7a2b84c --- /dev/null +++ b/.mvn/settings.xml @@ -0,0 +1,16 @@ + + + + + + + central + ${env.MAVEN_CENTRAL_USERNAME} + ${env.MAVEN_CENTRAL_PASSWORD} + + + From bf58be4fc8fa8ba342ef7e6368c26acec836b5f6 Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 29 Nov 2026 17:54:56 +0000 Subject: [PATCH 11/15] docs(plans): record the POM wiring and env-based Central token (N7.1) --- docs/plans/publishing.md | 73 ++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/docs/plans/publishing.md b/docs/plans/publishing.md index c82d0baa..94274361 100644 --- a/docs/plans/publishing.md +++ b/docs/plans/publishing.md @@ -1,9 +1,8 @@ # Plan: publishing to Maven Central (N7.1 / C24.8) -Status: **not started.** Two preparatory build changes are in (steps 6a and -6b): inter-module dependencies go through `${project.groupId}`, and the four -build-only modules all set `maven.deploy.skip`. Nothing else is wired. -The running status is in [`overall.md`](overall.md) under N7.1. +Status: **POM wiring done on the rehearsal branch (steps 6a to 10), nothing +deployed yet.** Next is the first snapshot (Phase 3). The running status is in +[`overall.md`](overall.md) under N7.1. The approach: rehearse the whole pipeline in a fork under a personal `io.github.` namespace, snapshots first and then a real release, and @@ -137,15 +136,13 @@ the Portal's Publish button stays as a second look. 3. On the namespace's dropdown, choose Enable SNAPSHOTs. 4. Generate a user token at central.sonatype.com/usertoken. Both halves are shown once; save them. -5. Add the token to `~/.m2/settings.xml`: - - ```xml - - central - TOKEN_USER - TOKEN_PASS - - ``` +5. Export the token halves as `MAVEN_CENTRAL_USERNAME` and + `MAVEN_CENTRAL_PASSWORD`. The committed `.mvn/settings.xml` maps them to + the `central` server, and every deploy passes it with + `-s .mvn/settings.xml`. It is not in `.mvn/maven.config`: `-s` replaces + `~/.m2/settings.xml` (mirrors, proxies) rather than merging with it, so it + would change every build. Other builds never read the credentials; with + the variables unset, only a deploy fails (401). ## Phase 2: fork POM changes @@ -157,7 +154,7 @@ the Portal's Publish button stays as a second look. 6b. Done: `maven.deploy.skip` on `postgresql-client-coverage`, matching the other three build-only modules; without it a deploy pushed the coverage POM. -6c. Swap the groupId, the one spot: +6c. Done (fork only): swap the groupId, the one spot: ```sh git grep -l 'org.postgresql' -- pom.xml '*/pom.xml' \ @@ -167,26 +164,26 @@ the Portal's Publish button stays as a second look. After 6a this hits the root `` and the nine `` blocks and nothing else; no dependency in the reactor shares that literal. Keep this as its own commit so it can be reverted cleanly at merge time. -7. Add ``, `` (`connection`, `developerConnection`, `url`, `tag`), - and `` to the root POM. -8. Add `central-publishing-maven-plugin` 0.9.0 to the root `` - with `true`, `publishingServerId` `central`, and - `autoPublish` false. -9. Add a `release` profile in the root POM with `maven-source-plugin` +7. Done: ``, `` (`connection`, `developerConnection`, `url`, `tag`), + and `` in the root POM, pointing at `github.com/pgjdbc/pg-java` + so they carry over at merge time. The `child.*.inherit.append.path` + attributes stop the modules appending their artifactId to the URLs. +8. Done: `central-publishing-maven-plugin` 0.9.0 in the root `` + with `true`, `publishingServerId` `central`, + `autoPublish` false, and the four build-only modules in `excludeArtifacts`. +9. Done: a `release` profile in the root POM with `maven-source-plugin` (`jar-no-fork`), `maven-javadoc-plugin` (`jar`), and `maven-gpg-plugin` - 3.2.x (`sign`, `bestPractices` true, passphrase from - `MAVEN_GPG_PASSPHRASE`). Keep them out of the default build so the everyday - `verify` stays fast. -10. Run `./mvnw -ntp -DskipTests -Prelease -Dgpg.skip package` and fix what - doclint reports. Javadoc is the one gate this project has never run, so - expect findings; `doclint` set to `all,-missing` is the usual first cut if - missing-comment noise is the only problem. Doclint fixes are code changes - and get their own commits. + 3.2.7 (`sign`, `bestPractices` true, passphrase from + `MAVEN_GPG_PASSPHRASE`). The build-only modules skip all three. +10. Done: `./mvnw -ntp -DskipTests -Prelease -Dgpg.skip package` passes with + doclint at `all,-missing`. Missing comments were the bulk of the findings; + the rest (an unescaped `<<`, a link into `java.sql` from core, two broken + `{@link}`s) were fixed in their own commits. ## Phase 3: first snapshot -11. `./mvnw -ntp deploy` with the version still `0.1.0-SNAPSHOT`. No signing, - no validation. +11. `./mvnw -ntp -s .mvn/settings.xml deploy` with the version still + `0.1.0-SNAPSHOT`. No signing, no validation. 12. Check the Portal lists exactly the five artifacts above. If a build-only module appears, the plugin ignored `maven.deploy.skip`, and each of the four POMs needs `true` instead. @@ -223,18 +220,20 @@ Two ways; pick one. 15. Set the version with `./mvnw versions:set -DnewVersion=0.1.0`, commit, tag `v0.1.0`. (Or publish before tagging, as pgjdbc does; either way the tag must not exist before the upload succeeds.) -16. `./mvnw -ntp -Prelease deploy` with `MAVEN_GPG_PASSPHRASE` set (and the - key imported, for 14a). `waitUntil` defaults to `validated`, so the build - returns once the Portal accepts the bundle. +16. `./mvnw -ntp -s .mvn/settings.xml -Prelease deploy` with + `MAVEN_GPG_PASSPHRASE` set (and the key imported, for 14a). `waitUntil` + defaults to `validated`, so the build returns once the Portal accepts the + bundle. 17. In the Portal, inspect the VALIDATED deployment and press Publish. Central releases are immutable: a bad `0.1.0` can only be followed by `0.1.1`. -18. Bump to `0.2.0-SNAPSHOT`, commit, and confirm a plain `deploy` still lands - snapshots. +18. Bump to `0.2.0-SNAPSHOT`, commit, and confirm the step 11 deploy (no + `-Prelease`) still lands snapshots. ## Phase 6: CI (optional for the fork, required upstream) -19. `snapshot.yml`: on push to the main branch, `./mvnw -ntp deploy` with the - Central token from secrets. +19. `snapshot.yml`: on push to the main branch, + `./mvnw -ntp -s .mvn/settings.xml deploy`, with + `MAVEN_CENTRAL_USERNAME` and `MAVEN_CENTRAL_PASSWORD` set from secrets. 20. `release.yml`: `workflow_dispatch` with a version input, guard the branch and the tag as pgjdbc does, run step 16 with the key from secrets, then tag and create the GitHub release only after the upload succeeded. Leave From 0fbcf2de116859435f94a337eb731b233b182d8c Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 29 Nov 2026 19:25:04 +0000 Subject: [PATCH 12/15] ci: add a manual workflow that publishes a snapshot (N7.1) Run from the Actions tab. It refuses a non-SNAPSHOT version and a missing token, and deploy runs the unit tests and gates before the upload. --- .github/workflows/publish-snapshot.yml | 58 ++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/publish-snapshot.yml diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml new file mode 100644 index 00000000..80cead66 --- /dev/null +++ b/.github/workflows/publish-snapshot.yml @@ -0,0 +1,58 @@ +name: publish snapshot + +# Publishes the selected branch's -SNAPSHOT build to the Central Portal snapshot repository +# (docs/plans/publishing.md, Phase 3). Run by hand from the Actions tab; nothing triggers it +# automatically. Snapshots are not signed, so no GPG key is involved. The Central user token +# comes from the MAVEN_CENTRAL_USERNAME and MAVEN_CENTRAL_PASSWORD repository secrets, which +# .mvn/settings.xml maps to the `central` server. + +on: + workflow_dispatch: + +# One publish at a time per branch, so two runs cannot interleave their uploads. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +permissions: + contents: read + +jobs: + publish: + name: publish snapshot + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + cache: maven + - name: Refuse anything but a -SNAPSHOT version + # A release goes through -Prelease and the Portal's Publish button, never this workflow. + run: | + version=$(./mvnw -B -ntp -q help:evaluate -Dexpression=project.version -DforceStdout) + echo "version: $version" + case "$version" in + *-SNAPSHOT) ;; + *) echo "::error::$version is not a -SNAPSHOT version"; exit 1 ;; + esac + - name: Require the Central token + env: + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + # Unset, settings.xml would send the literal ${env...} text and fail late with a 401. + run: | + if [ -z "$MAVEN_CENTRAL_USERNAME" ] || [ -z "$MAVEN_CENTRAL_PASSWORD" ]; then + echo "::error::set the MAVEN_CENTRAL_USERNAME and MAVEN_CENTRAL_PASSWORD secrets" + exit 1 + fi + - name: Build, test, and deploy + env: + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + # deploy runs the unit tests and gates first, so a broken build is never published. + run: ./mvnw -B -ntp -s .mvn/settings.xml deploy From 6c59cb96caa031e8abc0b1e2e7270affc33af803 Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 29 Nov 2026 19:25:12 +0000 Subject: [PATCH 13/15] docs(plans): record the published snapshot and the manual workflow (N7.1) --- docs/plans/publishing.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/plans/publishing.md b/docs/plans/publishing.md index 94274361..e2b8ba3f 100644 --- a/docs/plans/publishing.md +++ b/docs/plans/publishing.md @@ -1,8 +1,10 @@ # Plan: publishing to Maven Central (N7.1 / C24.8) -Status: **POM wiring done on the rehearsal branch (steps 6a to 10), nothing -deployed yet.** Next is the first snapshot (Phase 3). The running status is in -[`overall.md`](overall.md) under N7.1. +Status: **snapshots publish; releases deferred.** The POM wiring (steps 6a +to 10) is done, a first snapshot was published under `io.github.sehrope` from +a local deploy (step 11), and `publish-snapshot.yml` publishes one by hand +(step 19). No signing key exists yet, so Phases 4 and 5 wait. The running +status is in [`overall.md`](overall.md) under N7.1. The approach: rehearse the whole pipeline in a fork under a personal `io.github.` namespace, snapshots first and then a real release, and @@ -231,9 +233,13 @@ Two ways; pick one. ## Phase 6: CI (optional for the fork, required upstream) -19. `snapshot.yml`: on push to the main branch, - `./mvnw -ntp -s .mvn/settings.xml deploy`, with - `MAVEN_CENTRAL_USERNAME` and `MAVEN_CENTRAL_PASSWORD` set from secrets. +19. Done: `publish-snapshot.yml`, run by hand (`workflow_dispatch`) on the + selected branch. It refuses a non-SNAPSHOT version and missing secrets, + then runs `./mvnw -B -ntp -s .mvn/settings.xml deploy`, which tests before + it uploads. The token comes from the `MAVEN_CENTRAL_USERNAME` and + `MAVEN_CENTRAL_PASSWORD` repository secrets. A push trigger after the `ci` + workflow passes can come later; manual is enough while releases are + deferred. 20. `release.yml`: `workflow_dispatch` with a version input, guard the branch and the tag as pgjdbc does, run step 16 with the key from secrets, then tag and create the GitHub release only after the upload succeeded. Leave From 6a926cb8899267a876c88f88bcc488206a187a41 Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 29 Nov 2026 19:29:25 +0000 Subject: [PATCH 14/15] docs(plans): record dropping the rehearsal groupId swap (N7.1) --- docs/plans/publishing.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/plans/publishing.md b/docs/plans/publishing.md index e2b8ba3f..560e823f 100644 --- a/docs/plans/publishing.md +++ b/docs/plans/publishing.md @@ -1,10 +1,12 @@ # Plan: publishing to Maven Central (N7.1 / C24.8) -Status: **snapshots publish; releases deferred.** The POM wiring (steps 6a -to 10) is done, a first snapshot was published under `io.github.sehrope` from -a local deploy (step 11), and `publish-snapshot.yml` publishes one by hand -(step 19). No signing key exists yet, so Phases 4 and 5 wait. The running -status is in [`overall.md`](overall.md) under N7.1. +Status: **snapshots rehearsed; releases deferred.** The POM wiring (steps 6a +to 10) is done, and a first snapshot was published under `io.github.sehrope` +from a local deploy (step 11). The groupId swap (6c) has since been dropped, +so the build is `org.postgresql` again, and `publish-snapshot.yml` publishes +one by hand (step 19) once the repository holds a token with rights on +`org.postgresql` (step 22). No signing key exists yet, so Phases 4 and 5 wait. +The running status is in [`overall.md`](overall.md) under N7.1. The approach: rehearse the whole pipeline in a fork under a personal `io.github.` namespace, snapshots first and then a real release, and @@ -156,7 +158,8 @@ the Portal's Publish button stays as a second look. 6b. Done: `maven.deploy.skip` on `postgresql-client-coverage`, matching the other three build-only modules; without it a deploy pushed the coverage POM. -6c. Done (fork only): swap the groupId, the one spot: +6c. Done for the rehearsal, then dropped (step 21): swap the groupId, the one + spot: ```sh git grep -l 'org.postgresql' -- pom.xml '*/pom.xml' \ @@ -250,8 +253,9 @@ Two ways; pick one. ## Phase 7: merge back -21. Revert step 6c in the fork so the diff to merge is steps 7 through 10, 19, - and 20, plus the doclint fixes. +21. Done: the step 6c commit was dropped rather than reverted, so the branch + carries steps 7 through 10 and 19 plus the doclint fixes, under + `org.postgresql`. 22. Upstream needs its own `central` token with rights on `org.postgresql` and its own signing key (14b). Everything else carries over unchanged. 23. Tick N7.1 in `overall.md`. Wire the revapi/japicmp gate next, as N7.1 says: From 7cea8deb230780d1f303c4ca0ded28ac0e4a6f95 Mon Sep 17 00:00:00 2001 From: Sehrope Sarkuni Date: Sun, 29 Nov 2026 19:44:09 +0000 Subject: [PATCH 15/15] ci: summarize the published coordinates in the snapshot workflow Lists each artifact the build publishes with its timestamped snapshot build, read back from the repository, and a dependency snippet. --- .github/workflows/publish-snapshot.yml | 13 +++- scripts/snapshot-summary.sh | 93 ++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 2 deletions(-) create mode 100755 scripts/snapshot-summary.sh diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 80cead66..dd272813 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -32,14 +32,18 @@ jobs: java-version: '21' cache: maven - name: Refuse anything but a -SNAPSHOT version + id: coordinates # A release goes through -Prelease and the Portal's Publish button, never this workflow. run: | - version=$(./mvnw -B -ntp -q help:evaluate -Dexpression=project.version -DforceStdout) - echo "version: $version" + group=$(./mvnw -B -ntp -q -N help:evaluate -Dexpression=project.groupId -DforceStdout) + version=$(./mvnw -B -ntp -q -N help:evaluate -Dexpression=project.version -DforceStdout) + echo "coordinates: $group:*:$version" case "$version" in *-SNAPSHOT) ;; *) echo "::error::$version is not a -SNAPSHOT version"; exit 1 ;; esac + echo "group=$group" >> "$GITHUB_OUTPUT" + echo "version=$version" >> "$GITHUB_OUTPUT" - name: Require the Central token env: MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} @@ -56,3 +60,8 @@ jobs: MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} # deploy runs the unit tests and gates first, so a broken build is never published. run: ./mvnw -B -ntp -s .mvn/settings.xml deploy + - name: Summarize the published coordinates + env: + GROUP: ${{ steps.coordinates.outputs.group }} + VERSION: ${{ steps.coordinates.outputs.version }} + run: scripts/snapshot-summary.sh "$GROUP" "$VERSION" >> "$GITHUB_STEP_SUMMARY" diff --git a/scripts/snapshot-summary.sh b/scripts/snapshot-summary.sh new file mode 100755 index 00000000..8b904a05 --- /dev/null +++ b/scripts/snapshot-summary.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +# +# Writes a Markdown summary of a published snapshot to stdout, for the publish-snapshot +# workflow's $GITHUB_STEP_SUMMARY. +# +# Usage: scripts/snapshot-summary.sh GROUP_ID VERSION +# +# The published artifacts are the parent plus every of the root pom.xml, minus the +# entries of its excludeArtifacts block (module directory names are the +# artifactIds in this build). Each one's timestamped build is read back from the snapshot +# repository's maven-metadata.xml; "-" means it could not be read. + +set -euo pipefail + +REPO_URL="https://central.sonatype.com/repository/maven-snapshots" + +main() { + if [ $# -ne 2 ]; then + echo "usage: $0 GROUP_ID VERSION" >&2 + exit 2 + fi + local group="$1" version="$2" + cd "$(dirname "$0")/.." + + local parent + parent=$(sed -n 's|^ \(.*\)$|\1|p' pom.xml | head -n 1) + local excluded + excluded=$(sed -n 's|^ *\(.*\)$|\1|p' pom.xml) + local artifacts=("$parent") + local module + for module in $(sed -n 's|^ *\(.*\)$|\1|p' pom.xml); do + if ! grep -qx "$module" <<<"$excluded"; then + artifacts+=("$module") + fi + done + + local group_path="${group//./\/}" + local commit="${GITHUB_SHA:-$(git rev-parse HEAD)}" + local ref="${GITHUB_REF_NAME:-$(git rev-parse --abbrev-ref HEAD)}" + + echo "## Published snapshot" + echo + echo "| | |" + echo "| --- | --- |" + echo "| Version | \`$version\` |" + echo "| Branch | \`$ref\` |" + echo "| Commit | \`${commit:0:12}\` |" + echo "| Repository | $REPO_URL |" + echo + echo "| Artifact | Coordinates | Build |" + echo "| --- | --- | --- |" + local artifact build + for artifact in "${artifacts[@]}"; do + build=$(snapshot_build "$group_path" "$artifact" "$version") + echo "| \`$artifact\` | \`$group:$artifact:$version\` | ${build:+\`}${build:--}${build:+\`} |" + done + echo + echo "### Using it" + echo + echo "Snapshots are not on Maven Central itself; add the snapshot repository:" + echo + echo '```xml' + echo "" + echo " " + echo " central-portal-snapshots" + echo " $REPO_URL/" + echo " false" + echo " true" + echo " " + echo "" + echo + echo "" + echo " $group" + echo " postgresql-client-jdbc" + echo " $version" + echo "" + echo '```' +} + +# The timestamped build (e.g. 0.1.0-20261129.191502-3) the version currently resolves to. +snapshot_build() { + local group_path="$1" artifact="$2" version="$3" + local metadata + metadata=$(curl -fsS --max-time 20 "$REPO_URL/$group_path/$artifact/$version/maven-metadata.xml" 2>/dev/null) || return 0 + local timestamp number + timestamp=$(sed -n 's|.*\(.*\).*|\1|p' <<<"$metadata" | head -n 1) + number=$(sed -n 's|.*\(.*\).*|\1|p' <<<"$metadata" | head -n 1) + if [ -n "$timestamp" ] && [ -n "$number" ]; then + echo "${version%-SNAPSHOT}-$timestamp-$number" + fi +} + +main "$@"