Skip to content

Commit 03bc58e

Browse files
committed
Update release automation
1 parent cb7af4b commit 03bc58e

File tree

8 files changed

+183
-45
lines changed

8 files changed

+183
-45
lines changed

.github/scripts/get-version.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash -e
2+
3+
grep "var protoVersion = " build.gradle.kts | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash -e
2+
3+
git config user.name otelbot
4+
git config user.email [email protected]
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Prepare release branch
2+
on:
3+
workflow_dispatch:
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
prereqs:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
13+
14+
- name: Verify prerequisites
15+
run: |
16+
if [[ $GITHUB_REF_NAME != main ]]; then
17+
echo this workflow should only be run against main
18+
exit 1
19+
fi
20+
21+
create-pull-request-against-release-branch:
22+
permissions:
23+
contents: write # for Git to git push
24+
runs-on: ubuntu-latest
25+
needs:
26+
- prereqs
27+
steps:
28+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
29+
30+
- name: Create release branch
31+
run: |
32+
version=$(.github/scripts/get-version.sh)
33+
if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
34+
release_branch_name="release/v${version}"
35+
release_branch_exists=$(git ls-remote --heads origin refs/heads/$release_branch_name)
36+
if [[ $release_branch_exists != "" ]] ; then
37+
echo "release branch $release_branch_name already exists"
38+
exit 1
39+
fi
40+
else
41+
echo "unexpected version: $version"
42+
exit 1
43+
fi
44+
45+
git push origin HEAD:$release_branch_name
46+
47+
echo "VERSION=$version" >> $GITHUB_ENV
48+
echo "RELEASE_BRANCH_NAME=$release_branch_name" >> $GITHUB_ENV
49+
50+
- name: Update version
51+
run: sed -Ei "s/val snapshot = true/val snapshot = false/" build.gradle.kts
52+
53+
- name: Use CLA approved bot
54+
run: .github/scripts/use-cla-approved-bot.sh
55+
56+
- uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
57+
id: otelbot-token
58+
with:
59+
app-id: ${{ vars.OTELBOT_APP_ID }}
60+
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
61+
62+
- name: Create pull request against the release branch
63+
env:
64+
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
65+
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
66+
run: |
67+
message="Prepare release $VERSION"
68+
branch="otelbot/prepare-release-${VERSION}"
69+
70+
git checkout -b $branch
71+
git commit -a -m "$message"
72+
git push --set-upstream origin $branch
73+
gh pr create --title "[$RELEASE_BRANCH_NAME] $message" \
74+
--body "$message." \
75+
--base $RELEASE_BRANCH_NAME

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
release:
10+
permissions:
11+
contents: write # for creating the release
12+
runs-on: ubuntu-latest
13+
outputs:
14+
version: ${{ steps.create-github-release.outputs.version }}
15+
steps:
16+
- run: |
17+
if [[ $GITHUB_REF_NAME != release/* ]]; then
18+
echo this workflow should only be run against release branches
19+
exit 1
20+
fi
21+
22+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
23+
24+
- uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
25+
with:
26+
distribution: temurin
27+
java-version: 17
28+
29+
- uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
30+
31+
- name: Build and publish artifacts
32+
run: ./gradlew assemble publishToSonatype closeAndReleaseSonatypeStagingRepository
33+
env:
34+
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
35+
SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
36+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
37+
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
38+
39+
- name: Set environment variables
40+
run: |
41+
version=$(.github/scripts/get-version.sh)
42+
echo "VERSION=$version" >> $GITHUB_ENV
43+
44+
- name: Generate release notes
45+
run: |
46+
cat > /tmp/release-notes.txt << EOF
47+
Java Bindings for [OTLP v$VERSION](https://github.com/open-telemetry/opentelemetry-proto/releases/tag/v$VERSION)
48+
EOF
49+
50+
- id: create-github-release
51+
name: Create GitHub release
52+
env:
53+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
run: |
55+
gh release create --target $GITHUB_REF_NAME \
56+
--title "Version $VERSION" \
57+
--notes-file /tmp/release-notes.txt \
58+
v$VERSION
59+
60+
echo "version=$VERSION" >> $GITHUB_OUTPUT

RELEASING.md

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
1-
# Versioning and releasing
1+
# Release Process
22

3-
Releases of the Java bindings for the OpenTelemetry Protocol (OTLP) follow the same versions
4-
as [releases in opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto/releases).
3+
Releases are performed in lockstep
4+
with [open-telemetry/opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto) [releases](https://github.com/open-telemetry/opentelemetry-proto/releases).
55

6-
## Starting the release
6+
## Preparing a new release
77

8-
Upon release of a new [opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto) version:
8+
Applies to major, minor and patch releases of `open-telemetry/opentelemetry-proto`.
99

10-
- Open
11-
the ["Release Build" workflow](https://github.com/open-telemetry/opentelemetry-proto-java/actions/workflows/release-build.yml)
12-
in your browser
13-
- Click the button that says "Run workflow" next to the phrase "This workflow has a
14-
`workflow_dispatch` event trigger." and then
15-
- select the `main` branch
16-
- enter the version of the new [opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto) release
17-
- click "Run workflow"
10+
* Merge a PR to `main` updating the `protoVersion` variable in `build.gradle.kts` to the version
11+
of `opentelemetry-proto` to be released
12+
* Run
13+
the [Prepare release branch workflow](https://github.com/open-telemetry/opentelemetry-proto-java/actions/workflows/prepare-release-branch.yml)
14+
* Press the "Run workflow" button, and leave the default branch `main` selected
15+
* Review and merge the pull request it creates (targeted to the release branch, which sets `snapshot = false`)
1816

19-
A successful workflow run will create:
20-
- a new [tag](https://github.com/open-telemetry/opentelemetry-proto-java/tags)
21-
- a new [release announcement](https://github.com/open-telemetry/opentelemetry-proto-java/releases)
22-
- a new release
23-
on [Maven Central](https://search.maven.org/artifact/io.opentelemetry.proto/opentelemetry-proto)
17+
## Preparing a patch release
18+
19+
TODO: Define process for releasing a patch, which should add a 4th component to
20+
the `opentelemetry-proto` release version, e.g. `v1.5.0.1`
21+
22+
## Making the release
23+
24+
* Run
25+
the [Release workflow](https://github.com/open-telemetry/opentelemetry-proto-java/actions/workflows/release.yml)
26+
* Press the "Run workflow" button, then select the release branch from the dropdown list,
27+
e.g. `release/v1.8.0`, and click the "Run workflow" button below that.
28+
* This workflow will publish artifacts to maven central and will publish a GitHub release with
29+
auto-generated release notes.
30+
31+
## Credentials
32+
33+
See [opentelemetry-java credentials](https://github.com/open-telemetry/opentelemetry-java/blob/main/RELEASING.md#credentials).

build.gradle.kts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
import com.google.protobuf.gradle.*
22
import de.undercouch.gradle.tasks.download.Download
3-
import nebula.plugin.release.git.base.TagStrategy
4-
import nebula.plugin.release.git.semver.NearestVersionLocator
53
import java.time.Duration
64

75
plugins {
86
id("com.google.protobuf")
97
id("de.undercouch.download")
108
id("io.github.gradle-nexus.publish-plugin")
11-
id("nebula.release")
129

1310
id("otel.java-conventions")
1411
id("otel.publish-conventions")
1512
}
1613

17-
release {
18-
defaultVersionStrategy = nebula.plugin.release.git.opinion.Strategies.getSNAPSHOT()
19-
}
14+
// start - updated by ./.github/workflows/prepare-release-branch.yml
15+
val snapshot = true
16+
// end
2017

21-
tasks {
22-
named("release") {
23-
mustRunAfter("snapshotSetup", "finalSetup")
24-
}
18+
// The release version of opentelemetry-proto used to generate classes
19+
var protoVersion = "1.8.0"
20+
21+
// Compute the artifact version, include the "-SNAPSHOT" suffix if not releasing
22+
// Release example: 1.5.0
23+
// Snapshot example: 1.5.0-SNAPSHOT
24+
var ver = protoVersion
25+
if (snapshot) {
26+
ver += "-SNAPSHOT"
2527
}
28+
version = ver
2629

2730
description = "Java Bindings for the OpenTelemetry Protocol (OTLP)"
2831

@@ -65,14 +68,6 @@ protobuf {
6568
}
6669
}
6770

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(release.gitReadCommands, TagStrategy()).locate().any.toString()
75-
}
7671
val protoArchive = file("$buildDir/archives/opentelemetry-proto-$protoVersion.zip")
7772

7873
tasks {

buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ publishing {
5959
}
6060
}
6161

62-
afterEvaluate {
63-
val publishToSonatype by tasks.getting
64-
val release by rootProject.tasks.existing
65-
release.configure {
66-
finalizedBy(publishToSonatype)
67-
}
68-
}
69-
7062
if (System.getenv("CI") != null) {
7163
signing {
7264
useInMemoryPgpKeys(System.getenv("GPG_PRIVATE_KEY"), System.getenv("GPG_PASSWORD"))

settings.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pluginManagement {
33
id("com.google.protobuf") version "0.9.5"
44
id("de.undercouch.download") version "5.6.0"
55
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
6-
id("nebula.release") version "20.0.0"
76
}
87
}
98

0 commit comments

Comments
 (0)