Skip to content

Commit f8562f2

Browse files
rapphilbryan-aguilarAneurysm9
authored
Add new process for patch releases (#321) (#323)
* Add new process for patch releases --------- Signed-off-by: Raphael Silva <[email protected]> Co-authored-by: bryan-aguilar <[email protected]> Co-authored-by: Anthony Mirabella <[email protected]>
1 parent d013b0f commit f8562f2

File tree

6 files changed

+269
-40
lines changed

6 files changed

+269
-40
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: "Patch dependencies"
2+
description: |
3+
Patches direct dependencies of this project leveraging maven local to publish the results.
4+
5+
This workflow supports patching opentelemetry-java and opentelemetry-java-instrumentation repositories by executing
6+
the `patch.sh` script that will try to patch those repositories and after that will optionally test and then publish
7+
the artifacts to maven local.
8+
To add a patch you have to add a file in the `.github/patches/` directory with the name of the repository that must
9+
be patched.
10+
This action assumes that java was set correctly.
11+
inputs:
12+
run_tests:
13+
default: "false"
14+
required: false
15+
description: "If the workflow should run tests of the dependencies. Anything different than false will evaluate to true"
16+
branch:
17+
required: true
18+
description: "The branch where this patches are being applied e.g.: release/v1.21.x"
19+
gpg_private_key:
20+
description: "The gpg key used to sign the artifacts"
21+
required: true
22+
gpg_password:
23+
description: "The gpg key password"
24+
required: true
25+
runs:
26+
using: "composite"
27+
steps:
28+
- name: check patches
29+
run: |
30+
if [[ -f .github/patches/${{ inputs.branch }}/opentelemetry-java.patch ]]; then
31+
echo 'patch_otel_java=true' >> $GITHUB_ENV
32+
fi
33+
if [[ -f .github/patches/${{ inputs.branch }}/opentelemetry-java-instrumentation.patch ]]; then
34+
echo 'patch_otel_java_instrumentation=true' >> $GITHUB_ENV
35+
fi
36+
if [[ -f .github/patches/${{ inputs.branch }}/opentelemetry-java-contrib.patch ]]; then
37+
echo 'patch_otel_java_contrib=true' >> $GITHUB_ENV
38+
fi
39+
shell: bash
40+
41+
- name: Clone and patch repositories
42+
run: .github/scripts/patch.sh "${{ inputs.branch }}"
43+
if: ${{ env.patch_otel_java == 'true' ||
44+
env.patch_otel_java_instrumentation == 'true' ||
45+
env.patch_otel_java_contrib == 'true' }}
46+
shell: bash
47+
48+
- name: Build opentelemetry-java with tests
49+
uses: gradle/gradle-build-action@v2
50+
if: ${{ env.patch_otel_java == 'true' && inputs.run_tests != 'false' }}
51+
with:
52+
arguments: build publishToMavenLocal
53+
build-root-directory: opentelemetry-java
54+
env:
55+
GPG_PRIVATE_KEY: ${{ inputs.gpg_private_key }}
56+
GPG_PASSWORD: ${{ inputs.gpg_password }}
57+
58+
- name: Build opentelemetry-java
59+
uses: gradle/gradle-build-action@v2
60+
if: ${{ env.patch_otel_java == 'true' && inputs.run_tests == 'false' }}
61+
with:
62+
arguments: publishToMavenLocal
63+
build-root-directory: opentelemetry-java
64+
env:
65+
GPG_PRIVATE_KEY: ${{ inputs.gpg_private_key }}
66+
GPG_PASSWORD: ${{ inputs.gpg_password }}
67+
68+
- name: Build opentelemetry-java-contrib with tests
69+
uses: gradle/gradle-build-action@v2
70+
if: ${{ env.patch_otel_java_contrib == 'true' && inputs.run_tests != 'false' }}
71+
with:
72+
arguments: build publishToMavenLocal
73+
build-root-directory: opentelemetry-java-contrib
74+
env:
75+
GPG_PRIVATE_KEY: ${{ inputs.gpg_private_key }}
76+
GPG_PASSWORD: ${{ inputs.gpg_password }}
77+
78+
- name: Build opentelemetry-java-contrib
79+
uses: gradle/gradle-build-action@v2
80+
if: ${{ env.patch_otel_java_contrib == 'true' && inputs.run_tests == 'false' }}
81+
with:
82+
arguments: publishToMavenLocal
83+
build-root-directory: opentelemetry-java-contrib
84+
env:
85+
GPG_PRIVATE_KEY: ${{ inputs.gpg_private_key }}
86+
GPG_PASSWORD: ${{ inputs.gpg_password }}
87+
88+
- name: Build opentelemetry-java-instrumentation with tests
89+
uses: gradle/gradle-build-action@v2
90+
if: ${{ env.patch_otel_java_instrumentation == 'true' && inputs.run_tests != 'false' }}
91+
with:
92+
arguments: check -x spotlessCheck publishToMavenLocal
93+
build-root-directory: opentelemetry-java-instrumentation
94+
env:
95+
GPG_PRIVATE_KEY: ${{ inputs.gpg_private_key }}
96+
GPG_PASSWORD: ${{ inputs.gpg_password }}
97+
98+
- name: Build opentelemetry java instrumentation
99+
uses: gradle/gradle-build-action@v2
100+
if: ${{ env.patch_otel_java_instrumentation == 'true' && inputs.run_tests == 'false' }}
101+
with:
102+
arguments: publishToMavenLocal
103+
build-root-directory: opentelemetry-java-instrumentation
104+
env:
105+
GPG_PRIVATE_KEY: ${{ inputs.gpg_private_key }}
106+
GPG_PASSWORD: ${{ inputs.gpg_password }}

.github/scripts/patch.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
# Enable debug mode, fail on any command that fail in this script and fail on unset variables
3+
set -x -e -u
4+
5+
# This parameter will help find the patches to be applied
6+
BRANCH=$1
7+
8+
# .github/patches/$BRANCH/versions.sh should define all the versions of the dependencies that we are going to patch
9+
# This is used so that we can properly clone the upstream repositories.
10+
# This file should define the following variables:
11+
# OTEL_JAVA_VERSION. Tag of the opentelemetry-java repository to use. E.g.: JAVA_OTEL_JAVA_VERSION=v1.21.0
12+
# OTEL_JAVA_INSTRUMENTATION_VERSION. Tag of the opentelemetry-java-instrumentation repository to use, e.g.: OTEL_JAVA_INSTRUMENTATION_VERSION=v1.21.0
13+
# OTEL_JAVA_CONTRIB_VERSION. Tag of the opentelemetry-java-contrib repository. E.g.: OTEL_JAVA_CONTRIB_VERSION=v1.21.0
14+
# This script will fail if a variable that is supposed to exist is referenced.
15+
16+
if [[ ! -f .github/patches/${BRANCH}/versions ]]; then
17+
echo "No versions file found. Skipping patching"
18+
exit 0
19+
fi
20+
21+
source .github/patches/${BRANCH}/versions
22+
23+
git config --global user.email "[email protected]"
24+
git config --global user.name "ADOT Patch workflow"
25+
26+
27+
OTEL_JAVA_PATCH=".github/patches/${BRANCH}/opentelemetry-java.patch"
28+
if [[ -f "$OTEL_JAVA_PATCH" ]]; then
29+
git clone https://github.com/open-telemetry/opentelemetry-java.git
30+
cd opentelemetry-java
31+
git checkout ${OTEL_JAVA_VERSION} -b tag-${OTEL_JAVA_VERSION}
32+
patch -p1 < ../${OTEL_JAVA_PATCH}
33+
git commit -a -m "ADOT Patch release"
34+
cd -
35+
else
36+
echo "Skiping patching opentelemetry-java"
37+
fi
38+
39+
40+
OTEL_JAVA_CONTRIB_PATCH=".github/patches/${BRANCH}/opentelemetry-java-contrib.patch"
41+
if [[ -f "$OTEL_JAVA_CONTRIB_PATCH" ]]; then
42+
git clone https://github.com/open-telemetry/opentelemetry-java-contrib.git
43+
cd opentelemetry-java-contrib
44+
git checkout ${OTEL_JAVA_CONTRIB_VERSION} -b tag-${OTEL_JAVA_CONTRIB_VERSION}
45+
patch -p1 < "../${OTEL_JAVA_CONTRIB_PATCH}"
46+
git commit -a -m "ADOT Patch release"
47+
cd -
48+
else
49+
echo "Skipping patching opentelemetry-java-contrib"
50+
fi
51+
52+
53+
OTEL_JAVA_INSTRUMENTATION_PATCH=".github/patches/${BRANCH}/opentelemetry-java-instrumentation.patch"
54+
if [[ -f "$OTEL_JAVA_INSTRUMENTATION_PATCH" ]]; then
55+
git clone https://github.com/open-telemetry/opentelemetry-java-instrumentation.git
56+
cd opentelemetry-java-instrumentation
57+
git checkout ${OTEL_JAVA_INSTRUMENTATION_VERSION} -b tag-${OTEL_JAVA_INSTRUMENTATION_VERSION}
58+
patch -p1 < "../${OTEL_JAVA_INSTRUMENTATION_PATCH}"
59+
git commit -a -m "ADOT Patch release"
60+
cd -
61+
else
62+
echo "Skipping patching opentelemetry-java-instrumentation"
63+
fi

.github/workflows/main-build.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
push:
44
branches:
55
- main
6-
6+
- "release/v*"
77
env:
88
AWS_DEFAULT_REGION: us-east-1
99

@@ -12,15 +12,43 @@ permissions:
1212
contents: read
1313

1414
jobs:
15+
testpatch:
16+
name: Test patches applied to dependencies
17+
runs-on: ubuntu-latest
18+
if: ${{ startsWith(github.ref_name, 'release/v') }}
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: actions/setup-java@v3
22+
with:
23+
java-version: 17
24+
distribution: temurin
25+
- uses: gradle/wrapper-validation-action@v1
26+
- uses: ./.github/actions/patch-dependencies
27+
with:
28+
run_tests: "true"
29+
branch: ${{ github.ref_name }}
30+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
31+
gpg_password: ${{ secrets.GPG_PASSPHRASE }}
32+
1533
build:
1634
runs-on: ubuntu-latest
1735
steps:
1836
- uses: actions/checkout@v2
1937
with:
2038
fetch-depth: 0
21-
- uses: actions/setup-java@v1
39+
- uses: actions/setup-java@v3
2240
with:
2341
java-version: 17
42+
distribution: temurin
43+
44+
- name: Publish patched dependencies to maven local
45+
uses: ./.github/actions/patch-dependencies
46+
if: ${{ startsWith(github.ref_name, 'release/v') }}
47+
with:
48+
branch: ${{ github.ref_name }}
49+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
50+
gpg_password: ${{ secrets.GPG_PASSPHRASE }}
51+
2452
- uses: gradle/wrapper-validation-action@v1
2553
- name: Configure AWS Credentials
2654
uses: aws-actions/configure-aws-credentials@v1

.github/workflows/pr-build.yml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,30 @@ on:
33
pull_request:
44
branches:
55
- main
6+
- "release/v*"
67

78
jobs:
9+
testpatch:
10+
name: Test patches applied to dependencies
11+
runs-on: ubuntu-latest
12+
if: ${{ startsWith(github.event.pull_request.base.ref, 'release/v') }}
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- uses: actions/setup-java@v3
17+
with:
18+
java-version: 17
19+
distribution: temurin
20+
21+
- uses: gradle/wrapper-validation-action@v1
22+
23+
- uses: ./.github/actions/patch-dependencies
24+
with:
25+
run_tests: "true"
26+
branch: ${{ github.event.pull_request.base.ref }}
27+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
28+
gpg_password: ${{ secrets.GPG_PASSPHRASE }}
29+
830
build:
931
name: Build on ${{ matrix.os }}
1032
runs-on: ${{ matrix.os }}
@@ -14,17 +36,37 @@ jobs:
1436
- macos-latest
1537
- ubuntu-latest
1638
- windows-latest
39+
exclude:
40+
# Skip windows on patch workflow because it is not possible to build opentelemetry-java on windows
41+
# when the cache is in a different drive than the source code
42+
# Windows is not working for patch workflows, therefore we disable it here
43+
# https://github.com/square/wire/issues/2188
44+
# https://github.com/open-telemetry/opentelemetry-java/issues/4560
45+
- os: ${{ startsWith(github.event.pull_request.base.ref, 'release/v') && 'windows-latest' || '' }}
1746
steps:
1847
- uses: actions/checkout@v2
19-
- uses: actions/setup-java@v1
48+
49+
- uses: actions/setup-java@v3
2050
with:
2151
java-version: 17
52+
distribution: temurin
53+
2254
- uses: gradle/wrapper-validation-action@v1
55+
56+
- name: Publish patched dependencies to maven local
57+
uses: ./.github/actions/patch-dependencies
58+
if: ${{ startsWith(github.event.pull_request.base.ref, 'release/v') }}
59+
with:
60+
branch: ${{ github.event.pull_request.base.ref }}
61+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
62+
gpg_password: ${{ secrets.GPG_PASSPHRASE }}
63+
2364
- name: Build with Gradle with Integration tests
24-
if: ${{ matrix.os == 'ubuntu-latest' }}
2565
uses: gradle/gradle-build-action@v2
66+
if: ${{ matrix.os == 'ubuntu-latest' }}
2667
with:
2768
arguments: build integrationTests --stacktrace -PenableCoverage=true -PlocalDocker=true
69+
2870
- name: Build with Gradle
2971
uses: gradle/gradle-build-action@v2
3072
if: ${{ matrix.os != 'ubuntu-latest' }}

.github/workflows/release-build.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ jobs:
2222
with:
2323
java-version: 17
2424
- uses: gradle/wrapper-validation-action@v1
25+
26+
- name: Publish patched dependencies to maven local
27+
uses: ./.github/actions/patch-dependencies
28+
if: ${{ startsWith(github.ref_name, 'release/v') }}
29+
with:
30+
branch: ${{ github.ref_name }}
31+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
32+
gpg_password: ${{ secrets.GPG_PASSPHRASE }}
33+
2534
- name: Configure AWS Credentials
2635
uses: aws-actions/configure-aws-credentials@v1
2736
with:

RELEASING.md

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -36,49 +36,30 @@ to view a summary of all commits since last release as a reference.
3636
All patch releases should include only bug-fixes, and must avoid
3737
adding/modifying the public APIs.
3838

39-
Open the patch release build workflow in your browser [here](https://github.com/aws-observability/aws-otel-java-instrumentation/actions?query=workflow%3A%22Patch+Release+Build%22).
39+
Steps:
40+
1. Create a branch from the release that you want to patch. It should follow the convention `release/v<major>.<minor>.x`. E.g.: if you want to patch release 1.21.0, the name of the branch should be `release/v1.21.x`.
41+
1. Modify the source code/dependencies. You can only update the patch version of opentelemetry dependencies.
42+
1. Optionally prepare patches that can be applied to opentelemetry-java and opentelemetry-java-instrumentation. More details about this in the following section.
43+
1. Create pull request to merge in the release branch.
4044

41-
You will see a button that says "Run workflow". Press the button, enter the version number you want
42-
to release in the input field for version that pops up and the commits you want to cherrypick for the
43-
patch as a comma-separated list. Then, press "Run workflow".
44-
45-
If the commits cannot be cleanly applied to the release branch, for example because it has diverged
46-
too much from main, then the workflow will fail before building. In this case, you will need to
47-
prepare the release branch manually.
45+
After the pull request is merged, open the release build workflow in your browser [here](https://github.com/aws-observability/aws-otel-java-instrumentation/actions?query=workflow%3A%22Release+Build%22).
4846

49-
This example will assume patching into release branch `v1.2.x` from a git repository with remotes
50-
named `origin` and `upstream`.
47+
Select the branch and provide the version.
5148

52-
```
53-
$ git remote -v
54-
origin [email protected]:username/opentelemetry-java.git (fetch)
55-
origin [email protected]:username/opentelemetry-java.git (push)
56-
upstream [email protected]:open-telemetry/opentelemetry-java.git (fetch)
57-
upstream [email protected]:open-telemetry/opentelemetry-java.git (push)
58-
```
49+
### Patching upstream dependencies
5950

60-
First, checkout the release branch
51+
If you need to patch upstream dependencies, you need:
6152

62-
```
63-
git fetch upstream v1.2.x
64-
git checkout upstream/v1.2.x
65-
```
66-
67-
Apply cherrypicks manually and commit. It is ok to apply multiple cherrypicks in a single commit.
68-
Use a commit message such as "Manual cherrypick for commits commithash1, commithash2".
69-
70-
After commiting the change, push to your fork's branch.
71-
72-
```
73-
git push origin v1.2.x
74-
```
53+
* Provide patch files for each repository that will need to be patched. These files should be located in `.github/patches/release/v<major>.<minor>.x` and should be named
54+
using the convention `<repository name>.patch`. The following repositories are supported: opentelemetry-java, opentelemetry-java-instrumentation and opentelemetry-java-contrib. Provide one patch file per repository. The adot patch version of each upstream dependency should be `<version>-adot<number>` where `version` is the version of the upstream dependency and `number` is the number of this patch that should be incremented from 1 per patch version.
7555

76-
Create a PR to have code review and merge this into upstream's release branch. As this was not
77-
applied automatically, we need to do code review to make sure the manual cherrypick is correct.
56+
* Create a `versions` file in the directory `.github/patches/release/v<major>.<minor>.x`. This file should contain shell variables with the versions of the tags of the repositories which will receive patches.
57+
This file should define the following variables:
58+
* `OTEL_JAVA_VERSION`. Tag of the opentelemetry-java repository to use. E.g.: `JAVA_OTEL_JAVA_VERSION=v1.21.0`
59+
* `OTEL_JAVA_INSTRUMENTATION_VERSION`. Tag of the opentelemetry-java-instrumentation repository to use, e.g.: `OTEL_JAVA_INSTRUMENTATION_VERSION=v1.21.0`
60+
* `OTEL_JAVA_CONTRIB_VERSION`. Tag of the opentelemetry-java-contrib repository. E.g.: `OTEL_JAVA_CONTRIB_VERSION=v1.21.0`
7861

79-
After it is merged, Run the patch release workflow again, but leave the commits input field blank.
80-
The release will be made with the current state of the release branch, which is what you prepared
81-
above.
62+
During the build, ephemeral artifacts will be generated and stored into maven local and those will be used to build the ADOT Java Agent.
8263

8364
## Release candidates
8465

0 commit comments

Comments
 (0)