Skip to content

Commit 4b7cca3

Browse files
committed
Add release-please to automate releases
Set up release-please with java release type and always-bump-patch versioning. This replaces the manual release process: release-please maintains a release PR, and merging it creates a tag that triggers the existing Maven Central deploy workflow. Remove bump_snapshot.py and set-version.sh scripts as release-please handles SNAPSHOT version bumps automatically. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
1 parent b1f7ee0 commit 4b7cca3

File tree

7 files changed

+88
-133
lines changed

7 files changed

+88
-133
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Release Please
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
release-please:
15+
if: ${{ github.repository == 'prometheus/client_java' }}
16+
runs-on: ubuntu-24.04
17+
steps:
18+
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}

.mise/tasks/bump_snapshot.py

Lines changed: 0 additions & 86 deletions
This file was deleted.

.mise/tasks/set-version.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

.release-please-config.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"packages": {
4+
".": {
5+
"release-type": "java",
6+
"versioning": "always-bump-patch",
7+
"extra-files": [
8+
"prometheus-metrics-parent/pom.xml",
9+
"integration-tests/it-spring-boot-smoke-test/pom.xml"
10+
]
11+
}
12+
}
13+
}

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "1.5.0"
3+
}

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ or simply
5656
mise run compile
5757
```
5858

59+
## Version Numbers in Examples
60+
61+
Example `pom.xml` files (under `examples/`) should reference the latest
62+
**released** version, not a SNAPSHOT. After each release, Renovate
63+
updates these versions automatically.
64+
65+
Only use a SNAPSHOT version in an example when it demonstrates a new
66+
feature that has not been released yet.
67+
5968
## Updating the Protobuf Java Classes
6069

6170
The generated protobuf `Metrics.java` lives in a versioned package

RELEASING.md

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,58 @@
11
# Releasing Instructions for Prometheus Java Client
22

3-
## Before the Release
3+
Releases are automated via
4+
[release-please](https://github.com/googleapis/release-please).
45

5-
If there have been significant changes since the last release, update the
6-
benchmarks before creating a new release:
6+
## How It Works
77

8-
```shell
9-
mise run update-benchmarks
10-
```
8+
1. Commits to `main` using
9+
[Conventional Commits](https://www.conventionalcommits.org/) are
10+
tracked by release-please.
11+
2. Release-please maintains a release PR that accumulates changes and
12+
updates the changelog.
13+
3. When the release PR is merged, release-please creates a GitHub
14+
release and a `vX.Y.Z` tag.
15+
4. The tag triggers the existing `release.yml` workflow, which deploys
16+
to Maven Central.
17+
5. After tagging, release-please opens a follow-up PR to bump the
18+
SNAPSHOT version in all `pom.xml` files.
1119

12-
## Create a Release
20+
## Patch Release (default)
1321

14-
1. Go to <https://github.com/prometheus/client_java/releases/new>
15-
2. Click on "Choose a tag", enter the tag name (e.g. `v0.1.0`), and click "Create a new tag".
16-
3. Click on "Generate release notes" to auto-generate the release notes based on the commits since
17-
the last release.
18-
4. Click on "Publish release".
22+
Simply merge the release PR — release-please bumps the patch version
23+
by default (e.g. `1.5.0` -> `1.5.1`).
1924

20-
## Major or minor release
25+
## Minor or Major Release
2126

22-
After the release is created, bump the snapshot version in all
23-
`pom.xml` files:
27+
Add a `release-as: X.Y.0` footer to any commit on `main`:
2428

25-
```shell
26-
# Auto-increment the minor version (e.g. 1.5.0-SNAPSHOT -> 1.6.0-SNAPSHOT)
27-
mise run bump-snapshot
29+
```text
30+
feat: add new feature
31+
32+
release-as: 1.6.0
33+
```
2834

29-
# Or specify an explicit version (e.g. for a major bump)
30-
mise run bump-snapshot 2.0.0-SNAPSHOT
35+
Alternatively, edit the release PR title to
36+
`chore(main): release 1.6.0`.
37+
38+
## Before the Release
39+
40+
If there have been significant changes since the last release, update
41+
the benchmarks before merging the release PR:
42+
43+
```shell
44+
mise run update-benchmarks
3145
```
3246

33-
## If the GPG key expired
47+
## If the GPG Key Expired
3448

3549
1. Generate a new key:
3650
<https://central.sonatype.org/publish/requirements/gpg/#generating-a-key-pair>
37-
2. Distribute the
38-
key: <https://central.sonatype.org/publish/requirements/gpg/#distributing-your-public-key>
39-
3. use `gpg --armor --export-secret-keys YOUR_ID` to
40-
export ([docs](https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#gpg))
41-
4. Update the
42-
passphrase: <https://github.com/prometheus/client_java/settings/secrets/actions/GPG_SIGNING_PASSPHRASE> <!-- editorconfig-checker-disable-line -->
43-
5. Update the GPG
44-
key: <https://github.com/prometheus/client_java/settings/secrets/actions/GPG_SIGNING_KEY>
51+
2. Distribute the key:
52+
<https://central.sonatype.org/publish/requirements/gpg/#distributing-your-public-key>
53+
3. Use `gpg --armor --export-secret-keys YOUR_ID` to export
54+
([docs](https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#gpg))
55+
4. Update the passphrase:
56+
<https://github.com/prometheus/client_java/settings/secrets/actions/GPG_SIGNING_PASSPHRASE>
57+
5. Update the GPG key:
58+
<https://github.com/prometheus/client_java/settings/secrets/actions/GPG_SIGNING_KEY>

0 commit comments

Comments
 (0)