Skip to content

Commit 236b9e6

Browse files
author
Anuraag Agrawal
authored
Add release workflows (#62)
* Add release workflows * Create release
1 parent 90c7d6e commit 236b9e6

File tree

3 files changed

+301
-0
lines changed

3 files changed

+301
-0
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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: false
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+
28+
- id: checkout-release-branch
29+
name: Check out release branch
30+
continue-on-error: true
31+
uses: actions/[email protected]
32+
with:
33+
ref: ${{ steps.parse-release-branch.outputs.release-branch-name }}
34+
fetch-depth: 0
35+
36+
- id: checkout-release-tag
37+
name: Check out release tag
38+
if: ${{ steps.checkout-release-branch.outcome == 'failure' }}
39+
uses: actions/[email protected]
40+
with:
41+
ref: ${{ steps.parse-release-branch.outputs.release-tag-name }}
42+
fetch-depth: 0
43+
44+
- name: Create release branch
45+
if: ${{ steps.checkout-release-tag.outcome == 'success' }}
46+
run: |
47+
git checkout -b ${{ steps.parse-release-branch.outputs.release-branch-name }}
48+
git push --set-upstream origin ${{ steps.parse-release-branch.outputs.release-branch-name }}
49+
50+
build:
51+
name: build
52+
needs: prepare-release-branch
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v2
56+
with:
57+
fetch-depth: 0
58+
- name: Setup Java 11
59+
uses: actions/setup-java@v2
60+
with:
61+
distribution: adopt
62+
java-version: 11
63+
- uses: burrunan/gradle-cache-action@v1
64+
name: Build
65+
with:
66+
arguments: --stacktrace build
67+
remote-build-cache-proxy-enabled: false
68+
- uses: actions/upload-artifact@v2
69+
name: Save unit test results
70+
if: always()
71+
with:
72+
name: test-results
73+
path: jmx-metrics/build/reports/tests/test
74+
integration-test:
75+
name: integration-test
76+
needs: prepare-release-branch
77+
runs-on: ubuntu-latest
78+
steps:
79+
- uses: actions/checkout@v2
80+
with:
81+
fetch-depth: 0
82+
- name: Setup Java 11
83+
uses: actions/setup-java@v2
84+
with:
85+
distribution: adopt
86+
java-version: 11
87+
- uses: burrunan/gradle-cache-action@v1
88+
name: Integration Tests
89+
with:
90+
arguments: --stacktrace integrationTest
91+
remote-build-cache-proxy-enabled: false
92+
- uses: actions/upload-artifact@v2
93+
name: Save integrationTest results
94+
if: always()
95+
with:
96+
name: integration-test-results
97+
path: jmx-metrics/build/reports/tests/test
98+
publish:
99+
name: publish
100+
runs-on: ubuntu-latest
101+
needs: [ build, integration-test ]
102+
steps:
103+
- uses: actions/checkout@v2
104+
with:
105+
fetch-depth: 0
106+
- name: Setup Java 11
107+
uses: actions/setup-java@v2
108+
with:
109+
distribution: adopt
110+
java-version: 11
111+
- uses: burrunan/gradle-cache-action@v1
112+
name: Publish
113+
with:
114+
arguments: --stacktrace final closeAndReleaseSonatypeStagingRepository -Prelease.version=${{ github.event.inputs.version }}
115+
env:
116+
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
117+
SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
118+
GRGIT_USER: ${{ github.actor }}
119+
GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }}
120+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
121+
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
122+
- name: Create Release
123+
id: create_release
124+
uses: actions/[email protected]
125+
env:
126+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+
with:
128+
tag_name: v${{ github.event.inputs.version }}
129+
release_name: Release v${{ github.event.inputs.version }}
130+
draft: true
131+
prerelease: false
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
- name: Setup Java 11
19+
uses: actions/setup-java@v2
20+
with:
21+
distribution: adopt
22+
java-version: 11
23+
- uses: burrunan/gradle-cache-action@v1
24+
name: Build
25+
with:
26+
arguments: --stacktrace build
27+
remote-build-cache-proxy-enabled: false
28+
- uses: actions/upload-artifact@v2
29+
name: Save unit test results
30+
if: always()
31+
with:
32+
name: test-results
33+
path: jmx-metrics/build/reports/tests/test
34+
integration-test:
35+
name: integration-test
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v2
39+
with:
40+
fetch-depth: 0
41+
- name: Setup Java 11
42+
uses: actions/setup-java@v2
43+
with:
44+
distribution: adopt
45+
java-version: 11
46+
- uses: burrunan/gradle-cache-action@v1
47+
name: Integration Tests
48+
with:
49+
arguments: --stacktrace integrationTest
50+
remote-build-cache-proxy-enabled: false
51+
- uses: actions/upload-artifact@v2
52+
name: Save integrationTest results
53+
if: always()
54+
with:
55+
name: integration-test-results
56+
path: jmx-metrics/build/reports/tests/test
57+
publish:
58+
name: publish
59+
runs-on: ubuntu-latest
60+
needs: [build, integration-test]
61+
steps:
62+
- uses: actions/checkout@v2
63+
with:
64+
fetch-depth: 0
65+
- name: Setup Java 11
66+
uses: actions/setup-java@v2
67+
with:
68+
distribution: adopt
69+
java-version: 11
70+
- uses: burrunan/gradle-cache-action@v1
71+
name: Publish
72+
with:
73+
arguments: --stacktrace final closeAndReleaseSonatypeStagingRepository -Prelease.version=${{ github.event.inputs.version }}
74+
env:
75+
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
76+
SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
77+
GRGIT_USER: ${{ github.actor }}
78+
GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }}
79+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
80+
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
81+
- name: Create Release
82+
id: create_release
83+
uses: actions/[email protected]
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
with:
87+
tag_name: v${{ github.event.inputs.version }}
88+
release_name: Release v${{ github.event.inputs.version }}
89+
draft: true
90+
prerelease: false

