Skip to content

Commit 70b3bdf

Browse files
committed
Pin japicmp baseline in version.gradle.kts (atomic with apidiff snapshots)
Replace the dynamic 'latest.release' lookup in otel.japicmp-conventions.gradle.kts with a pinned property declared in version.gradle.kts. The post-release workflow now bumps that property in the same PR that regenerates docs/apidiffs/current_vs_latest/*.txt, so the baseline and the snapshot files always move together. Without this change, the moment a release is published to Maven Central every PR against main starts failing the apidiff check until the post-release PR lands: the live latest.release resolution flips to the new version, but the apidiff snapshots committed to the repo are still against the previous one.
1 parent 58a77f9 commit 70b3bdf

3 files changed

Lines changed: 21 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ jobs:
267267
PRIOR_VERSION: ${{ needs.release.outputs.prior-version }}
268268
run: |
269269
./gradlew japicmp -PapiBaseVersion=$PRIOR_VERSION -PapiNewVersion=$VERSION
270+
# Bump the pinned apidiff baseline so that the next `./gradlew japicmp` invocation
271+
# (and every subsequent build on main) compares against the just-released version.
272+
sed -i "s/^val apidiffBaselineVersion = .*/val apidiffBaselineVersion = \"$VERSION\"/" version.gradle.kts
270273
./gradlew --refresh-dependencies japicmp
271274
272275
- name: Use CLA approved bot
@@ -291,6 +294,7 @@ jobs:
291294
git checkout -b $branch
292295
git add CHANGELOG.md
293296
git add docs/apidiffs
297+
git add version.gradle.kts
294298
git commit -m "$message"
295299
git push --set-upstream origin $branch
296300
gh pr create --title "$message" \

conventions/src/main/kotlin/otel.japicmp-conventions.gradle.kts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,16 @@ plugins {
1111
}
1212

1313
/**
14-
* The latest *released* version of the project. Evaluated lazily so the work is only done if necessary.
14+
* The baseline version that japicmp compares against. Pinned in version.gradle.kts and bumped by
15+
* the post-release "update apidiff baseline" PR (see .github/workflows/release.yml). This avoids
16+
* the chicken-and-egg problem of resolving `latest.release` against Maven Central live: with a
17+
* dynamic lookup, every PR against main started failing japicmp the moment a new release was
18+
* published, until the post-release PR landed. With a pinned baseline, the version that japicmp
19+
* uses moves atomically with the docs/apidiffs/current_vs_latest/*.txt snapshots that the
20+
* post-release PR regenerates.
1521
*/
16-
val latestReleasedVersion: String by lazy {
17-
// hack to find the current released version of the project
18-
val temp: Configuration = configurations.create("tempConfig")
19-
temp.resolutionStrategy.cacheDynamicVersionsFor(0, TimeUnit.SECONDS)
20-
// pick the bom, since we don't use dependency substitution on it.
21-
dependencies.add(temp.name, "io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:latest.release")
22-
val moduleVersion = configurations["tempConfig"].resolvedConfiguration.firstLevelModuleDependencies.elementAt(0).moduleVersion
23-
24-
configurations.remove(temp)
25-
logger.info("Discovered latest release version: $moduleVersion")
26-
moduleVersion
27-
}
22+
val latestReleasedVersion: String =
23+
rootProject.extra["apidiffBaselineVersion"] as String
2824
2925
/**
3026
* Locate the project's artifact of a particular version.

version.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
val stableVersion = "2.27.0-SNAPSHOT"
22
val alphaVersion = "2.27.0-alpha-SNAPSHOT"
33

4+
// Baseline for japicmp's API-diff comparison. Bumped to the just-released version by the
5+
// post-release "update apidiff baseline" PR opened from .github/workflows/release.yml. Until
6+
// that PR lands, the baseline stays at the previous release so the snapshots checked into
7+
// docs/apidiffs/current_vs_latest/ continue to match — PRs against main don't break the moment
8+
// a new version is published to Maven Central.
9+
val apidiffBaselineVersion = "2.26.1"
10+
411
allprojects {
512
if (findProperty("otel.stable") != "true") {
613
version = alphaVersion
714
} else {
815
version = stableVersion
916
}
17+
extra["apidiffBaselineVersion"] = apidiffBaselineVersion
1018
}

0 commit comments

Comments
 (0)