Skip to content

Commit 492a817

Browse files
author
Anuraag Agrawal
authored
Add GitHub workflows to automate releases (open-telemetry#1781)
* Add GitHub workflows to automate releases * Cleanup * Tab * Rename prepareRelease and manual patch release instructions.
1 parent 22281d6 commit 492a817

8 files changed

Lines changed: 229 additions & 110 deletions

File tree

.circleci/config.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,3 @@ workflows:
114114
jobs:
115115
- build
116116
- java11
117-
build_and_release:
118-
jobs:
119-
- release_job:
120-
filters:
121-
tags:
122-
only: /^v.*/
123-
branches:
124-
ignore: /.*/
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Releases a patch by cherrypicking commits into a release branch based on the previous
2+
# release tag.
3+
name: Patch Release Build
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: The version to tag the release with, e.g., 1.2.1, 1.2.2
9+
required: true
10+
commits:
11+
description: Comma separated list of commit shas to cherrypick
12+
required: true
13+
14+
jobs:
15+
prepare-release-branch:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
release-branch-name: ${{ steps.parse-release-branch.outputs.release-branch-name }}
19+
steps:
20+
- id: parse-release-branch
21+
name: Parse release branch name
22+
run: |
23+
# Sets the release-branch-name output to the version number with the last non-period element replaced with an 'x' and preprended with v.
24+
echo "::set-output name=release-branch-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.x/')"
25+
# Sets the release-tag-name output to the version number with the last non-period element replace with a '0' and prepended with v
26+
echo "::set-output name=release-tag-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.0/')"
27+
- id: checkout-release-branch
28+
name: Check out release branch
29+
continue-on-error: true
30+
uses: actions/checkout@v2
31+
with:
32+
ref: ${{ steps.parse-release-branch.outputs.release-branch-name }}
33+
- id: checkout-release-tag
34+
name: Check out release tag
35+
if: ${{ steps.checkout-release-branch.outcome == 'failure' }}
36+
uses: actions/checkout@v2
37+
with:
38+
ref: ${{ steps.parse-release-branch.outputs.release-tag-name }}
39+
- name: Create release branch
40+
if: ${{ steps.checkout-release-tag.outcome == 'success' }}
41+
run: |
42+
git checkout -b ${{ steps.parse-release-branch.outputs.release-branch-name }}
43+
git push --set-upstream origin ${{ steps.parse-release-branch.outputs.release-branch-name }}
44+
build:
45+
runs-on: ubuntu-latest
46+
needs: prepare-release-branch
47+
steps:
48+
- name: Checkout release branch
49+
uses: actions/checkout@v2
50+
with:
51+
ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
52+
submodules: true
53+
- uses: actions/setup-java@v1
54+
with:
55+
java-version: 11
56+
- name: Setup git name
57+
run: |
58+
git config user.name github-actions
59+
git config user.email github-actions@github.com
60+
- name: Cherrypicks
61+
if: ${{ github.event.inputs.commits != '' }}
62+
run: |
63+
git fetch origin master
64+
echo ${{ github.event.inputs.commits }} | sed -n 1'p' | tr ',' '\n' | while read word; do
65+
# Trim whitespaces and cherrypick
66+
echo $word | sed 's/ *$//g' | sed 's/^ *//g' | git cherry-pick --stdin
67+
done
68+
- uses: burrunan/gradle-cache-action@v1.5
69+
with:
70+
job-id: jdk11
71+
remote-build-cache-proxy-enabled: false
72+
arguments: build --stacktrace -Prelease.version=${{ github.event.inputs.version }}
73+
properties: |
74+
enable.docker.tests=true
75+
- name: Publish artifacts
76+
uses: burrunan/gradle-cache-action@v1.5
77+
with:
78+
job-id: jdk11
79+
remote-build-cache-proxy-enabled: false
80+
arguments: final --stacktrace -Prelease.version=${{ github.event.inputs.version }}
81+
properties: |
82+
enable.docker.tests=true
83+
env:
84+
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
85+
BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
86+
GRGIT_USER: ${{ github.actor }}
87+
GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }}
88+
- run: git push
89+
- name: Checkout master
90+
uses: actions/checkout@v2
91+
with:
92+
submodules: true
93+
- uses: burrunan/gradle-cache-action@v1.5
94+
with:
95+
job-id: jdk11
96+
remote-build-cache-proxy-enabled: false
97+
arguments: updateVersionInDocs --stacktrace -Prelease.version=${{ github.event.inputs.version }}
98+
- name: Commit README changes
99+
run: |
100+
git commit -am "README update for patch release ${{ github.event.inputs.version }}"
101+
git push
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Releases a new minor / major version from the HEAD of the main branch
2+
name: Release Build
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: The version to tag the release with, e.g., 1.2.0, 1.2.1-alpha.1
8+
required: true
9+
10+
jobs:
11+
build:
12+
name: Build and release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
submodules: true
18+
- uses: actions/setup-java@v1
19+
with:
20+
java-version: 11
21+
- uses: burrunan/gradle-cache-action@v1.5
22+
with:
23+
job-id: jdk11
24+
remote-build-cache-proxy-enabled: false
25+
arguments: updateVersionInDocs build --stacktrace -Prelease.version=${{ github.event.inputs.version }}
26+
properties: |
27+
enable.docker.tests=true
28+
- name: Setup git name
29+
run: |
30+
git config user.name github-actions
31+
git config user.email github-actions@github.com
32+
- name: Commit README updates
33+
run: git commit -am "Releasing ${{ github.event.inputs.version }}"
34+
- name: Publish artifacts
35+
run: ./gradlew final --stacktrace -Prelease.version=${{ github.event.inputs.version }}
36+
env:
37+
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
38+
BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
39+
GRGIT_USER: ${{ github.actor }}
40+
GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }}
41+
- name: Push README updates
42+
run: git push

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ verify-format:
2424
.PHONY: publish-snapshots
2525
publish-snapshots:
2626
ifeq ($(CIRCLE_BRANCH),master)
27-
./gradlew artifactoryPublish
27+
# TODO(anuraaga): Remove version specificer after next release creates a tag on master.
28+
./gradlew artifactoryPublish -Prelease.version=0.10.0-SNAPSHOT
2829
endif
2930

