Skip to content

Commit 0c954a9

Browse files
authored
Workflow cleanup/sync (#280)
* Workflow cleanup/sync * more * Add missing script * fix * Use simpler sharing of env vars across steps * Simplify, merge related jobs * Simplify * More improvements * Use release/* release branch naming
1 parent 6b3a3ce commit 0c954a9

File tree

7 files changed

+129
-73
lines changed

7 files changed

+129
-73
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash -e
2+
3+
# shellcheck disable=SC2016
4+
# shellcheck disable=SC2086
5+
6+
from_version=$1
7+
to_version=$2
8+
9+
# get the date of the first commit on main that wasn't in the from_version
10+
from=$(git log --reverse --pretty=format:"%cI" $from_version..HEAD | head -1)
11+
12+
# get the last commit on main that was in the to_version
13+
to=$(git merge-base HEAD $to_version | xargs git log -1 --pretty=format:"%cI")
14+
15+
contributors1=$(gh api graphql --paginate -F q="repo:$GITHUB_REPOSITORY is:pr base:main is:merged merged:$from..$to" -f query='
16+
query($q: String!, $endCursor: String) {
17+
search(query: $q, type: ISSUE, first: 100, after: $endCursor) {
18+
edges {
19+
node {
20+
... on PullRequest {
21+
author { login }
22+
reviews(first: 100) {
23+
nodes {
24+
author { login }
25+
}
26+
}
27+
comments(first: 100) {
28+
nodes {
29+
author { login }
30+
}
31+
}
32+
closingIssuesReferences(first: 100) {
33+
nodes {
34+
author { login }
35+
}
36+
}
37+
}
38+
}
39+
}
40+
pageInfo {
41+
hasNextPage
42+
endCursor
43+
}
44+
}
45+
}' --jq '.data.search.edges.[].node.author.login,
46+
.data.search.edges.[].node.reviews.nodes.[].author.login,
47+
.data.search.edges.[].node.comments.nodes.[].author.login,
48+
.data.search.edges.[].node.closingIssuesReferences.nodes.[].author.login')
49+
50+
# this query captures authors of issues which have had PRs in the current range reference the issue
51+
# but not necessarily through closingIssuesReferences (e.g. addressing just a part of an issue)
52+
contributors2=$(gh api graphql --paginate -F q="repo:$GITHUB_REPOSITORY is:pr base:main is:merged merged:$from..$to" -f query='
53+
query($q: String!, $endCursor: String) {
54+
search(query: $q, type: ISSUE, first: 100, after: $endCursor) {
55+
edges {
56+
node {
57+
... on PullRequest {
58+
body
59+
}
60+
}
61+
}
62+
pageInfo {
63+
hasNextPage
64+
endCursor
65+
}
66+
}
67+
}
68+
' --jq '.data.search.edges.[].node.body' \
69+
| grep -oE "#[0-9]{4,}|issues/[0-9]{4,}" \
70+
| grep -oE "[0-9]{4,}" \
71+
| xargs -I{} gh issue view {} --json 'author,url' --jq '[.author.login,.url]' \
72+
| grep -v '/pull/' \
73+
| sed 's/^\["//' \
74+
| sed 's/".*//')
75+
76+
echo $contributors1 $contributors2 \
77+
| sed 's/ /\n/g' \
78+
| sort -uf \
79+
| grep -v linux-foundation-easycla \
80+
| grep -v github-actions \
81+
| grep -v dependabot \
82+
| sed 's/^/@/'

.github/workflows/backport-pull-request.yml renamed to .github/workflows/backport.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Backport a pull request
1+
name: Backport
22
on:
33
workflow_dispatch:
44
inputs:
@@ -15,7 +15,7 @@ jobs:
1515
# history is needed in order to do cherry-pick
1616
fetch-depth: 0
1717

18-
- name: Set up git name
18+
- name: Set git user
1919
run: |
2020
git config user.name opentelemetry-java-bot
2121
git config user.email [email protected]

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- main
7-
- v[0-9]+.[0-9]+.x
7+
- release/*
88
workflow_dispatch:
99

1010
jobs:

.github/workflows/prepare-patch-release.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ jobs:
88
steps:
99
- uses: actions/checkout@v3
1010

11-
- name: Set versions
12-
id: set-versions
11+
- name: Set environment variables
1312
run: |
1413
prior_version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1)
1514
if [[ $prior_version =~ ([0-9]+.[0-9]+).([0-9]+) ]]; then
@@ -19,30 +18,26 @@ jobs:
1918
echo "unexpected version: $prior_version"
2019
exit 1
2120
fi
22-
echo "::set-output name=release-version::$major_minor.$((patch + 1))"
23-
echo "::set-output name=prior-release-version::$prior_version"
21+
echo "VERSION=$major_minor.$((patch + 1))" >> $GITHUB_ENV
22+
echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV
2423
2524
- name: Bump version
26-
env:
27-
VERSION: ${{ steps.set-versions.outputs.release-version }}
28-
PRIOR_VERSION: ${{ steps.set-versions.outputs.prior-release-version }}
2925
run: |
3026
sed -ri "s/$PRIOR_VERSION/$VERSION/" version.gradle.kts
3127
32-
- name: Set up git name
28+
- name: Set git user
3329
run: |
3430
git config user.name opentelemetry-java-bot
3531
git config user.email [email protected]
3632
3733
- name: Create pull request
3834
env:
39-
VERSION: ${{ steps.set-versions.outputs.release-version }}
4035
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4136
run: |
42-
msg="Prepare patch release $VERSION"
37+
msg="Prepare release $VERSION"
4338
git commit -a -m "$msg"
44-
git push origin HEAD:prepare-patch-release-$VERSION
45-
gh pr create --title "$msg" \
39+
git push origin HEAD:prepare-release-$VERSION
40+
gh pr create --title "[$GITHUB_REF_NAME] $msg" \
4641
--body "$msg" \
47-
--head prepare-patch-release-$VERSION \
42+
--head prepare-release-$VERSION \
4843
--base $GITHUB_REF_NAME

.github/workflows/prepare-release-branch.yml

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,45 @@ on:
33
workflow_dispatch:
44

55
jobs:
6-
prepare-release-branch:
6+
create-pull-request-against-release-branch:
77
runs-on: ubuntu-latest
8-
outputs:
9-
release-branch-name: ${{ steps.set-release-branch-name.outputs.release-branch-name }}
108
steps:
119
- uses: actions/checkout@v3
1210

13-
- name: Set release branch name
14-
id: set-release-branch-name
15-
run: |
16-
version=$(grep -Eo "[0-9.]+-SNAPSHOT" version.gradle.kts)
17-
release_branch_name=$(echo $version | sed -E 's/([0-9]+)\.([0-9]+)\.0/v\1.\2.x/')
18-
echo "::set-output name=release-branch-name::$release_branch_name"
19-
2011
- name: Create release branch
21-
env:
22-
RELEASE_BRANCH_NAME: ${{ steps.set-release-branch-name.outputs.release-branch-name }}
12+
id: create-release-branch
2313
run: |
24-
git checkout -b $RELEASE_BRANCH_NAME
25-
git push origin $RELEASE_BRANCH_NAME
14+
version=$(grep -Eo "[0-9]+.[0-9]+.0-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//')
15+
release_branch_name=$(echo $version | sed -E 's,([0-9]+)\.([0-9]+)\.0,release/v\1.\2.x,')
2616
27-
create-pull-request-against-release-branch:
28-
needs: prepare-release-branch
29-
runs-on: ubuntu-latest
30-
steps:
31-
- uses: actions/checkout@v3
32-
with:
33-
ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
17+
git push origin HEAD:$release_branch_name
3418
35-
- name: Bump version on release branch
19+
echo "VERSION=$version" >> $GITHUB_ENV
20+
echo "RELEASE_BRANCH_NAME=$release_branch_name" >> $GITHUB_ENV
21+
22+
- name: Bump version
3623
run: |
37-
version=$(grep -Eo "[0-9]+.[0-9]+.0-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//')
38-
sed -ri "s/$version-SNAPSHOT/$version/" version.gradle.kts
39-
sed -ri "s/$version-alpha-SNAPSHOT/$version-alpha/" version.gradle.kts
24+
sed -ri "s/$VERSION-SNAPSHOT/$VERSION/" version.gradle.kts
25+
sed -ri "s/$VERSION-alpha-SNAPSHOT/$VERSION-alpha/" version.gradle.kts
4026
41-
- name: Set up git name
27+
- name: Set git user
4228
run: |
4329
git config user.name opentelemetry-java-bot
4430
git config user.email [email protected]
4531
4632
- name: Create pull request against release branch
4733
env:
48-
RELEASE_BRANCH_NAME: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
4934
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5035
run: |
51-
msg="Prepare release branch $RELEASE_BRANCH_NAME"
36+
msg="Prepare release $VERSION"
5237
git commit -a -m "$msg"
53-
git push origin HEAD:prepare-release-branch-$RELEASE_BRANCH_NAME
54-
gh pr create --title "$msg" \
38+
git push origin HEAD:prepare-release-$VERSION
39+
gh pr create --title "[$RELEASE_BRANCH_NAME] $msg" \
5540
--body "$msg" \
56-
--head prepare-release-branch-$RELEASE_BRANCH_NAME \
41+
--head prepare-release-$VERSION \
5742
--base $RELEASE_BRANCH_NAME
5843
5944
create-pull-request-against-main:
60-
needs:
61-
- prepare-release-branch
62-
- create-pull-request-against-release-branch
6345
runs-on: ubuntu-latest
6446
steps:
6547
- uses: actions/checkout@v3
@@ -78,7 +60,7 @@ jobs:
7860
sed -ri "s/$version-SNAPSHOT/$next_version-SNAPSHOT/" version.gradle.kts
7961
sed -ri "s/$version-apha-SNAPSHOT/$next_version-apha-SNAPSHOT/" version.gradle.kts
8062
81-
- name: Set up git name
63+
- name: Set git user
8264
run: |
8365
git config user.name opentelemetry-java-bot
8466
git config user.email [email protected]

.github/workflows/release.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ jobs:
7676
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
7777
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
7878

79-
- name: Set versions
80-
id: set-versions
79+
- name: Set environment variables
8180
run: |
8281
version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1)
8382
if [[ $version =~ ([0-9]+).([0-9]+).([0-9]+) ]]; then
@@ -99,50 +98,47 @@ jobs:
9998
else
10099
prior_version="$major.$minor.$((patch - 1))"
101100
fi
102-
echo "::set-output name=release-version::$version"
103-
echo "::set-output name=prior-release-version::$prior_version"
101+
echo "VERSION=$version" >> $GITHUB_ENV
102+
echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV
104103
105104
- name: Generate release notes
106105
env:
107-
VERSION: ${{ steps.set-versions.outputs.release-version }}
108-
PRIOR_VERSION: ${{ steps.set-versions.outputs.prior-release-version }}
109106
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110107
run: |
111108
if [[ $version == *.0 ]]; then
112109
cat > release-notes.txt << EOF
113110
This release targets the OpenTelemetry SDK $VERSION.
114-
111+
115112
EOF
116113
else
117114
cat > release-notes.txt << EOF
118115
This is a patch release on the previous $PRIOR_VERSION release, fixing the issue(s) below.
119-
116+
120117
EOF
121118
fi
122119
123-
sed -n '/^## Version $VERSION/,/^## Version /p' CHANGELOG.md \
120+
sed -n "/^## Version $VERSION/,/^## Version /p" CHANGELOG.md \
124121
| tail -n +2 \
125122
| head -n -1 \
126123
| perl -0pe 's/^\n+//g' \
127124
| perl -0pe 's/\n+$/\n/g' \
128-
| sed -r 's,\[#([0-9]+)]\(https://github.com/$GITHUB_REPOSITORY/(pull|issues)/[0-9]+\),#\1,' \
125+
| sed -r "s,\[#([0-9]+)]\(https://github.com/$GITHUB_REPOSITORY/(pull|issues)/[0-9]+\),#\1," \
129126
| perl -0pe 's/\n +/ /g' \
130127
>> release-notes.txt
131128
132129
if [[ $version == *.0 ]]; then
133130
cat >> release-notes.txt << EOF
134-
131+
135132
### 🙇 Thank you
136133
This release was possible thanks to the following contributors who shared their brilliant ideas and awesome pull requests:
137-
134+
138135
EOF
139-
136+
140137
.github/scripts/generate-release-contributors.sh v$PRIOR_VERSION v$VERSION >> release-notes.txt
141138
fi
142139
143140
- name: Create GitHub release
144141
env:
145-
VERSION: ${{ steps.set-versions.outputs.release-version }}
146142
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147143
run: |
148144
cp jmx-metrics/build/libs/opentelemetry-jmx-metrics-$VERSION.jar opentelemetry-jmx-metrics.jar
@@ -159,12 +155,13 @@ jobs:
159155
# history is needed in order to generate the patch
160156
fetch-depth: 0
161157

162-
- name: Set up git name
158+
- name: Set git user
163159
run: |
164160
git config user.name opentelemetry-java-bot
165161
git config user.email [email protected]
166162
167-
# this step should be last since it will fail if conflicting change log updates on main
163+
# this step should be last since it will fail if there have been conflicting
164+
# change log updates introduced on the main branch
168165
- name: Create pull request to merge any change log updates to main
169166
env:
170167
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -174,9 +171,9 @@ jobs:
174171
git apply patch
175172
msg="Merge change log updates from $GITHUB_REF_NAME to main"
176173
git commit -a -m "$msg"
177-
git push origin HEAD:opentelemetry-java-bot/merge-change-log-updates
174+
git push origin HEAD:merge-change-log-updates-to-main
178175
gh pr create --title "$msg" \
179176
--body "$msg" \
180-
--head opentelemetry-java-bot/merge-change-log-updates \
177+
--head merge-change-log-updates-to-main \
181178
--base main
182179
fi

RELEASING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ All patch releases should include only bug-fixes, and must avoid adding/modifyin
2525
In general, patch releases are only made for regressions, memory leaks and deadlocks.
2626

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

3939
## Making the release
4040

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

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

0 commit comments

Comments
 (0)