diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index aa7abe2..1995698 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: version: - description: The version to tag the release with, e.g., 1.2.0, 1.2.1-alpha.1 + 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 required: true jobs: @@ -26,14 +26,14 @@ jobs: remote-build-cache-proxy-enabled: false arguments: build --stacktrace properties: | - release.version=${{ github.event.inputs.version }} + release.version.prop=${{ github.event.inputs.version }} org.gradle.java.installations.paths=${{ steps.setup-java-17.outputs.path }} - uses: burrunan/gradle-cache-action@v1.10 with: remote-build-cache-proxy-enabled: false arguments: final closeAndReleaseSonatypeStagingRepository --stacktrace properties: | - release.version=${{ github.event.inputs.version }} + release.version.prop=${{ github.event.inputs.version }} org.gradle.java.installations.paths=${{ steps.setup-java-17.outputs.path }} env: SONATYPE_USER: ${{ secrets.SONATYPE_USER }} diff --git a/README.md b/README.md index e770efe..2bf45ae 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,10 @@ is [0.20.0](https://github.com/open-telemetry/opentelemetry-proto-java/tree/v0.2 downloaded from the [v0.20.0 release](https://github.com/open-telemetry/opentelemetry-proto/releases/tag/v0.20.0). This can be overridden for the build or other gradle tasks (e.g. `publishToMavenLocal`) -with `-Prelease.version`: +with `-Prelease.version.prop`: ```shell -./gradlew build -Prelease.version=1.0.0 +./gradlew build -Prelease.version.prop=1.0.0 ``` ## Support diff --git a/build.gradle.kts b/build.gradle.kts index 4807f6c..91671e2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,7 +14,32 @@ plugins { id("otel.publish-conventions") } +// Resolve protoVersion and releaseVersion +// 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. +// Else, set protoVersion and releaseVersion to the most recent git tag. +// 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. +// The protoVersion is used to download sources from opentelemetry-proto.. +var protoVersion = "unknown" +var releaseVersion = "unknown" +if (properties.contains("release.version.prop")) { + val releaseVersionProperty = properties.get("release.version.prop") as String + val matchResult = "^(?([0-9]*)\\.([0-9]*)\\.([0-9]*)).*\$".toRegex().matchEntire(releaseVersionProperty) + if (matchResult == null) { + throw GradleException("Invalid value for release.version.prop") + } + protoVersion = matchResult.groups["protoversion"]?.value as String + releaseVersion = releaseVersionProperty +} else { + protoVersion = NearestVersionLocator(TagStrategy()).locate(release.grgit).any.toString() + releaseVersion = protoVersion +} +logger.lifecycle("proto version: " + protoVersion) +logger.lifecycle("release version: " + releaseVersion) + +val protoArchive = file("$buildDir/archives/opentelemetry-proto-$protoVersion.zip") + release { + version = releaseVersion defaultVersionStrategy = nebula.plugin.release.git.opinion.Strategies.getSNAPSHOT() } @@ -65,16 +90,6 @@ protobuf { } } -// Proto version is set from -Prelease.version or inferred from the latest tag -var protoVersion = if (properties.contains( - "release.version" - )) { - properties.get("release.version") as String -} else { - NearestVersionLocator(TagStrategy()).locate(release.grgit).any.toString() -} -val protoArchive = file("$buildDir/archives/opentelemetry-proto-$protoVersion.zip") - tasks { val downloadProtoArchive by registering(Download::class) { onlyIf { !protoArchive.exists() }