Skip to content

Commit ef468a4

Browse files
pom sync on release
Signed-off-by: F-Node-Karlsruhe <christian.fries@eecc.de>
1 parent 326f9bc commit ef468a4

7 files changed

Lines changed: 123 additions & 41 deletions

File tree

.cursor/notes/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Java library for generating and processing [OpenID4VP](https://openid.net/specs/openid-4-verifiable-presentations-1_0.html) presentation requests.
66

7-
**Current Version**: 0.2.0-SNAPSHOT (see `oid4vp-java/pom.xml`)
7+
**Current Version**: 0.4.1-SNAPSHOT (see `oid4vp-java/pom.xml` and module parent references)
88
**License**: Apache License 2.0
99
**Technology Stack**: Java 25, Maven, Jackson, Caffeine, SLF4J; optional Spring Boot 3.4
1010
**Maven coordinates**: `de.eecc.oid4vc:oid4vp` (core), `de.eecc.oid4vc:oid4vp-spring-boot-starter`
@@ -42,7 +42,7 @@ mvn test
4242
mvn package
4343
```
4444

45-
Release: `npm run release minor` (from repo root). Version lives in parent `oid4vp-parent` POM.
45+
Release: `npm run release minor` (from repo root). Version lives in parent `oid4vp-parent` POM and must match the `<parent><version>` in `oid4vp-core`, `oid4vp-spring`, and `oid4vp-spring-boot-starter`. `minor`/`major` bumps use the latest git tag as the base; `patch` uses the SNAPSHOT version in the POM. See `scripts/release.js`.
4646

4747
## Important Files
4848

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
## [0.3.0] - 2026-06-15
10+
### Fixed
11+
12+
- Release script `minor`/`major` bumps now derive from the last git tag instead of the SNAPSHOT version in `pom.xml`, preventing skipped versions when the POM was manually advanced ahead of the last release
13+
- Release script now updates the parent POM and all module POM parent version references together
14+
15+
## [0.2.0] - 2026-06-15
1116

1217
### Added
1318

oid4vp-java/oid4vp-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>de.eecc.oid4vc</groupId>
99
<artifactId>oid4vp-parent</artifactId>
10-
<version>0.2.0-SNAPSHOT</version>
10+
<version>0.4.1-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>oid4vp</artifactId>

oid4vp-java/oid4vp-spring-boot-starter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>de.eecc.oid4vc</groupId>
99
<artifactId>oid4vp-parent</artifactId>
10-
<version>0.2.0-SNAPSHOT</version>
10+
<version>0.4.1-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>oid4vp-spring-boot-starter</artifactId>

oid4vp-java/oid4vp-spring/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>de.eecc.oid4vc</groupId>
99
<artifactId>oid4vp-parent</artifactId>
10-
<version>0.2.0-SNAPSHOT</version>
10+
<version>0.4.1-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>oid4vp-spring</artifactId>

oid4vp-java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>de.eecc.oid4vc</groupId>
88
<artifactId>oid4vp-parent</artifactId>
9-
<version>0.3.1-SNAPSHOT</version>
9+
<version>0.4.1-SNAPSHOT</version>
1010
<packaging>pom</packaging>
1111

1212
<name>oid4vp-parent</name>

scripts/release.js

Lines changed: 111 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,22 @@ const fs = require("fs");
44
const path = require("path");
55
const { execSync } = require("child_process");
66

7-
const POM_PATH = path.join(__dirname, "..", "oid4vp-java", "pom.xml");
7+
const JAVA_ROOT = path.join(__dirname, "..", "oid4vp-java");
8+
const PARENT_POM = path.join(JAVA_ROOT, "pom.xml");
9+
const MODULE_POMS = [
10+
path.join(JAVA_ROOT, "oid4vp-core", "pom.xml"),
11+
path.join(JAVA_ROOT, "oid4vp-spring", "pom.xml"),
12+
path.join(JAVA_ROOT, "oid4vp-spring-boot-starter", "pom.xml"),
13+
];
14+
const ALL_POMS = [PARENT_POM, ...MODULE_POMS];
15+
const POM_GIT_PATHS = ALL_POMS.map((pomPath) =>
16+
path.relative(path.join(__dirname, ".."), pomPath)
17+
);
18+
19+
const PARENT_VERSION_PATTERN =
20+
/(<artifactId>oid4vp-parent<\/artifactId>\s*\n\s*<version>)[0-9]+\.[0-9]+\.[0-9]+(?:-SNAPSHOT)?(<\/version>)/;
21+
const PARENT_VERSION_READ_PATTERN =
22+
/<artifactId>oid4vp-parent<\/artifactId>\s*\n\s*<version>([0-9]+\.[0-9]+\.[0-9]+(?:-SNAPSHOT)?)<\/version>/;
823

924
const colors = {
1025
reset: "\x1b[0m",
@@ -21,33 +36,34 @@ function log(message, color = "reset") {
2136
}
2237

2338
function getCurrentVersion() {
24-
const pomContent = fs.readFileSync(POM_PATH, "utf8");
25-
const versionMatch = pomContent.match(
26-
/<artifactId>oid4vp-parent<\/artifactId>\s*\n\s*<version>([0-9]+\.[0-9]+\.[0-9]+(?:-SNAPSHOT)?)<\/version>/
27-
);
39+
const pomContent = fs.readFileSync(PARENT_POM, "utf8");
40+
const versionMatch = pomContent.match(PARENT_VERSION_READ_PATTERN);
2841
if (!versionMatch) {
2942
throw new Error("Could not find project version in oid4vp-java/pom.xml");
3043
}
3144
return versionMatch[1];
3245
}
3346

3447
function updatePomVersion(newVersion) {
35-
let pomContent = fs.readFileSync(POM_PATH, "utf8");
36-
let versionUpdated = false;
37-
pomContent = pomContent.replace(
38-
/(<artifactId>oid4vp-parent<\/artifactId>\s*\n\s*<version>)[0-9]+\.[0-9]+\.[0-9]+(?:-SNAPSHOT)?(<\/version>)/,
39-
(match, prefix, suffix) => {
40-
versionUpdated = true;
41-
return prefix + newVersion + suffix;
48+
for (const pomPath of ALL_POMS) {
49+
let pomContent = fs.readFileSync(pomPath, "utf8");
50+
let versionUpdated = false;
51+
52+
pomContent = pomContent.replace(
53+
PARENT_VERSION_PATTERN,
54+
(match, prefix, suffix) => {
55+
versionUpdated = true;
56+
return prefix + newVersion + suffix;
57+
}
58+
);
59+
60+
if (!versionUpdated) {
61+
throw new Error(`Could not update version in ${pomPath}`);
4262
}
43-
);
4463

45-
if (!versionUpdated) {
46-
throw new Error("Could not update version in oid4vp-java/pom.xml");
64+
fs.writeFileSync(pomPath, pomContent);
65+
log(`✓ Updated ${path.relative(path.join(__dirname, ".."), pomPath)} to ${newVersion}`, "green");
4766
}
48-
49-
fs.writeFileSync(POM_PATH, pomContent);
50-
log(`✓ Updated oid4vp-java/pom.xml version to ${newVersion}`, "green");
5167
}
5268

5369
function updateChangelog(version, changes) {
@@ -96,36 +112,74 @@ ${changes}
96112
log(`✓ Updated CHANGELOG.md with version ${version}`, "green");
97113
}
98114

99-
function calculateReleaseVersion(currentVersion, type) {
115+
function compareSemver(a, b) {
116+
const partsA = a.split(".").map(Number);
117+
const partsB = b.split(".").map(Number);
118+
119+
for (let i = 0; i < 3; i++) {
120+
const diff = (partsA[i] || 0) - (partsB[i] || 0);
121+
if (diff !== 0) {
122+
return diff;
123+
}
124+
}
125+
126+
return 0;
127+
}
128+
129+
function getLastReleasedVersion() {
130+
try {
131+
execSync("git status", { stdio: "ignore" });
132+
} catch {
133+
return null;
134+
}
135+
136+
try {
137+
const tags = execSync('git tag -l "v*"', { encoding: "utf8" })
138+
.trim()
139+
.split("\n")
140+
.filter(Boolean)
141+
.map((tag) => tag.replace(/^v/, ""))
142+
.sort(compareSemver);
143+
144+
return tags.length > 0 ? tags[tags.length - 1] : null;
145+
} catch {
146+
return null;
147+
}
148+
}
149+
150+
function calculateReleaseVersion(currentVersion, type, lastReleasedVersion) {
100151
const baseVersion = currentVersion.replace(/-SNAPSHOT$/, "");
101-
const parts = baseVersion.split(".").map(Number);
102152

103153
switch (type) {
104154
case "patch":
105155
return baseVersion;
106-
case "minor":
156+
case "minor": {
157+
const base = lastReleasedVersion || baseVersion;
158+
const parts = base.split(".").map(Number);
107159
parts[1]++;
108160
parts[2] = 0;
109-
break;
110-
case "major":
161+
return parts.join(".");
162+
}
163+
case "major": {
164+
const base = lastReleasedVersion || baseVersion;
165+
const parts = base.split(".").map(Number);
111166
parts[0]++;
112167
parts[1] = 0;
113168
parts[2] = 0;
114-
break;
169+
return parts.join(".");
170+
}
115171
default:
116172
throw new Error(
117173
`Invalid version type: ${type}. Use 'patch', 'minor', or 'major'`
118174
);
119175
}
120-
121-
return parts.join(".");
122176
}
123177

124178
function commitAndTag(version) {
125179
try {
126180
execSync("git status", { stdio: "ignore" });
127181

128-
execSync("git add oid4vp-java/pom.xml CHANGELOG.md");
182+
execSync(`git add ${POM_GIT_PATHS.join(" ")} CHANGELOG.md`);
129183

130184
execSync(`git commit -m "chore: release version ${version}"`, {
131185
stdio: "inherit",
@@ -146,7 +200,7 @@ function commitAndTag(version) {
146200
return true;
147201
} catch (error) {
148202
log("⚠ Git operations failed. Please commit and tag manually:", "yellow");
149-
log(` git add oid4vp-java/pom.xml CHANGELOG.md`, "cyan");
203+
log(` git add ${POM_GIT_PATHS.join(" ")} CHANGELOG.md`, "cyan");
150204
log(` git commit -m "chore: release version ${version}"`, "cyan");
151205
log(` git tag -a v${version} -m "Release version ${version}"`, "cyan");
152206
log(` git push && git push --tags`, "cyan");
@@ -164,7 +218,7 @@ function setNextSnapshotVersion(releaseVersion) {
164218
updatePomVersion(snapshotVersion);
165219

166220
try {
167-
execSync("git add oid4vp-java/pom.xml");
221+
execSync(`git add ${POM_GIT_PATHS.join(" ")}`);
168222
execSync(
169223
`git commit -m "chore: prepare next development iteration ${snapshotVersion}"`,
170224
{ stdio: "inherit" }
@@ -179,7 +233,7 @@ function setNextSnapshotVersion(releaseVersion) {
179233
return true;
180234
} catch (error) {
181235
log("\n⚠ Release was tagged successfully, but snapshot version setup failed.", "yellow");
182-
log(`Set oid4vp-java/pom.xml to ${snapshotVersion} manually and push.`, "yellow");
236+
log(`Set all pom.xml files to ${snapshotVersion} manually and push.`, "yellow");
183237
return false;
184238
}
185239
}
@@ -238,7 +292,7 @@ function main() {
238292
log(" npm run release minor # 0.1.0-SNAPSHOT -> 0.2.0 -> 0.2.1-SNAPSHOT", "cyan");
239293
log(" npm run release major # 0.1.0-SNAPSHOT -> 1.0.0 -> 1.0.1-SNAPSHOT", "cyan");
240294
log("\nThis will:", "yellow");
241-
log(" • Update oid4vp-java/pom.xml to the release version", "cyan");
295+
log(" • Update all oid4vp-java pom.xml files to the release version", "cyan");
242296
log(" • Update CHANGELOG.md", "cyan");
243297
log(" • Commit and tag the release", "cyan");
244298
log(" • Set next development version with -SNAPSHOT suffix", "cyan");
@@ -247,9 +301,30 @@ function main() {
247301
}
248302

249303
const currentVersion = getCurrentVersion();
250-
const releaseVersion = calculateReleaseVersion(currentVersion, versionType);
304+
const lastReleasedVersion = getLastReleasedVersion();
305+
const releaseVersion = calculateReleaseVersion(
306+
currentVersion,
307+
versionType,
308+
lastReleasedVersion
309+
);
251310

252311
log(`Current version: ${currentVersion}`, "blue");
312+
if (lastReleasedVersion) {
313+
log(`Last released version: ${lastReleasedVersion}`, "blue");
314+
}
315+
if (
316+
lastReleasedVersion &&
317+
versionType !== "patch" &&
318+
compareSemver(
319+
currentVersion.replace(/-SNAPSHOT$/, ""),
320+
lastReleasedVersion
321+
) > 0
322+
) {
323+
log(
324+
`Note: ${versionType} release is based on last git tag (v${lastReleasedVersion}), not the SNAPSHOT in pom.xml`,
325+
"yellow"
326+
);
327+
}
253328
log(`Release version: ${releaseVersion}`, "green");
254329
log(`Release type: ${versionType}`, "cyan");
255330
log("");
@@ -280,7 +355,9 @@ function main() {
280355
log("\n📋 Release Summary:", "bright");
281356
log(`Version: ${currentVersion} -> ${releaseVersion}`, "blue");
282357
log("Files updated:", "blue");
283-
log(" ✓ oid4vp-java/pom.xml", "green");
358+
for (const pomPath of POM_GIT_PATHS) {
359+
log(` ✓ ${pomPath}`, "green");
360+
}
284361
log(" ✓ CHANGELOG.md", "green");
285362

286363
if (!skipGit) {
@@ -307,7 +384,7 @@ function main() {
307384
log("2. Commit, tag, and push when ready", "cyan");
308385
const parts = releaseVersion.split(".").map(Number);
309386
parts[2]++;
310-
log(`3. Set oid4vp-java/pom.xml to ${parts.join(".")}-SNAPSHOT for next development`, "cyan");
387+
log(`3. Set all pom.xml files to ${parts.join(".")}-SNAPSHOT for next development`, "cyan");
311388
}
312389
}
313390

0 commit comments

Comments
 (0)