RELEASING.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Versioning and releasing
2+
3+
OpenTelemetry Java Contrib uses [SemVer standard](https://semver.org) for versioning of its artifacts.
4+
5+
Instead of manually specifying project version (and by extension the version of built artifacts)
6+
in gradle build scripts, we use [nebula-release-plugin](https://github.com/nebula-plugins/nebula-release-plugin)
7+
to calculate the current version based on git tags. This plugin looks for the latest tag of the form
8+
`vX.Y.Z` on the current branch and calculates the current project version as `vX.Y.(Z+1)-SNAPSHOT`.
9+
10+
## Snapshot builds
11+
Every successful CI build of the master branch automatically executes `./gradlew snapshot` as the last task.
12+
This signals Nebula plugin to build and publish to
13+
[Sonatype OSS snapshots repository](https://oss.sonatype.org/content/repositories/snapshots/io/opentelemetry/)
14+
next _minor_ release version. This means version `vX.(Y+1).0-SNAPSHOT`.
15+
16+
## Starting the Release
17+
18+
Open the release build workflow in your browser [here](https://github.com/open-telemetry/opentelemetry-java-contrib/actions/workflows/release-build.yml).
19+
20+
You will see a button that says "Run workflow". Press the button, enter the version number you want
21+
to release in the input field that pops up, and then press "Run workflow".
22+
23+
This triggers the release process, which builds the artifacts, publishes the artifacts, and creates
24+
and pushes a git tag with the version number.
25+
26+
## Announcement
27+
28+
Once the GitHub workflow completes, go to Github [release
29+
page](https://github.com/open-telemetry/opentelemetry-java-contrib/releases), press
30+
`Draft a new release` to write release notes about the new release. If there is already a draft
31+
release notes, just point it at the created tag.
32+
33+
## Patch Release
34+
35+
All patch releases should include only bug-fixes, and must avoid
36+
adding/modifying the public APIs.
37+
38+
Open the patch release build workflow in your browser [here](https://github.com/open-telemetry/opentelemetry-java-contrib/actions/workflows/patch-release-build.yml).
39+
40+
You will see a button that says "Run workflow". Press the button, enter the version number you want
41+
to release in the input field for version that pops up and the commits you want to cherrypick for the
42+
patch as a comma-separated list. Then, press "Run workflow".
43+
44+
If the commits cannot be cleanly applied to the release branch, for example because it has diverged
45+
too much from main, then the workflow will fail before building. In this case, you will need to
46+
prepare the release branch manually.
47+
48+
This example will assume patching into release branch `v1.2.x` from a git repository with remotes
49+
named `origin` and `upstream`.
50+
51+
```
52+
$ git remote -v
53+
origin [email protected]:username/opentelemetry-java-contrib.git (fetch)
54+
origin [email protected]:username/opentelemetry-java-contrib.git (push)
55+
upstream [email protected]:open-telemetry/opentelemetry-java-contrib.git (fetch)
56+
upstream [email protected]:open-telemetry/opentelemetry-java-contrib.git (push)
57+
```
58+
59+
First, checkout the release branch
60+
61+
```
62+
git fetch upstream v1.2.x
63+
git checkout upstream/v1.2.x
64+
```
65+
66+
Apply cherrypicks manually and commit. It is ok to apply multiple cherrypicks in a single commit.
67+
Use a commit message such as "Manual cherrypick for commits commithash1, commithash2".
68+
69+
After committing the change, push to your fork's branch.
70+
71+
```
72+
git push origin v1.2.x
73+
```
74+
75+
Create a PR to have code review and merge this into upstream's release branch. As this was not
76+
applied automatically, we need to do code review to make sure the manual cherrypick is correct.
77+
78+
After it is merged, Run the patch release workflow again, but leave the commits input field blank.
79+
The release will be made with the current state of the release branch, which is what you prepared
80+
above.

0 commit comments

Comments
 (0)