3031
.PHONY: publish-release-artifacts

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ repositories {
9797
}
9898
9999
dependencies {
100-
implementation('io.opentelemetry:opentelemetry-api:0.9.0-SNAPSHOT')
100+
implementation('io.opentelemetry:opentelemetry-api:0.10.0-SNAPSHOT')
101101
}
102102
```
103103

RELEASING.md

Lines changed: 55 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,22 @@
11
# OpenTelemetry Release Process
22

3-
## Tagging the Release
4-
5-
The first step in the release process is to create a release branch, bump versions, and create a tag
6-
for the release. Our release branches follow the naming convention of v<major>.<minor>.x, while the
7-
tags include the patch version v<major>.<minor>.<patch>. For example, the same branch v0.3.x would
8-
be used to create all v0.3.* tags (e.g. v0.3.0, v0.3.1).
9-
10-
In this section upstream repository refers to the main opentelemetry-java github repository.
11-
12-
Before any push to the upstream repository you need to create a
13-
[personal access token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line).
14-
15-
Note: The scripts referenced in here may or may not work as-is, depending on your operating system
16-
and command-line shell of choice. In all cases, a description of what needs to be done is also
17-
provided, for clarity.
18-
19-
1. Create the new version series (eg. `v0.10.x`) branch and push it to GitHub:
20-
21-
```bash
22-
$ MAJOR=0 MINOR=3 PATCH=0 # Set appropriately for new release
23-
$ VERSION_FILES=(
24-
build.gradle
25-
)
26-
$ git checkout -b v$MAJOR.$MINOR.x master
27-
$ git push upstream v$MAJOR.$MINOR.x
28-
```
29-
The branch will be automatically protected by the GitHub branch protection rule for release
30-
branches.
31-
32-
2. Back on the `master` branch:
33-
34-
- Change the version in the root `build.gradle` to the next minor snapshot (e.g.
35-
`0.11.0-SNAPSHOT`).
36-
37-
```bash
38-
$ git checkout -b bump-version master
39-
# Change version to next minor (but keep the `-SNAPSHOT` suffix)
40-
$ sed -i "" 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_OPEN_TELEMETRY_VERSION\)/'$MAJOR.$((MINOR+1)).0'\1/' \
41-
"${VERSION_FILES[@]}"
42-
$ ./gradlew build
43-
$ git commit -a -m "Start $MAJOR.$((MINOR+1)).0 development cycle"
44-
```
45-
46-
- Go through the normal PR review against master, and merge to the master branch on GitHub.
47-
48-
3. From the `vMajor.Minor.x` branch:
49-
50-
- Create a new branch called 'release'; change the version in the root build.gradle to remove "-SNAPSHOT" for the next release
51-
version (eg. `0.10.0`). Commit the result and tag it with the version being released (eg. "v0.10.0"):
52-
53-
```bash
54-
$ git checkout -b release v$MAJOR.$MINOR.x
55-
# Change the version to remove -SNAPSHOT
56-
$ sed -i "" 's/-SNAPSHOT\(.*CURRENT_OPEN_TELEMETRY_VERSION\)/\1/' "${VERSION_FILES[@]}"
57-
$ ./gradlew build
58-
$ git commit -a -m "Bump version to $MAJOR.$MINOR.$PATCH"
59-
$ git tag -a v$MAJOR.$MINOR.$PATCH -m "Version $MAJOR.$MINOR.$PATCH"
60-
```
61-
62-
- Change the version in the root `build.gradle` to the next patch level snapshot version (e.g.
63-
`0.10.1-SNAPSHOT`). Commit the result:
64-
65-
```bash
66-
# Change version to the next patch level and add -SNAPSHOT
67-
$ sed -i "" 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_OPEN_TELEMETRY_VERSION\)/'$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT'\1/' \
68-
"${VERSION_FILES[@]}"
69-
$ ./gradlew build
70-
$ git commit -a -m "Bump version to $MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT"
71-
```
72-
73-
- Create a PR with the current state of your 'release' branch against the `v.M.m.x` branch.
74-
*Do not merge this PR to the master branch!*
75-
Go through PR review and after approval, manually push the release tag and updated `v.M.m.x` branch
76-
to GitHub (note: do not squash the commits when you merge otherwise you
77-
will lose the release tag!):
78-
79-
```bash
80-
$ git checkout v$MAJOR.$MINOR.x
81-
$ git merge --ff-only release
82-
$ git push upstream v$MAJOR.$MINOR.x
83-
### this next step, pushing the tag, is what triggers the build that publishes the release:
84-
$ git push upstream v$MAJOR.$MINOR.$PATCH
85-
```
3+
## Starting the Release
4+
5+
Open the release build workflow in your browser [here](https://github.com/open-telemetry/opentelemetry-java/actions?query=workflow%3A%22Release+Build%22).
6+
7+
You will see a button that says "Run workflow". Press the button, enter the version number you want
8+
to release in the input field that pops up, and then press "Run workflow".
9+
10+
This triggers the release process, which builds the artifacts, updates the README with the new
11+
version numbers, commits the change to the README, publishes the artifacts, and creates and pushes
12+
a git tag with the version number.
8613

8714
## Announcement
8815

89-
Once deployment is done by Circle CI (controlled by the Bintray plugin) , go to Github [release
16+
Once the GitHub workflow completes, go to Github [release
9017
page](https://github.com/open-telemetry/opentelemetry-java/releases), press
91-
`Draft a new release` to write release notes about the new release.
18+
`Draft a new release` to write release notes about the new release. If there is already a draft
19+
release notes, just point it at the created tag.
9220

9321
You can use `git log upstream/v$MAJOR.$((MINOR-1)).x..upstream/v$MAJOR.$MINOR.x --graph --first-parent`
9422
or the Github [compare tool](https://github.com/open-telemetry/opentelemetry-java/compare/)
@@ -101,7 +29,6 @@ for a list of major changes since last release.
10129
## Update release versions in documentations and CHANGELOG files
10230

10331
After releasing is done, you need to update
104-
[README.md](https://github.com/open-telemetry/opentelemetry-java/blob/master/README.md) and
10532
[CHANGELOG.md](https://github.com/open-telemetry/opentelemetry-java/blob/master/CHANGELOG.md).
10633

10734
Create a PR to mark the new release in
@@ -111,21 +38,51 @@ on master branch.
11138
## Patch Release
11239

11340
All patch releases should include only bug-fixes, and must avoid
114-
adding/modifying the public APIs. To cherry-pick one commit use the following
115-
instructions:
41+
adding/modifying the public APIs.
42+
43+
Open the patch release build workflow in your browser [here](https://github.com/open-telemetry/opentelemetry-java/actions?query=workflow%3A%22Patch+Release+Build%22).
44+
45+
You will see a button that says "Run workflow". Press the button, enter the version number you want
46+
to release in the input field for version that pops up and the commits you want to cherrypick for the
47+
patch as a comma-separated list. Then, press "Run workflow".
48+
49+
If the commits cannot be cleanly applied to the release branch, for example because it has diverged
50+
too much from main, then the workflow will fail before building. In this case, you will need to
51+
prepare the release branch manually.
52+
53+
This example will assume patching into release branch `v1.2.x` from a git repository with remotes
54+
named `origin` and `upstream`.
55+
56+
```
57+
$ git remote -v
58+
origin git@github.com:username/opentelemetry-java.git (fetch)
59+
origin git@github.com:username/opentelemetry-java.git (push)
60+
upstream git@github.com:open-telemetry/opentelemetry-java.git (fetch)
61+
upstream git@github.com:open-telemetry/opentelemetry-java.git (push)
62+
```
63+
64+
First, checkout the release branch
65+
66+
```
67+
git fetch upstream v1.2.x
68+
git checkout upstream/v1.2.x
69+
```
11670

117-
- Create and push a tag:
71+
Apply cherrypicks manually and commit. It is ok to apply multiple cherrypicks in a single commit.
72+
Use a commit message such as "Manual cherrypick for commits commithash1, commithash2".
11873

119-
```bash
120-
COMMIT=1224f0a # Set the right commit hash.
121-
git checkout -b cherrypick v$MAJOR.$MINOR.x
122-
git cherry-pick -x $COMMIT
123-
git commit -a -m "Cherry-pick commit $COMMIT"
74+
After commiting the change, push to your fork's branch.
75+
76+
```
77+
git push origin v1.2.x
12478
```
12579

126-
- Go through PR review and merge it to GitHub v$MAJOR.$MINOR.x branch.
80+
Create a PR to have code review and merge this into upstream's release branch. As this was not
81+
applied automatically, we need to do code review to make sure the manual cherrypick is correct.
12782

128-
- Tag a new patch release when all commits are merged.
83+
After it is merged, Run the patch release workflow again, but leave the commits input field blank.
84+
The release will be made with the current state of the release branch, which is what you prepared
85+
above.
12986

13087
## Release candidates
13188

@@ -151,5 +108,6 @@ export BINTRAY_USER=my_bintray_user
151108
export BINTRAY_KEY=my_user_api_key
152109
export SONATYPE_USER=my_maven_user
153110
export SONATYPE_KEY=my_maven_password
154-
make publish-release-artifacts
111+
export RELEASE_VERSION=2.4.5 # Set version you want to release
112+
./gradlew final -Prelease.version=${RELEASE_VERSION}
155113
```

0 commit comments

Comments
 (0)