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
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release

# Publishes to Maven Central when a GitHub Release is published, via the
# Central Publisher Portal (https://central.sonatype.com).
#
# Required repository secrets (see RELEASING.md for setup):
# CENTRAL_USERNAME - Central portal user token name
# CENTRAL_PASSWORD - Central portal user token value
# GPG_PRIVATE_KEY - ASCII-armored GPG private key used to sign artifacts
# GPG_PASSPHRASE - passphrase for that key
#
# To cut a release: bump the version in pom.xml (drop -SNAPSHOT), merge to
# main, then publish a GitHub Release with tag vX.Y.Z — this workflow signs
# and uploads the artifacts.

on:
release:
types: [published]

permissions:
contents: read

jobs:
publish:
name: Publish to Maven Central
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
cache: maven
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Verify tag matches pom version
run: |
POM_VERSION=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version)
TAG="${GITHUB_REF_NAME#v}"
if [ "$POM_VERSION" != "$TAG" ]; then
echo "pom.xml version ($POM_VERSION) does not match release tag ($GITHUB_REF_NAME)"
exit 1
fi
- name: Publish
run: mvn -B --no-transfer-progress -Prelease deploy
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
31 changes: 9 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Maven:

```xml
<dependency>
<groupId>com.iopsystems</groupId>
<groupId>systems.iop</groupId>
<artifactId>h2histogram</artifactId>
<version>0.1.0</version>
</dependency>
Expand All @@ -42,17 +42,17 @@ Maven:
Gradle:

```kotlin
implementation("com.iopsystems:h2histogram:0.1.0")
implementation("systems.iop:h2histogram:0.1.0")
```

The library requires Java 17 or later and has no runtime dependencies.

## Quick start

```java
import com.iopsystems.h2histogram.Bucket;
import com.iopsystems.h2histogram.Histogram;
import com.iopsystems.h2histogram.SparseHistogram;
import systems.iop.h2histogram.Bucket;
import systems.iop.h2histogram.Histogram;
import systems.iop.h2histogram.SparseHistogram;

Histogram h = new Histogram(7, 64); // groupingPower, maxValuePower

Expand All @@ -79,8 +79,8 @@ For a snapshot you'll query many times, convert to a `CumulativeHistogram`
precomputes a midpoint-estimated mean:

