Skip to content

Commit

Permalink
Workflow cleanup/sync (#5736)
Browse files Browse the repository at this point in the history
* Workflow cleanup/sync

* more

* more

* more

* fix

* consistency

* Use simpler sharing of env vars across steps

* Simplify, merge related jobs

* Simplify

* More improvements

* Use release/* release branch naming
  • Loading branch information
trask authored Apr 4, 2022
1 parent 79cd093 commit d908821
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 85 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/generate-release-contributors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ from=$(git log --reverse --pretty=format:"%cI" $from_version..HEAD | head -1)
# get the last commit on main that was in the to_version
to=$(git merge-base HEAD $to_version | xargs git log -1 --pretty=format:"%cI")

contributors1=$(gh api graphql --paginate -F q="repo:open-telemetry/opentelemetry-java-instrumentation is:pr base:main is:merged merged:$from..$to" -f query='
contributors1=$(gh api graphql --paginate -F q="repo:$GITHUB_REPOSITORY is:pr base:main is:merged merged:$from..$to" -f query='
query($q: String!, $endCursor: String) {
search(query: $q, type: ISSUE, first: 100, after: $endCursor) {
edges {
Expand Down Expand Up @@ -49,7 +49,7 @@ query($q: String!, $endCursor: String) {

# this query captures authors of issues which have had PRs in the current range reference the issue
# but not necessarily through closingIssuesReferences (e.g. addressing just a part of an issue)
contributors2=$(gh api graphql --paginate -F q="repo:open-telemetry/opentelemetry-java-instrumentation is:pr base:main is:merged merged:$from..$to" -f query='
contributors2=$(gh api graphql --paginate -F q="repo:$GITHUB_REPOSITORY is:pr base:main is:merged merged:$from..$to" -f query='
query($q: String!, $endCursor: String) {
search(query: $q, type: ISSUE, first: 100, after: $endCursor) {
edges {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Backport a pull request
name: Backport
on:
workflow_dispatch:
inputs:
Expand All @@ -15,7 +15,7 @@ jobs:
# history is needed in order to do cherry-pick
fetch-depth: 0

- name: Set up git name
- name: Set git user
run: |
git config user.name opentelemetry-java-bot
git config user.email [email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- main
- v[0-9]+.[0-9]+.x
- release/*
workflow_dispatch:

jobs:
Expand Down
24 changes: 8 additions & 16 deletions .github/workflows/prepare-patch-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set versions
id: set-versions
- name: Set environment variables
run: |
prior_version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1)
if [[ $prior_version =~ ([0-9]+.[0-9]+).([0-9]+) ]]; then
Expand All @@ -19,37 +18,30 @@ jobs:
echo "unexpected version: $prior_version"
exit 1
fi
echo "::set-output name=release-version::$major_minor.$((patch + 1))"
echo "::set-output name=prior-release-version::$prior_version"
echo "VERSION=$major_minor.$((patch + 1))" >> $GITHUB_ENV
echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV
- name: Bump version
env:
VERSION: ${{ steps.set-versions.outputs.release-version }}
PRIOR_VERSION: ${{ steps.set-versions.outputs.prior-release-version }}
run: |
.github/scripts/update-versions.sh "$PRIOR_VERSION" "$PRIOR_VERSION-alpha" "$VERSION" "$VERSION-alpha"
- name: Bump download link version
env:
VERSION: ${{ steps.set-versions.outputs.release-version }}
PRIOR_VERSION: ${{ steps.set-versions.outputs.prior-release-version }}
run: |
sed -Ei "s,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$PRIOR_VERSION/,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$VERSION/," README.md
- name: Set up git name
- name: Set git user
run: |
git config user.name opentelemetry-java-bot
git config user.email [email protected]
- name: Create pull request
env:
VERSION: ${{ steps.set-versions.outputs.release-version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
msg="Prepare patch release $VERSION"
msg="Prepare release $VERSION"
git commit -a -m "$msg"
git push origin HEAD:prepare-patch-release-$VERSION
gh pr create --title "$msg" \
git push origin HEAD:prepare-release-$VERSION
gh pr create --title "[$GITHUB_REF_NAME] $msg" \
--body "$msg" \
--head prepare-patch-release-$VERSION \
--head prepare-release-$VERSION \
--base $GITHUB_REF_NAME
53 changes: 17 additions & 36 deletions .github/workflows/prepare-release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,48 @@ on:
workflow_dispatch:

jobs:
prepare-release-branch:
create-pull-request-against-release-branch:
runs-on: ubuntu-latest
outputs:
release-branch-name: ${{ steps.set-release-branch-name.outputs.release-branch-name }}
steps:
- uses: actions/checkout@v3

- name: Set release branch name
id: set-release-branch-name
run: |
version=$(grep -Eo "[0-9.]+-SNAPSHOT" version.gradle.kts)
release_branch_name=$(echo $version | sed -E 's/([0-9]+)\.([0-9]+)\.0/v\1.\2.x/')
echo "::set-output name=release-branch-name::$release_branch_name"
- name: Create release branch
env:
RELEASE_BRANCH_NAME: ${{ steps.set-release-branch-name.outputs.release-branch-name }}
id: create-release-branch
run: |
git checkout -b $RELEASE_BRANCH_NAME
git push origin $RELEASE_BRANCH_NAME
version=$(grep -Eo "[0-9]+.[0-9]+.0-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//')
release_branch_name=$(echo $version | sed -E 's,([0-9]+)\.([0-9]+)\.0,release/v\1.\2.x,')
create-pull-request-against-release-branch:
needs: prepare-release-branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
git push origin HEAD:$release_branch_name
- name: Bump version on release branch
echo "VERSION=$version" >> $GITHUB_ENV
echo "RELEASE_BRANCH_NAME=$release_branch_name" >> $GITHUB_ENV
- name: Bump version
run: |
version=$(grep -Eo "[0-9]+.[0-9]+.0-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//')
.github/scripts/update-versions.sh "$version-SNAPSHOT" "$version-alpha-SNAPSHOT" "$version" "$version-alpha"
.github/scripts/update-versions.sh "$VERSION-SNAPSHOT" "$VERSION-alpha-SNAPSHOT" "$VERSION" "$VERSION-alpha"
- name: Bump download link version
run: |
new_version=$(grep -Eo "[0-9]+.[0-9]+.0" version.gradle.kts | head -1)
sed -Ei "s,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$new_version/," README.md
sed -Ei "s,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$VERSION/," README.md
- name: Set up git name
- name: Set git user
run: |
git config user.name opentelemetry-java-bot
git config user.email [email protected]
- name: Create pull request against release branch
env:
RELEASE_BRANCH_NAME: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
msg="Prepare release branch $RELEASE_BRANCH_NAME"
msg="Prepare release $VERSION"
git commit -a -m "$msg"
git push origin HEAD:prepare-release-branch-$RELEASE_BRANCH_NAME
gh pr create --title "$msg" \
git push origin HEAD:prepare-release-$VERSION
gh pr create --title "[$RELEASE_BRANCH_NAME] $msg" \
--body "$msg" \
--head prepare-release-branch-$RELEASE_BRANCH_NAME \
--head prepare-release-$VERSION \
--base $RELEASE_BRANCH_NAME
create-pull-request-against-main:
needs:
- prepare-release-branch
- create-pull-request-against-release-branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -81,7 +62,7 @@ jobs:
next_version="$major.$((minor + 1)).0"
.github/scripts/update-versions.sh "$version-SNAPSHOT" "$version-alpha-SNAPSHOT" "$next_version-SNAPSHOT" "$next_version-alpha-SNAPSHOT"
- name: Set up git name
- name: Set git user
run: |
git config user.name opentelemetry-java-bot
git config user.email [email protected]
Expand Down
41 changes: 17 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ jobs:
arguments: build publishPlugins publishPluginMavenPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository
build-root-directory: gradle-plugins

- name: Set versions
id: set-versions
- name: Set environment variables
run: |
version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1)
if [[ $version =~ ([0-9]+).([0-9]+).([0-9]+) ]]; then
Expand All @@ -94,52 +93,49 @@ jobs:
else
prior_version="$major.$minor.$((patch - 1))"
fi
echo "::set-output name=release-version::$version"
echo "::set-output name=prior-release-version::$prior_version"
echo "VERSION=$version" >> $GITHUB_ENV
echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV
- name: Generate release notes
env:
VERSION: ${{ steps.set-versions.outputs.release-version }}
PRIOR_VERSION: ${{ steps.set-versions.outputs.prior-release-version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ $version == *.0 ]]; then
cat > release-notes.txt << EOF
This release targets the OpenTelemetry SDK $VERSION.
Note that all artifacts other than \`io.opentelemetry.javaagent:opentelemetry-javaagent\` have the \`-alpha\` suffix attached to their version number, reflecting that they are still alpha quality and will continue to have breaking changes. Please see the [VERSIONING.md](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/VERSIONING.md#opentelemetry-java-instrumentation-versioning) for more details.
EOF
else
cat > release-notes.txt << EOF
This is a patch release on the previous $PRIOR_VERSION release, fixing the issue(s) below.
EOF
fi
sed -n '/^## Version $VERSION/,/^## Version /p' CHANGELOG.md \
sed -n "/^## Version $VERSION/,/^## Version /p" CHANGELOG.md \
| tail -n +2 \
| head -n -1 \
| perl -0pe 's/^\n+//g' \
| perl -0pe 's/\n+$/\n/g' \
| sed -r 's,\[#([0-9]+)]\(https://github.com/$GITHUB_REPOSITORY/(pull|issues)/[0-9]+\),#\1,' \
| sed -r "s,\[#([0-9]+)]\(https://github.com/$GITHUB_REPOSITORY/(pull|issues)/[0-9]+\),#\1," \
| perl -0pe 's/\n +/ /g' \
>> release-notes.txt
if [[ $version == *.0 ]]; then
cat >> release-notes.txt << EOF
### 🙇 Thank you
This release was possible thanks to the following contributors who shared their brilliant ideas and awesome pull requests:
EOF
.github/scripts/generate-release-contributors.sh v$PRIOR_VERSION v$VERSION >> release-notes.txt
fi
- name: Create GitHub release
env:
VERSION: ${{ steps.set-versions.outputs.release-version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cp javaagent/build/libs/opentelemetry-javaagent-$VERSION.jar opentelemetry-javaagent.jar
Expand All @@ -157,27 +153,22 @@ jobs:
token: ${{ secrets.OPENTELEMETRY_JAVA_BOT_TOKEN }}

- name: Initialize pull request branch
env:
VERSION: ${{ steps.set-versions.outputs.release-version }}
run: |
git remote add upstream https://github.com/open-telemetry/opentelemetry-operator.git
git fetch upstream
git checkout -b update-opentelemetry-javaagent-to-$VERSION upstream/main
- name: Bump version
env:
VERSION: ${{ steps.set-versions.outputs.release-version }}
run: |
echo $VERSION > autoinstrumentation/java/version.txt
- name: Set up git name
- name: Set git user
run: |
git config user.name opentelemetry-java-bot
git config user.email [email protected]
- name: Create pull request against opentelemetry-operator
env:
VERSION: ${{ steps.set-versions.outputs.release-version }}
# this is the PAT used for "gh pr create" below
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRY_JAVA_BOT_TOKEN }}
run: |
Expand All @@ -193,19 +184,21 @@ jobs:
gh pr create --title "$msg" \
--body "$msg" \
--repo open-telemetry/opentelemetry-operator
--base main
- uses: actions/checkout@v3
with:
ref: main
# history is needed in order to run git format-patch below
fetch-depth: 0

- name: Set up git name
- name: Set git user
run: |
git config user.name opentelemetry-java-bot
git config user.email [email protected]
# this step should be last since it will fail if conflicting change log updates on main
# this step should be last since it will fail if there have been conflicting
# change log updates introduced on the main branch
- name: Create pull request to merge any change log updates to main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -215,9 +208,9 @@ jobs:
git apply patch
msg="Merge change log updates from $GITHUB_REF_NAME to main"
git commit -a -m "$msg"
git push origin HEAD:opentelemetry-java-bot/merge-change-log-updates
git push origin HEAD:merge-change-log-updates-to-main
gh pr create --title "$msg" \
--body "$msg" \
--head opentelemetry-java-bot/merge-change-log-updates \
--head merge-change-log-updates-to-main \
--base main
fi
8 changes: 4 additions & 4 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ All patch releases should include only bug-fixes, and must avoid adding/modifyin
In general, patch releases are only made for regressions, memory leaks and deadlocks.

* Backport pull request(s) to the release branch
* Run the [Backport pull request workflow](.github/workflows/backport-pull-request.yml).
* Run the [Backport workflow](.github/workflows/backport.yml).
* Press the "Run workflow" button, then select the release branch from the dropdown list,
e.g. `v1.9.x`, then enter the pull request number that you want to backport,
e.g. `release/v1.9.x`, then enter the pull request number that you want to backport,
then click the "Run workflow" button below that.
* Review and merge the backport pull request that it generates
* Merge a pull request to the release branch updating the `CHANGELOG.md`
* Run the [Prepare patch release workflow](.github/workflows/prepare-patch-release.yml).
* Press the "Run workflow" button, then select the release branch from the dropdown list,
e.g. `v1.9.x`, and click the "Run workflow" button below that.
e.g. `release/v1.9.x`, and click the "Run workflow" button below that.
* Review and merge the pull request that it creates

## Making the release

Run the [Release workflow](.github/workflows/release.yml).

* Press the "Run workflow" button, then select the release branch from the dropdown list,
e.g. `v1.9.x`, and click the "Run workflow" button below that.
e.g. `release/v1.9.x`, and click the "Run workflow" button below that.
* This workflow will publish the artifacts to maven central and will publish a GitHub release with
release notes based on the change log and with the javaagent jar attached.
* Lastly, if there were any change log updates in the release branch that need to be merged back to
Expand Down

0 comments on commit d908821

Please sign in to comment.