Skip to content
Open
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
11 changes: 10 additions & 1 deletion .mise/tasks/build-release.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#!/usr/bin/env bash

#MISE description="Build release package"
#USAGE arg "<tag>" env="TAG" default="1.5.0-SNAPSHOT"
#USAGE arg "[tag]" env="TAG"

set -euo pipefail

# shellcheck disable=SC2154 # is set by mise
if [[ -z "${usage_tag:-}" ]]; then
PARENT_POM="prometheus-metrics-parent/pom.xml"
usage_tag=$(sed -n 's/.*<version>\(.*-SNAPSHOT\)<\/version>.*/\1/p' "$PARENT_POM" | head -1)
if [[ -z "$usage_tag" ]]; then
echo "ERROR: could not find SNAPSHOT version in $PARENT_POM" >&2
exit 1
fi
fi

VERSION=${usage_tag#v}

mise run set-version "$VERSION"
Expand Down
86 changes: 86 additions & 0 deletions .mise/tasks/bump_snapshot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env python3

# [MISE] description="Bump the snapshot version in all pom.xml files"
# [MISE] alias="bump-snapshot"

"""
Bump the SNAPSHOT version in all pom.xml files.

By default, increments the minor version (e.g. X.Y.0 -> X.(Y+1).0).
An explicit version can be passed as argument:
mise run bump-snapshot 2.0.0-SNAPSHOT
"""

import re
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[2] # repo root
PARENT_POM = ROOT / "prometheus-metrics-parent" / "pom.xml"


def current_snapshot() -> str:
"""Extract the current SNAPSHOT version from the parent pom.xml."""
text = PARENT_POM.read_text(encoding="utf-8")
m = re.search(
r"<groupId>io\.prometheus</groupId>\s*"
r"<artifactId>client_java_parent</artifactId>\s*"
r"<version>(\S+)</version>",
text,
)
if not m:
sys.exit("Could not find version in " + str(PARENT_POM))
version = m.group(1)
if not version.endswith("-SNAPSHOT"):
sys.exit(f"Current version '{version}' is not a SNAPSHOT version")
return version


def next_minor(version: str) -> str:
"""Increment the minor version: 1.5.0-SNAPSHOT -> 1.6.0-SNAPSHOT."""
base = version.removesuffix("-SNAPSHOT")
parts = base.split(".")
if len(parts) != 3:
sys.exit(f"Expected three-part version, got '{base}'")
parts[1] = str(int(parts[1]) + 1)
parts[2] = "0"
return ".".join(parts) + "-SNAPSHOT"


def find_pom_files() -> list[Path]:
"""Find all pom.xml files in the repository."""
return sorted(ROOT.rglob("pom.xml"))


def main() -> None:
old_version = current_snapshot()

if len(sys.argv) > 1:
new_version = sys.argv[1]
if not new_version.endswith("-SNAPSHOT"):
sys.exit(f"New version must end with -SNAPSHOT, got '{new_version}'")
else:
new_version = next_minor(old_version)

if old_version == new_version:
sys.exit(f"Old and new version are the same: {old_version}")

print(f"Bumping {old_version} -> {new_version}")

updated_count = 0
for pom in find_pom_files():
content = pom.read_text(encoding="utf-8")
updated = content.replace(old_version, new_version)
if content != updated:
pom.write_text(updated, encoding="utf-8")
print(f" updated {pom.relative_to(ROOT)}")
updated_count += 1

if updated_count == 0:
sys.exit(f"No pom.xml files contain '{old_version}'")

print(f"\nDone. {updated_count} pom.xml file(s) updated to {new_version}.")


if __name__ == "__main__":
main()
12 changes: 8 additions & 4 deletions .mise/tasks/set-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@

set -euo pipefail

# replace all occurrences '<version>1.5.0-SNAPSHOT</version>' with
# '<version>$usage_version</version>' in all pom.xml files in the current directory and
# subdirectories
PARENT_POM="prometheus-metrics-parent/pom.xml"
CURRENT_VERSION=$(sed -n 's/.*<version>\(.*-SNAPSHOT\)<\/version>.*/\1/p' "$PARENT_POM" | head -1)

if [[ -z "$CURRENT_VERSION" ]]; then
echo "ERROR: could not find SNAPSHOT version in $PARENT_POM" >&2
exit 1
fi

# shellcheck disable=SC2154 # is set by mise
find . -name 'pom.xml' -exec \
sed -i "s/<version>1.5.0-SNAPSHOT<\/version>/<version>$usage_version<\/version>/g" {} +
sed -i "s/<version>${CURRENT_VERSION}<\/version>/<version>$usage_version<\/version>/g" {} +
13 changes: 9 additions & 4 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ mise run update-benchmarks

## Major or minor release

After the release is created, do a text replace everywhere in the repository to update the
snapshot version in the `pom.xml` files (and some other files) to the next version.
For example, if the last release was `1.4.0`, the next snapshot version should be `1.5.0-SNAPSHOT`.
After the release is created, bump the snapshot version in all
`pom.xml` files:

Replace `1.4.0-SNAPSHOT` with `1.5.0-SNAPSHOT` in all following files.
```shell
# Auto-increment the minor version (e.g. 1.5.0-SNAPSHOT -> 1.6.0-SNAPSHOT)
mise run bump-snapshot

# Or specify an explicit version (e.g. for a major bump)
mise run bump-snapshot 2.0.0-SNAPSHOT
```

## If the GPG key expired

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>client_java</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>benchmarks</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/example-custom-buckets/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-bom</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-bom</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-bom</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/example-exporter-httpserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-bom</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/example-exporter-multi-target/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-bom</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/example-exporter-opentelemetry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-bom</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/example-exporter-servlet-tomcat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-bom</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/example-native-histogram/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-bom</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/example-otel-jvm-runtime-metrics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-bom</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/example-prometheus-properties/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-bom</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/example-simpleclient-bridge/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-bom</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>client_java</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>examples</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/it-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>integration-tests</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>it-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>it-exporter</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>it-exporter-duplicate-metrics-sample</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>it-exporter</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>it-exporter-httpserver-sample</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>it-exporter</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>it-exporter-no-protobuf</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>it-exporter</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>it-exporter-servlet-jetty-sample</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>it-exporter</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>it-exporter-servlet-tomcat-sample</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/it-exporter/it-exporter-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>it-exporter</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>it-exporter-test</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/it-exporter/it-no-protobuf-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>it-exporter</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>it-no-protobuf-test</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/it-exporter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>integration-tests</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>it-exporter</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/it-pushgateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>integration-tests</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>it-pushgateway</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/it-spring-boot-smoke-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<groupId>io.prometheus</groupId>
<artifactId>it-spring-boot-smoke-test</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>

<name>Integration Test - Spring Smoke Tests</name>
<description>
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>client_java</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>integration-tests</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>client_java_parent</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<relativePath>prometheus-metrics-parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion prometheus-metrics-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prometheus</groupId>
<artifactId>client_java_parent</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../prometheus-metrics-parent/pom.xml</relativePath>
</parent>

Expand Down
Loading