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 all commits
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
92 changes: 92 additions & 0 deletions .github/workflows/prepare-release-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
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: Setup git name
run: |
git config user.name github-actions
git config user.email github-actions@github.com

- name: Create pull request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
msg="Prepare release branch ${{ needs.prepare-release-branch.outputs.release-branch-name }}"
git add -u
git commit -m "$msg"
git push origin HEAD:prepare-release-branch-${{ needs.prepare-release-branch.outputs.release-branch-name }}
gh pr create --title "$msg" \
--body "$msg" \
--head prepare-release-branch-${{ needs.prepare-release-branch.outputs.release-branch-name }} \
--base ${{ 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: Setup git name
run: |
git config user.name github-actions
git config user.email github-actions@github.com

- name: Create pull request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
msg="Bump snapshot version"
git add -u
git commit -m "$msg"
git push origin HEAD:bump-snapshot-version
gh pr create --title "$msg" --body "$msg" --head bump-snapshot-version --base main
Copy link
Contributor

Choose a reason for hiding this comment

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

I just noticed the **/** CNCF branch protection rule seems to be gone, did we accidentally delete it?

Though either way, even if we can make it work for release branch, this PR creation to main looks like it'll be problematic due to CLA check :(

Copy link
Contributor

Choose a reason for hiding this comment

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

Though we do explicitly have the checkbox to let us merge even if status checks aren't all passing. So that could be our workaround

Copy link
Member Author

Choose a reason for hiding this comment

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

we have branch protection on both main and v**, so CLA check will be a problem for both PRs 😞

Copy link
Member Author

Choose a reason for hiding this comment

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

it looks there are complexities to approving github-actions bot account for EasyCLA and so that path could take some time

it seems that the current recommendation is to use a Personal Access Token generated by one of the maintainers: https://github.com/open-telemetry/community/blob/main/docs/using-github-extensions.md#writing-your-github-actions-pipelines

Copy link
Member Author

Choose a reason for hiding this comment

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

reverted back to using github-actions bot for now at least

20 changes: 4 additions & 16 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,9 @@ 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

* Delete the branches from these two PRs since they are created in the main repo

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 +32,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