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
25 changes: 21 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# Dependabot version updates.
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "gradle"
directory: "/" # Location of package manifests
directory: "/"
schedule:
interval: "weekly"
groups:
# gRPC and protobuf are released in lockstep and must stay compatible.
grpc-protobuf:
patterns:
- "io.grpc:*"
- "com.google.protobuf:*"
test-dependencies:
patterns:
- "org.junit*"
- "org.testcontainers*"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
github-actions:
patterns:
- "*"
25 changes: 25 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Categories for GitHub's automatically generated release notes
# ("Generate release notes" when drafting a release). Pull requests are sorted by label;
# Dependabot labels its pull requests "dependencies" automatically.
# https://docs.github.com/repositories/releasing-projects-on-github/automatically-generated-release-notes

changelog:
categories:
- title: Breaking changes
labels:
- breaking-change
- title: New features
labels:
- enhancement
- title: Bug fixes
labels:
- bug
- title: Documentation
labels:
- documentation
- title: Dependency updates
labels:
- dependencies
- title: Other changes
labels:
- "*"
25 changes: 25 additions & 0 deletions .github/scripts/post-release-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Updates the repository after version $1 has been published:
# - points the README's Gradle and Maven snippets at the released version
# - bumps gradle.properties to the next minor snapshot, unless it was already moved on
#
# Usage: post-release-update.sh <released-version> (e.g. 0.8 or 0.8.1)
set -euo pipefail

version="${1:?usage: post-release-update.sh <released-version>}"
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
echo "Not a release version: $version" >&2
exit 1
fi

# README: Gradle coordinates and the Maven <version> directly following our artifactId.
perl -pi -e "s/(io\.github\.domenicdev:umadb-java-client:)[^\"')]+/\${1}${version}/g" README.md
perl -0pi -e "s|(<artifactId>umadb-java-client</artifactId>\s*<version>)[^<]+(</version>)|\${1}${version}\${2}|g" README.md

# gradle.properties: X.Y[.Z] -> X.(Y+1)-SNAPSHOT, but only while the snapshot still names the
# version just released, so a manual bump (e.g. straight to 1.0-SNAPSHOT) is left alone.
current="$(sed -n 's/^version=//p' gradle.properties)"
IFS=. read -r major minor _ <<< "$version"
if [[ "$current" == "${major}.${minor}-SNAPSHOT" || "$current" == "${version}-SNAPSHOT" ]]; then
sed -i "s/^version=.*/version=${major}.$((minor + 1))-SNAPSHOT/" gradle.properties
fi
27 changes: 15 additions & 12 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
# Builds and tests every push and pull request to main, and submits the dependency graph
# so that Dependabot alerts cover all Gradle dependencies.
# See: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

Expand All @@ -13,44 +10,50 @@ on:
pull_request:
branches: [ "main" ]

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build:

runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Set up JDK 25
uses: actions/setup-java@v4
uses: actions/setup-java@v6
with:
java-version: '25'
distribution: 'temurin'

# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
uses: gradle/actions/setup-gradle@v6

- name: Build with Gradle Wrapper
run: ./gradlew build

dependency-submission:

runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Set up JDK 25
uses: actions/setup-java@v4
uses: actions/setup-java@v6
with:
java-version: '25'
distribution: 'temurin'

# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
uses: gradle/actions/dependency-submission@v6
106 changes: 92 additions & 14 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,107 @@
name: Publish

# Publishing a GitHub Release (or pre-release) tagged vX.Y[.Z][-suffix] releases that
# version to Maven Central. The version comes from the tag, so no release commit is needed.
# `published` fires once per release; promoting a pre-release to a release does not
# re-publish.
on:
release:
types: [released, prereleased]
types: [published]

concurrency:
group: publish-${{ github.event.release.tag_name }}
cancel-in-progress: false

permissions:
contents: read

jobs:
publish:
name: Release build and publish
name: Build, test and publish to Maven Central
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 30
outputs:
version: ${{ steps.version.outputs.version }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Derive version from tag
id: version
env:
TAG: ${{ github.event.release.tag_name }}
run: |
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-[0-9A-Za-z.]+)?$ ]] || [[ "$TAG" == *-SNAPSHOT ]]; then
echo "::error::Release tag '$TAG' is not a release version (expected vX.Y, vX.Y.Z or vX.Y.Z-suffix)"
exit 1
fi
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"

- name: Set up JDK 25
uses: actions/setup-java@v4
uses: actions/setup-java@v6
with:
java-version: '25'
distribution: 'temurin'
- name: Publish to MavenCentral
run: ./gradlew publishToMavenCentral --no-configuration-cache

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6

- name: Build and test
run: ./gradlew build
env:
ORG_GRADLE_PROJECT_version: ${{ steps.version.outputs.version }}

