Copy in release build workflow from opentelemetry-java (#1450)

* Copy in release build workflow from opentelemetry-java

* Fixes

* spot
This commit is contained in:
Anuraag Agrawal 2020-10-26 16:24:02 +09:00 committed by GitHub
parent 7244dbf188
commit 8650bd7bda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 175 additions and 17 deletions

View File

@ -0,0 +1,82 @@
# Releases a patch by cherrypicking commits into a release branch based on the previous
# release tag.
name: Patch Release Build
on:
workflow_dispatch:
inputs:
version:
description: The version to tag the release with, e.g., 1.2.1, 1.2.2
required: true
commits:
description: Comma separated list of commit shas to cherrypick
required: true
jobs:
prepare-release-branch:
runs-on: ubuntu-latest
outputs:
release-branch-name: ${{ steps.parse-release-branch.outputs.release-branch-name }}
steps:
- id: parse-release-branch
name: Parse release branch name
run: |
# Sets the release-branch-name output to the version number with the last non-period element replaced with an 'x' and preprended with v.
echo "::set-output name=release-branch-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.x/')"
# Sets the release-tag-name output to the version number with the last non-period element replace with a '0' and prepended with v
echo "::set-output name=release-tag-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.0/')"
- id: checkout-release-branch
name: Check out release branch
continue-on-error: true
uses: actions/checkout@v2
with:
ref: ${{ steps.parse-release-branch.outputs.release-branch-name }}
- id: checkout-release-tag
name: Check out release tag
if: ${{ steps.checkout-release-branch.outcome == 'failure' }}
uses: actions/checkout@v2
with:
ref: ${{ steps.parse-release-branch.outputs.release-tag-name }}
- name: Create release branch
if: ${{ steps.checkout-release-tag.outcome == 'success' }}
run: |
git checkout -b ${{ steps.parse-release-branch.outputs.release-branch-name }}
git push --set-upstream origin ${{ steps.parse-release-branch.outputs.release-branch-name }}
build:
runs-on: ubuntu-latest
needs: prepare-release-branch
steps:
- name: Checkout release branch
uses: actions/checkout@v2
with:
ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
- uses: actions/setup-java@v1
with:
java-version: 11
- name: Setup git name
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Cherrypicks
if: ${{ github.event.inputs.commits != '' }}
run: |
git fetch origin master
echo ${{ github.event.inputs.commits }} | sed -n 1'p' | tr ',' '\n' | while read word; do
# Trim whitespaces and cherrypick
echo $word | sed 's/ *$//g' | sed 's/^ *//g' | git cherry-pick --stdin
done
- uses: burrunan/gradle-cache-action@v1.5
with:
job-id: jdk11
remote-build-cache-proxy-enabled: false
arguments: build --stacktrace -Prelease.version=${{ github.event.inputs.version }}
- name: Publish artifacts
uses: burrunan/gradle-cache-action@v1.5
with:
job-id: jdk11
remote-build-cache-proxy-enabled: false
arguments: final --stacktrace -Prelease.version=${{ github.event.inputs.version }}
env:
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
GRGIT_USER: ${{ github.actor }}
GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }}

30
.github/workflows/release-build.yml vendored Normal file
View File

@ -0,0 +1,30 @@
# Releases a new minor / major version from the HEAD of the main branch
name: Release Build
on:
workflow_dispatch:
inputs:
version:
description: The version to tag the release with, e.g., 1.2.0, 1.2.1-alpha.1
required: true
jobs:
build:
name: Build and release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 11
- uses: burrunan/gradle-cache-action@v1.5
with:
job-id: jdk11
remote-build-cache-proxy-enabled: false
arguments: build --stacktrace -Prelease.version=${{ github.event.inputs.version }}
- name: Publish artifacts
run: ./gradlew final --stacktrace -Prelease.version=${{ github.event.inputs.version }}
env:
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
GRGIT_USER: ${{ github.actor }}
GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }}

View File

@ -13,22 +13,68 @@ This signals Nebula plugin to build and publish to
[JFrog OSS repository](https://oss.jfrog.org/artifactory/oss-snapshot-local/io/opentelemetry/auto/)next _minor_ release version.
This means version `vX.(Y+1).0-SNAPSHOT`.
## Public releases
All major and minor public releases are initiated by creating a git tag with a version to be released.
Do the following:
- Checkout a branch that you want to release.
- Tag a commit on which you want to base the release by executing `git tag vX.Y.0` with the expected version string.
- Push new tag to upstream repo.
## Starting the Release
On new tag creation a CI will start a new release build.
It will do the following:
- Checkout requested tag.
- Run `./gradlew -Prelease.useLastTag=true final`.
This signals Nebula plugin to build `X.Y.0` version and to publish it to
[Bintray repository](https://bintray.com/open-telemetry/maven/opentelemetry-java-instrumentation).
Open the release build workflow in your browser [here](https://github.com/open-telemetry/opentelemetry-java-instrumentation/actions?query=workflow%3A%22Release+Build%22).
## Patch releases
Whenever a fix is needed to any older branch, a PR should be made into the corresponding maintenance branch.
When that PR is merge, CI will notice the new commit into maintenance branch and will initiate a new build for this.
That build, after usual building and checking, will run `./gradlew -Prelease.scope=patch final`.
This will signal Nebula plugin to build a new version `vX.Y.(Z+1)` and publish it to Bintray repo.
You will see a button that says "Run workflow". Press the button, enter the version number you want
to release in the input field that pops up, and then press "Run workflow".
This triggers the release process, which builds the artifacts, publishes the artifacts, and creates
and pushes a git tag with the version number.
## Announcement
Once the GitHub workflow completes, go to Github [release
page](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases), press
`Draft a new release` to write release notes about the new release. If there is already a draft
release notes, just point it at the created tag.
## Patch Release
All patch releases should include only bug-fixes, and must avoid
adding/modifying the public APIs.
Open the patch release build workflow in your browser [here](https://github.com/open-telemetry/opentelemetry-java-instrumentation/actions?query=workflow%3A%22Patch+Release+Build%22).
You will see a button that says "Run workflow". Press the button, enter the version number you want
to release in the input field for version that pops up and the commits you want to cherrypick for the
patch as a comma-separated list. Then, press "Run workflow".
If the commits cannot be cleanly applied to the release branch, for example because it has diverged
too much from main, then the workflow will fail before building. In this case, you will need to
prepare the release branch manually.
This example will assume patching into release branch `v1.2.x` from a git repository with remotes
named `origin` and `upstream`.
```
$ git remote -v
origin git@github.com:username/opentelemetry-java.git (fetch)
origin git@github.com:username/opentelemetry-java.git (push)
upstream git@github.com:open-telemetry/opentelemetry-java.git (fetch)
upstream git@github.com:open-telemetry/opentelemetry-java.git (push)
```
First, checkout the release branch
```
git fetch upstream v1.2.x
git checkout upstream/v1.2.x
```
Apply cherrypicks manually and commit. It is ok to apply multiple cherrypicks in a single commit.
Use a commit message such as "Manual cherrypick for commits commithash1, commithash2".
After commiting the change, push to your fork's branch.
```
git push origin v1.2.x
```
Create a PR to have code review and merge this into upstream's release branch. As this was not
applied automatically, we need to do code review to make sure the manual cherrypick is correct.
After it is merged, Run the patch release workflow again, but leave the commits input field blank.
The release will be made with the current state of the release branch, which is what you prepared
above.