forked from open-telemetry/opentelemetry-python
-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (155 loc) · 7.03 KB
/
prepare-release-branch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Prepare release branch
on:
workflow_dispatch:
inputs:
prerelease_version:
description: "Pre-release version number? (e.g. 1.9.0rc2)"
required: false
jobs:
prereqs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install toml
run: pip install toml
- name: Verify prerequisites
env:
PRERELEASE_VERSION: ${{ github.event.inputs.prerelease_version }}
run: |
if [[ $GITHUB_REF_NAME != main ]]; then
echo this workflow should only be run against main
exit 1
fi
if ! grep --quiet "^## Unreleased$" CHANGELOG.md; then
echo the change log is missing an \"Unreleased\" section
exit 1
fi
if [[ ! -z $PRERELEASE_VERSION ]]; then
stable_version=$(./scripts/eachdist.py version --mode stable)
stable_version=${stable_version//.dev/}
if [[ $PRERELEASE_VERSION != ${stable_version}* ]]; then
echo "$PRERELEASE_VERSION is not a prerelease for the version on main ($stable_version)"
exit 1
fi
fi
create-pull-request-against-release-branch:
runs-on: ubuntu-latest
needs: prereqs
steps:
- uses: actions/checkout@v4
- name: Install toml
run: pip install toml
- name: Create release branch
env:
PRERELEASE_VERSION: ${{ github.event.inputs.prerelease_version }}
run: |
if [[ -z $PRERELEASE_VERSION ]]; then
stable_version=$(./scripts/eachdist.py version --mode stable)
stable_version=${stable_version//.dev/}
else
stable_version=$PRERELEASE_VERSION
fi
unstable_version=$(./scripts/eachdist.py version --mode prerelease)
unstable_version=${unstable_version//.dev/}
if [[ $stable_version =~ ^([0-9]+)\.([0-9]+)\.0$ ]]; then
stable_version_branch_part=$(echo $stable_version | sed -E 's/([0-9]+)\.([0-9]+)\.0/\1.\2.x/')
unstable_version_branch_part=$(echo $unstable_version | sed -E 's/0\.([0-9]+)b0/0.\1bx/')
release_branch_name="release/v${stable_version_branch_part}-${unstable_version_branch_part}"
elif [[ $stable_version =~ ^([0-9]+)\.([0-9]+)\.0 ]]; then
# pre-release version, e.g. 1.9.0rc2
release_branch_name="release/v$stable_version-$unstable_version"
else
echo "unexpected version: $stable_version"
exit 1
fi
git push origin HEAD:$release_branch_name
echo "STABLE_VERSION=$stable_version" >> $GITHUB_ENV
echo "UNSTABLE_VERSION=$unstable_version" >> $GITHUB_ENV
echo "RELEASE_BRANCH_NAME=$release_branch_name" >> $GITHUB_ENV
- name: Update version
run: .github/scripts/update-version.sh $STABLE_VERSION $UNSTABLE_VERSION
- name: Update the change log with the approximate release date
run: |
date=$(date "+%Y-%m-%d")
sed -Ei "s/^## Unreleased$/## Version ${STABLE_VERSION}\/${UNSTABLE_VERSION} ($date)/" CHANGELOG.md
- name: Use CLA approved github bot
run: .github/scripts/use-cla-approved-github-bot.sh
- name: Create pull request against the release branch
env:
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
run: |
message="Prepare release ${STABLE_VERSION}/${UNSTABLE_VERSION}"
branch="opentelemetrybot/prepare-release-${STABLE_VERSION}-${UNSTABLE_VERSION}"
git commit -a -m "$message"
git push origin HEAD:$branch
gh pr create --title "[$RELEASE_BRANCH_NAME] $message" \
--body "$message." \
--head $branch \
--base $RELEASE_BRANCH_NAME
create-pull-request-against-main:
runs-on: ubuntu-latest
needs: prereqs
steps:
- uses: actions/checkout@v4
- name: Install toml
run: pip install toml
- name: Set environment variables
env:
PRERELEASE_VERSION: ${{ github.event.inputs.prerelease_version }}
run: |
if [[ -z $PRERELEASE_VERSION ]]; then
stable_version=$(./scripts/eachdist.py version --mode stable)
stable_version=${stable_version//.dev/}
else
stable_version=$PRERELEASE_VERSION
fi
unstable_version=$(./scripts/eachdist.py version --mode prerelease)
unstable_version=${unstable_version//.dev/}
if [[ $stable_version =~ ^([0-9]+)\.([0-9]+)\.0$ ]]; then
stable_major="${BASH_REMATCH[1]}"
stable_minor="${BASH_REMATCH[2]}"
stable_next_version="$stable_major.$((stable_minor + 1)).0"
elif [[ $stable_version =~ ^([0-9]+)\.([0-9]+)\.0 ]]; then
# pre-release version, e.g. 1.9.0rc2
stable_major="${BASH_REMATCH[1]}"
stable_minor="${BASH_REMATCH[2]}"
stable_next_version="$stable_major.$stable_minor.0"
else
echo "unexpected stable_version: $stable_version"
exit 1
fi
if [[ $unstable_version =~ ^0\.([0-9]+)b[0-9]+$ ]]; then
unstable_minor="${BASH_REMATCH[1]}"
else
echo "unexpected unstable_version: $unstable_version"
exit 1
fi
unstable_next_version="0.$((unstable_minor + 1))b0"
echo "STABLE_VERSION=${stable_version}" >> $GITHUB_ENV
echo "STABLE_NEXT_VERSION=${stable_next_version}.dev" >> $GITHUB_ENV
echo "UNSTABLE_VERSION=${unstable_version}" >> $GITHUB_ENV
echo "UNSTABLE_NEXT_VERSION=${unstable_next_version}.dev" >> $GITHUB_ENV
- name: Update version
run: .github/scripts/update-version.sh $STABLE_NEXT_VERSION $UNSTABLE_NEXT_VERSION
- name: Update the change log on main
run: |
# the actual release date on main will be updated at the end of the release workflow
date=$(date "+%Y-%m-%d")
sed -Ei "s/^## Unreleased$/## Unreleased\n\n## Version ${STABLE_VERSION}\/${UNSTABLE_VERSION} ($date)/" CHANGELOG.md
- name: Use CLA approved github bot
run: .github/scripts/use-cla-approved-github-bot.sh
- name: Create pull request against main
env:
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
run: |
message="Update version to ${STABLE_NEXT_VERSION}/${UNSTABLE_NEXT_VERSION}"
body="Update version to \`${STABLE_NEXT_VERSION}/${UNSTABLE_NEXT_VERSION}\`."
branch="opentelemetrybot/update-version-to-${STABLE_NEXT_VERSION}-${UNSTABLE_NEXT_VERSION}"
git commit -a -m "$message"
git push origin HEAD:$branch
gh pr create --title "$message" \
--body "$body" \
--head $branch \
--base main