Skip to content

Commit d565093

Browse files
authored
Release workflow simplifications (#356)
* Release workflow simplifications * doc * Sync * Remove prerelease support * More * Sync * Fix
1 parent e999efd commit d565093

File tree

8 files changed

+266
-169
lines changed

8 files changed

+266
-169
lines changed

.github/scripts/draft-change-log-entries.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ else
2323
range="v$major.$((minor - 1)).0..HEAD"
2424
fi
2525

26+
echo "## Unreleased"
27+
echo
28+
2629
declare -A component_names=()
2730
component_names["aws-xray/"]="AWS X-Ray"
2831
component_names["consistent-sampling/"]="Consistent sampling"

.github/scripts/generate-release-contributors.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
# this should be run on the release branch
77

8+
# NOTE if you need to run this script locally, you will need to first:
9+
# git fetch upstream main
10+
# git push origin upstream/main:main
11+
# export GITHUB_REPOSITORY=open-telemetry/opentelemetry-java-contrib
12+
813
from_version=$1
914

1015
# get the date of the first commit that was not in the from_version
@@ -80,4 +85,5 @@ echo $contributors1 $contributors2 \
8085
| grep -v linux-foundation-easycla \
8186
| grep -v github-actions \
8287
| grep -v dependabot \
88+
| grep -v opentelemetry-java-bot \
8389
| sed 's/^/@/'

.github/workflows/backport.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ jobs:
1010
backport:
1111
runs-on: ubuntu-latest
1212
steps:
13+
- run: |
14+
if [[ ! $GITHUB_REF_NAME =~ ^release/v[0-9]+\.[0-9]+\.x$ ]]; then
15+
echo this workflow should only be run against release branches
16+
exit 1
17+
fi
18+
1319
- uses: actions/checkout@v3
1420
with:
1521
# history is needed to run git cherry-pick below
@@ -21,12 +27,11 @@ jobs:
2127
- name: Create pull request
2228
env:
2329
NUMBER: ${{ github.event.inputs.number }}
24-
# not using the default GITHUB_TOKEN because pull requests generated by it do not run any workflows
30+
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
2531
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
2632
run: |
2733
commit=$(gh pr view $NUMBER --json mergeCommit --jq .mergeCommit.oid)
2834
title=$(gh pr view $NUMBER --json title --jq .title)
29-
url=$(gh pr view $NUMBER --json url --jq .url)
3035
3136
branch="backport-${NUMBER}-to-${GITHUB_REF_NAME//\//-}"
3237

.github/workflows/merge-change-log-to-main.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

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

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

11+
- run: |
12+
if [[ ! $GITHUB_REF_NAME =~ ^release/v[0-9]+\.[0-9]+\.x$ ]]; then
13+
echo this workflow should only be run against release branches
14+
exit 1
15+
fi
16+
17+
if ! grep --quiet "^## Unreleased$" CHANGELOG.md; then
18+
echo the change log is missing an \"Unreleased\" section
19+
exit 1
20+
fi
21+
1122
- name: Set environment variables
1223
run: |
1324
version=$(.github/scripts/get-version.sh)
14-
if [[ $version =~ ([0-9]+\.[0-9]+)\.([0-9]+) ]]; then
25+
if [[ $version =~ ^([0-9]+\.[0-9]+)\.([0-9]+)$ ]]; then
1526
major_minor="${BASH_REMATCH[1]}"
1627
patch="${BASH_REMATCH[2]}"
1728
else
@@ -20,22 +31,20 @@ jobs:
2031
fi
2132
echo "VERSION=$major_minor.$((patch + 1))" >> $GITHUB_ENV
2233
23-
- name: Check change log has been updated
24-
run: |
25-
if ! grep --quiet "^## Version $VERSION" CHANGELOG.md; then
26-
echo the change log needs to be updated
27-
exit 1
28-
fi
29-
3034
- name: Update version
3135
run: .github/scripts/update-version.sh $VERSION
3236

37+
- name: Update the change log with the approximate release date
38+
run: |
39+
date=$(date "+%Y-%m-%d")
40+
sed -Ei "s/^## Unreleased$/## Version $VERSION ($date)/" CHANGELOG.md
41+
3342
- name: Set git user
3443
run: .github/scripts/set-git-user.sh
3544

3645
- name: Create pull request
3746
env:
38-
# not using the default GITHUB_TOKEN because pull requests generated by it do not run any workflows
47+
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
3948
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
4049
run: |
4150
message="Prepare release $VERSION"

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

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ jobs:
99
- uses: actions/checkout@v3
1010

1111
- run: |
12-
version=$(.github/scripts/get-version.sh)
13-
version=${version//-SNAPSHOT/}
14-
if ! grep --quiet "^## Version $version" CHANGELOG.md; then
15-
echo the change log needs to be updated
12+
if [[ $GITHUB_REF_NAME != main ]]; then
13+
echo this workflow should only be run against main
14+
exit 1
15+
fi
16+
17+
if ! grep --quiet "^## Unreleased$" CHANGELOG.md; then
18+
echo the change log is missing an \"Unreleased\" section
1619
exit 1
1720
fi
1821
@@ -23,11 +26,15 @@ jobs:
2326
- uses: actions/checkout@v3
2427

2528
- name: Create release branch
26-
id: create-release-branch
2729
run: |
2830
version=$(.github/scripts/get-version.sh)
2931
version=${version//-SNAPSHOT/}
30-
release_branch_name=$(echo $version | sed -E 's/([0-9]+)\.([0-9]+)\.0/release\/v\1.\2.x/')
32+
if [[ $version =~ ^([0-9]+)\.([0-9]+)\.0$ ]]; then
33+
release_branch_name=$(echo $version | sed -E 's/([0-9]+)\.([0-9]+)\.0/release\/v\1.\2.x/')
34+
else
35+
echo "unexpected version: $version"
36+
exit 1
37+
fi
3138
3239
git push origin HEAD:$release_branch_name
3340
@@ -37,12 +44,17 @@ jobs:
3744
- name: Update version
3845
run: .github/scripts/update-version.sh $VERSION
3946

47+
- name: Update the change log with the approximate release date
48+
run: |
49+
date=$(date "+%Y-%m-%d")
50+
sed -Ei "s/^## Unreleased$/## Version $VERSION ($date)/" CHANGELOG.md
51+
4052
- name: Set git user
4153
run: .github/scripts/set-git-user.sh
4254

4355
- name: Create pull request against the release branch
4456
env:
45-
# not using the default GITHUB_TOKEN because pull requests generated by it do not run any workflows
57+
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
4658
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
4759
run: |
4860
message="Prepare release $VERSION"
@@ -64,26 +76,33 @@ jobs:
6476
- name: Set environment variables
6577
run: |
6678
version=$(.github/scripts/get-version.sh)
67-
if [[ $version =~ ([0-9]+)\.([0-9]+)\.0 ]]; then
79+
version=${version//-SNAPSHOT/}
80+
if [[ $version =~ ^([0-9]+)\.([0-9]+)\.0$ ]]; then
6881
major="${BASH_REMATCH[1]}"
6982
minor="${BASH_REMATCH[2]}"
83+
next_version="$major.$((minor + 1)).0"
7084
else
7185
echo "unexpected version: $version"
7286
exit 1
7387
fi
74-
next_version="$major.$((minor + 1)).0"
75-
next_version="${next_version}-SNAPSHOT"
76-
echo "NEXT_VERSION=$next_version" >> $GITHUB_ENV
88+
echo "NEXT_VERSION=${next_version}-SNAPSHOT" >> $GITHUB_ENV
89+
echo "VERSION=$version" >> $GITHUB_ENV
7790
7891
- name: Update version
7992
run: .github/scripts/update-version.sh $NEXT_VERSION
8093

94+
- name: Update the change log on main
95+
run: |
96+
# the actual release date on main will be updated at the end of the release workflow
97+
date=$(date "+%Y-%m-%d")
98+
sed -Ei "s/^## Unreleased$/## Unreleased\n\n## Version $VERSION ($date)/" CHANGELOG.md
99+
81100
- name: Set git user
82101
run: .github/scripts/set-git-user.sh
83102

84103
- name: Create pull request against main
85104
env:
86-
# not using the default GITHUB_TOKEN because pull requests generated by it do not run any workflows
105+
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
87106
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
88107
run: |
89108
message="Update version to $NEXT_VERSION"

0 commit comments

Comments
 (0)