Skip to content

Commit 835072e

Browse files
authored
Add build tooling to support releasing patches, i.e. 1.3.2.1 (#18)
1 parent f8f2b13 commit 835072e

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

.github/workflows/release-build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: The version to tag the release with, e.g., 1.2.0, 1.2.1-alpha.1
7+
description: The version to tag the release with, e.g., 1.2.0, 1.2.1-alpha, or 1.2.0.1 for a patch release of the 1.2.0 proto release
88
required: true
99

1010
jobs:
@@ -26,14 +26,14 @@ jobs:
2626
remote-build-cache-proxy-enabled: false
2727
arguments: build --stacktrace
2828
properties: |
29-
release.version=${{ github.event.inputs.version }}
29+
release.version.prop=${{ github.event.inputs.version }}
3030
org.gradle.java.installations.paths=${{ steps.setup-java-17.outputs.path }}
3131
- uses: burrunan/[email protected]
3232
with:
3333
remote-build-cache-proxy-enabled: false
3434
arguments: final closeAndReleaseSonatypeStagingRepository --stacktrace
3535
properties: |
36-
release.version=${{ github.event.inputs.version }}
36+
release.version.prop=${{ github.event.inputs.version }}
3737
org.gradle.java.installations.paths=${{ steps.setup-java-17.outputs.path }}
3838
env:
3939
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ is [0.20.0](https://github.com/open-telemetry/opentelemetry-proto-java/tree/v0.2
4848
downloaded from
4949
the [v0.20.0 release](https://github.com/open-telemetry/opentelemetry-proto/releases/tag/v0.20.0).
5050
This can be overridden for the build or other gradle tasks (e.g. `publishToMavenLocal`)
51-
with `-Prelease.version`:
51+
with `-Prelease.version.prop`:
5252

5353
```shell
54-
./gradlew build -Prelease.version=1.0.0
54+
./gradlew build -Prelease.version.prop=1.0.0
5555
```
5656

5757
## Support

build.gradle.kts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,32 @@ plugins {
1414
id("otel.publish-conventions")
1515
}
1616

17+
// Resolve protoVersion and releaseVersion
18+
// If user provides property release.version.prop match against releaseVersionRegex. protoVersion is the semconv matching group (i.e. for release.version.prop=1.3.2.1, protoVersion is 1.3.2). releaseVersion is the value of the release.version.prop.
19+
// Else, set protoVersion and releaseVersion to the most recent git tag.
20+
// The releaseVersion is used to set the nebular release plugin release version. Note, the release.version.prop is used because the nebula release plugin verifies release.version matches semconv.
21+
// The protoVersion is used to download sources from opentelemetry-proto..
22+
var protoVersion = "unknown"
23+
var releaseVersion = "unknown"
24+
if (properties.contains("release.version.prop")) {
25+
val releaseVersionProperty = properties.get("release.version.prop") as String
26+
val matchResult = "^(?<protoversion>([0-9]*)\\.([0-9]*)\\.([0-9]*)).*\$".toRegex().matchEntire(releaseVersionProperty)
27+
if (matchResult == null) {
28+
throw GradleException("Invalid value for release.version.prop")
29+
}
30+
protoVersion = matchResult.groups["protoversion"]?.value as String
31+
releaseVersion = releaseVersionProperty
32+
} else {
33+
protoVersion = NearestVersionLocator(TagStrategy()).locate(release.grgit).any.toString()
34+
releaseVersion = protoVersion
35+
}
36+
logger.lifecycle("proto version: " + protoVersion)
37+
logger.lifecycle("release version: " + releaseVersion)
38+
39+
val protoArchive = file("$buildDir/archives/opentelemetry-proto-$protoVersion.zip")
40+
1741
release {
42+
version = releaseVersion
1843
defaultVersionStrategy = nebula.plugin.release.git.opinion.Strategies.getSNAPSHOT()
1944
}
2045

@@ -65,16 +90,6 @@ protobuf {
6590
}
6691
}
6792

68-
// Proto version is set from -Prelease.version or inferred from the latest tag
69-
var protoVersion = if (properties.contains(
70-
"release.version"
71-
)) {
72-
properties.get("release.version") as String
73-
} else {
74-
NearestVersionLocator(TagStrategy()).locate(release.grgit).any.toString()
75-
}
76-
val protoArchive = file("$buildDir/archives/opentelemetry-proto-$protoVersion.zip")
77-
7893
tasks {
7994
val downloadProtoArchive by registering(Download::class) {
8095
onlyIf { !protoArchive.exists() }

0 commit comments

Comments
 (0)