- name: Publish and release to Maven Central
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
env:
ORG_GRADLE_PROJECT_version: ${{ steps.version.outputs.version }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}

post-release:
name: Open pull request updating README and next snapshot
needs: publish
# Pre-releases are not advertised in the README.
if: ${{ !github.event.release.prerelease }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
pull-requests: write

steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.repository.default_branch }}

- name: Update README and gradle.properties
env:
VERSION: ${{ needs.publish.outputs.version }}
run: .github/scripts/post-release-update.sh "$VERSION"

- name: Open pull request
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}

GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.publish.outputs.version }}
BASE: ${{ github.event.repository.default_branch }}
run: |
if git diff --quiet; then
echo "Nothing to update."
exit 0
fi
branch="post-release/v${VERSION}"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git switch -c "$branch"
git commit -am "Update README to ${VERSION} and bump to next snapshot"
git push --force origin "$branch"
if gh pr view "$branch" --json state --jq .state 2>/dev/null | grep -q OPEN; then
echo "Pull request for $branch already open; branch updated."
exit 0
fi
gh pr create --base "$BASE" --head "$branch" \
--title "Post-release: ${VERSION}" \
--body "Points the README's installation snippets at ${VERSION}, which is now on Maven Central, and bumps \`gradle.properties\` to the next development snapshot (only if it still named the released version)."
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ A lightweight Java client for interacting with the [UmaDB event store](https://u

## Installation

> **Requires Java 25 or newer.** The library is compiled for Java 25 and does not run on
> older JVMs.

Add the following dependency to either the `build.gradle` or `pom.xml` file in your project.

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

Releases are driven entirely by GitHub Releases. There are no release commits: the version
is taken from the release tag.

## Cutting a release

1. Make sure `main` is green and the README's "Migrating from …" section describes any
breaking changes.
2. On GitHub, draft a new release:
- **Tag:** `vX.Y` or `vX.Y.Z` (for example `v0.8`), created from `main`.
- **Release notes:** click *Generate release notes*. Pull requests are grouped by label
(see `.github/release.yml`); add highlights or migration notes by hand if needed.
- Tick *Set as a pre-release* for versions such as `v0.9.0-rc1`.
3. Publish the release. The [Publish workflow](.github/workflows/publish.yml) then:
1. derives the version from the tag (`v0.8` → `0.8`) and rejects tags that are not
release versions,
2. builds and runs all tests against that version,
3. signs, uploads and **automatically releases** the artifacts on Maven Central,
4. for full releases only, opens a pull request that points the README's installation
snippets at the new version and bumps `gradle.properties` to the next minor snapshot.
4. Review and merge the post-release pull request.

Artifacts usually appear on Maven Central within about 30 minutes of the workflow finishing.
A published version cannot be replaced or deleted. If something is wrong, release a new
version.

## Versions

- `gradle.properties` holds the development version (`X.Y-SNAPSHOT`) used for local builds.
Release builds override it with `-Pversion`/`ORG_GRADLE_PROJECT_version`.
- The post-release pull request bumps the snapshot only if it still names the version just
released. To skip ahead (for example to `1.0-SNAPSHOT`), edit `gradle.properties` by hand.

## One-time repository setup

- **Secrets** used by the Publish workflow: `MAVEN_CENTRAL_USERNAME`,
`MAVEN_CENTRAL_PASSWORD` (a Central Portal user token), `SIGNING_KEY_ID`,
`SIGNING_PASSWORD`, `GPG_KEY_CONTENTS`.
- **Settings → Actions → General → Workflow permissions:** enable *Allow GitHub Actions to
create and approve pull requests*, so that the post-release pull request can be opened.
- **Labels** for release notes: `breaking-change` (create it), `enhancement`, `bug`,
`documentation`, `dependencies` (GitHub and Dependabot defaults).

Pull requests opened by the workflow do not trigger the CI workflow themselves, because
GitHub does not start workflows for events caused by `GITHUB_TOKEN`. They only touch the
README and `gradle.properties`, so this is harmless. If branch protection requires status
checks, push an empty commit to the branch or merge with admin rights.
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ plugins {
}

group = 'io.umadb'
version = '0.8-SNAPSHOT'
// The version lives in gradle.properties. Releases override it from the Git tag
// (see .github/workflows/publish.yml), so it never needs a release commit.

// Published bytecode targets Java 25, independent of the JDK running the build.
tasks.withType(JavaCompile).configureEach {
options.release = 25
}

repositories {
mavenCentral()
Expand Down
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Development version. Releases override it from the Git tag (vX.Y -> X.Y);
# the post-release pull request bumps it to the next snapshot.
version=0.8-SNAPSHOT

mavenCentralPublishing=true
signAllPublications=true
signAllPublications=true
Loading