Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow to prepare release branch #5143

Merged
merged 6 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/scripts/update-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Bumps versions in these files
# - version.gradle.kts
# - examples/distro/build.gradle
# - examples/extension/build.gradle

current_version=$1
current_alpha_version=$2
new_version=$3
new_alpha_version=$4

echo "updating from $current_version to $new_version and from $current_alpha_version to $new_alpha_version"

sed -ri "s/$current_version/$new_version/" version.gradle.kts
sed -ri "s/$current_alpha_version/$new_alpha_version/" version.gradle.kts

sed -ri "s/(opentelemetryJavaagent *: \")$current_version/\1$new_version/" examples/distro/build.gradle
sed -ri "s/(opentelemetryJavaagentAlpha *: \")$current_alpha_version/\1$new_alpha_version/" examples/distro/build.gradle

sed -ri "s/(opentelemetryJavaagent *: \")$current_version/\1$new_version/" examples/extension/build.gradle
sed -ri "s/(opentelemetryJavaagentAlpha *: \")$current_alpha_version/\1$new_alpha_version/" examples/extension/build.gradle

sed -ri "s/(io.opentelemetry.instrumentation.muzzle-generation\" version \")$current_alpha_version/\1$new_alpha_version/" examples/extension/build.gradle
sed -ri "s/(io.opentelemetry.instrumentation.muzzle-check\" version \")$current_alpha_version/\1$new_alpha_version/" examples/extension/build.gradle
77 changes: 77 additions & 0 deletions .github/workflows/prepare-release-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Prepare Release Branch
on:
workflow_dispatch:

jobs:
prepare-release-branch:
runs-on: ubuntu-latest
outputs:
release-branch-name: ${{ steps.set-release-branch-name.outputs.release-branch-name }}
steps:
- uses: actions/checkout@v2.3.4

- name: Set release branch name
id: set-release-branch-name
run: |
release_branch_name=$(grep -Eo "[0-9.]+-SNAPSHOT" version.gradle.kts | sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+)-SNAPSHOT/v\1.\2.x/')
echo "::set-output name=release-branch-name::$release_branch_name"

- name: Create release branch
run: |
git checkout -b ${{ steps.set-release-branch-name.outputs.release-branch-name }}
git push origin ${{ steps.set-release-branch-name.outputs.release-branch-name }}

create-pull-request-against-release-branch:
needs: prepare-release-branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
with:
ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }}

- name: Remove SNAPSHOT from version
run: |
v=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//')
.github/scripts/update-versions.sh "$v-SNAPSHOT" "$v-alpha-SNAPSHOT" "$v" "$v-alpha"

- name: Bump download link version
run: |
new_version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1)
sed -Ei "s,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v[0-9]+.[0-9]+.[0-9]+/,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$new_version/," README.md

- name: Create pull request
uses: peter-evans/create-pull-request@v3
with:
commit-message: Prepare release branch ${{ needs.prepare-release-branch.outputs.release-branch-name }}
branch: prepare-release-branch-${{ needs.prepare-release-branch.outputs.release-branch-name }}
delete-branch: true
title: Prepare release branch ${{ needs.prepare-release-branch.outputs.release-branch-name }}
body: Prepare release branch ${{ needs.prepare-release-branch.outputs.release-branch-name }}

create-pull-request-against-main:
needs: prepare-release-branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4

- name: Bump SNAPSHOT version
run: |
v=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//')
if [[ $v =~ ([0-9]+).([0-9]+).0 ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
else
echo "unexpected version: $v"
exit 1
fi
bump="$major.$((minor + 1)).0"
.github/scripts/update-versions.sh "$v-SNAPSHOT" "$v-alpha-SNAPSHOT" "$bump-SNAPSHOT" "$bump-alpha-SNAPSHOT"

- name: Create pull request
uses: peter-evans/create-pull-request@v3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If wanting to avoid a third party action, might be easy enough to use gh CLI

https://cli.github.com/manual/gh_pr_create

with:
commit-message: Bump snapshot version
branch: bump-snapshot-version
delete-branch: true
Copy link
Contributor

@anuraaga anuraaga Jan 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I was trying to see how delete-branch could possibly work when creating a pull request, and indeed it doesn't

https://github.com/peter-evans/create-pull-request#action-behaviour

It would delete the PR if it had already been merged when running this step, which would never be the case for us. So to prevent confusion, we should delete this field if sticking with the action. But I'd say the CLI command is simple and all we need, this action seems to support some intense workflows :O

https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#how-the-action-works

title: Bump snapshot version
body: Bump snapshot version
19 changes: 3 additions & 16 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,8 @@ as the last step, which publishes a snapshot build to
Before making the release:

* Merge a PR to `main` updating the `CHANGELOG.md`
* Create a release branch, e.g. `v1.9.x`
```
git checkout -b v1.9.x upstream/main
git push upstream v1.9.x
```
* Merge a PR to the release branch with the following changes
* Remove `-SNAPSHOT` from the version in these files:
* version.gradle.kts
* examples/distro/build.gradle
* examples/extension/build.gradle
* Bump the version in the download link in the root `README.md` file
* Run the [Prepare Release Branch workflow](https://github.com/open-telemetry/opentelemetry-java-instrumentation/actions/workflows/prepare-release-branch.yml).
* Review and merge the two PRs that it creates (one is targeted to the release branch and one is targeted to the `main` branch)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to delete the branch after merging


Open the release build workflow in your browser [here](https://github.com/open-telemetry/opentelemetry-java-instrumentation/actions/workflows/release-build.yml).

Expand All @@ -40,11 +31,7 @@ and pushes a git tag with the version number.

After making the release:

* Merge a PR to `main` with the following changes
* Bump version in these files to the next `-SNAPSHOT` version (e.g. from `1.9.0-SNAPSHOT` to `1.10.0-SNAPSHOT`)
* version.gradle.kts
* examples/distro/build.gradle
* examples/extension/build.gradle
* Merge a PR to `main` with the following change
* Bump the version in the download link in the root `README.md` file

## Announcement
Expand Down