```java
import com.iopsystems.h2histogram.BucketWithQuantiles;
import com.iopsystems.h2histogram.CumulativeHistogram;
import systems.iop.h2histogram.BucketWithQuantiles;
import systems.iop.h2histogram.CumulativeHistogram;

CumulativeHistogram c = h.toCumulative(); // read-only; also SparseHistogram.toCumulative()
Bucket b = c.percentile(0.99).orElseThrow(); // O(log n) binary search (individual count)
Expand Down Expand Up @@ -139,21 +139,8 @@ mvn verify

## Releasing

Releases are published to Maven Central. To cut a release:

1. **Land your changes on `main`** via a pull request.
2. **Set the release version** (drop the `-SNAPSHOT` suffix) in
[`pom.xml`](pom.xml), e.g. `0.1.0`, and merge that change.
3. **Tag and push** a `vX.Y.Z` tag on `main`:

```bash
git checkout main && git pull
git tag v0.1.0
git push origin v0.1.0
```

4. **Deploy** with `mvn -Prelease deploy` using Sonatype (Maven Central)
credentials, then bump `pom.xml` back to the next `-SNAPSHOT` version.
Releases are published to Maven Central automatically via GitHub Actions when
a GitHub Release is published. See [RELEASING.md](RELEASING.md) for the steps.

## License

Expand Down
80 changes: 80 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Releasing

`h2histogram` is published to Maven Central automatically by the
[`release.yml`](.github/workflows/release.yml) GitHub Actions workflow via the
[Central Publisher Portal](https://central.sonatype.com), whenever a GitHub
Release is published.

## Cutting a release

1. **Bump the version.** Edit `<version>` in [`pom.xml`](pom.xml), dropping the
`-SNAPSHOT` suffix (e.g. `0.1.0-SNAPSHOT` → `0.1.0`), following
[semantic versioning](https://semver.org/). Commit and merge to `main` via a
pull request titled `release: vX.Y.Z`.
2. **Publish a GitHub Release.** Go to
[Releases → Draft a new release](https://github.com/iopsystems/h2histogram-java/releases/new):
- **Choose a tag:** type `vX.Y.Z` (matching the `pom.xml` version) and select
*"Create new tag on publish"*, targeting `main`.
- **Title:** `vX.Y.Z`.
- Click **Generate release notes**, then **Publish release**.
3. **Watch the workflow.** Publishing the release triggers `release.yml`, which
verifies the tag matches the pom version, builds the jar plus sources and
javadoc jars, signs everything with GPG, and uploads to Maven Central with
`autoPublish` — no manual portal step. Follow it under the
[Actions tab](https://github.com/iopsystems/h2histogram-java/actions/workflows/release.yml).
Central validation takes a few minutes; sync to search/mirrors can take
longer.
4. **Bump back to a snapshot.** Open a follow-up PR setting `<version>` to the
next development version (e.g. `0.1.1-SNAPSHOT`).

> **Versions are immutable on Maven Central.** A published version can never be
> replaced or deleted. If you push a bad release, bump the version and cut a
> new one.

## One-time setup

### 1. Namespace verification

The `systems.iop` namespace (the reverse-DNS form of the `iop.systems`
domain) must be verified once in the
[Central portal](https://central.sonatype.com) (log in → **Namespaces** → add
`systems.iop`). Verification is via a DNS TXT record on `iop.systems`; the
portal shows the exact record to create.

### 2. Portal user token

In the portal: click your account → **View Account** → **Generate User Token**.
This produces a token *name* and *value* (these are not your portal login
credentials). Store them as repository secrets under
**Settings → Secrets and variables → Actions**:

| Secret | Value |
|--------|-------|
| `CENTRAL_USERNAME` | the token name |
| `CENTRAL_PASSWORD` | the token value |

### 3. GPG signing key

Maven Central requires artifacts to be GPG-signed.

```bash
gpg --gen-key # if you don't already have a key; RSA, no expiry is fine
gpg --keyserver keyserver.ubuntu.com --send-keys <KEY_ID> # publish the public key
gpg --armor --export-secret-keys <KEY_ID> # private key, for the secret below
```

Store as repository secrets:

| Secret | Value |
|--------|-------|
| `GPG_PRIVATE_KEY` | the full ASCII-armored private key block |
| `GPG_PASSPHRASE` | the key's passphrase |

## Publishing manually (without CI)

With a verified namespace, a portal token in `~/.m2/settings.xml` (server id
`central`), and a local GPG key:

```bash
mvn -Prelease deploy
```
8 changes: 4 additions & 4 deletions benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.iopsystems</groupId>
<groupId>systems.iop</groupId>
<artifactId>h2histogram-benchmarks</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.0</version>
<packaging>jar</packaging>

<name>h2histogram-benchmarks</name>
Expand All @@ -20,9 +20,9 @@

<dependencies>
<dependency>
<groupId>com.iopsystems</groupId>
<groupId>systems.iop</groupId>
<artifactId>h2histogram</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.hdrhistogram</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.iopsystems.h2histogram.bench;
package systems.iop.h2histogram.bench;

import com.iopsystems.h2histogram.Config;
import com.iopsystems.h2histogram.Histogram;
import systems.iop.h2histogram.Config;
import systems.iop.h2histogram.Histogram;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
Expand Down
54 changes: 52 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.iopsystems</groupId>
<groupId>systems.iop</groupId>
<artifactId>h2histogram</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.0</version>
<packaging>jar</packaging>

<name>h2histogram</name>
Expand All @@ -23,6 +23,14 @@
</license>
</licenses>

<developers>
<developer>
<name>IOP Systems</name>
<organization>IOP Systems</organization>
<organizationUrl>https://iop.systems</organizationUrl>
</developer>
</developers>

<scm>
<connection>scm:git:https://github.com/iopsystems/h2histogram-java.git</connection>
<developerConnection>scm:git:git@github.com:iopsystems/h2histogram-java.git</developerConnection>
Expand Down Expand Up @@ -84,4 +92,46 @@
</plugin>
</plugins>
</build>

<profiles>
<!-- Publishing to Maven Central: mvn -Prelease deploy (see RELEASING.md) -->
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.7.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iopsystems.h2histogram;
package systems.iop.h2histogram;

/**
* A single histogram bucket: a count and an inclusive value range.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iopsystems.h2histogram;
package systems.iop.h2histogram;

/**
* Bundles a bucket with its quantile span.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iopsystems.h2histogram;
package systems.iop.h2histogram;

/**
* An immutable bucketing configuration.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iopsystems.h2histogram;
package systems.iop.h2histogram;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iopsystems.h2histogram;
package systems.iop.h2histogram;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iopsystems.h2histogram;
package systems.iop.h2histogram;

/**
* Pairs a requested percentile with the {@link Bucket} it resolves to.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iopsystems.h2histogram;
package systems.iop.h2histogram;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iopsystems.h2histogram;
package systems.iop.h2histogram;

/**
* Helpers for treating Java {@code long} values as unsigned 64-bit integers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
* Java {@code long}s with unsigned semantics, so the full {@code u64} range is
* supported, exactly like the Rust crate.
*/
package com.iopsystems.h2histogram;
package systems.iop.h2histogram;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iopsystems.h2histogram;
package systems.iop.h2histogram;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iopsystems.h2histogram;
package systems.iop.h2histogram;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iopsystems.h2histogram;
package systems.iop.h2histogram;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iopsystems.h2histogram;
package systems.iop.h2histogram;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down
Loading