-
Notifications
You must be signed in to change notification settings - Fork 97
228 lines (221 loc) · 10.4 KB
/
release.yaml
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# ------------------------------------------------------------
# Copyright 2023 The Radius Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------
name: Release Radius
on:
push:
branches:
- main
- 'release/*'
paths:
- 'versions.yaml'
pull_request:
branches:
- main
- 'release/*'
paths:
- 'versions.yaml'
env:
GITHUB_TOKEN: ${{ secrets.GH_RAD_CI_BOT_PAT }}
jobs:
generate_release_note:
name: Generate release note from template
runs-on: ubuntu-latest
# We should only create the release note if this is a pull request against main
if: github.repository == 'radius-project/radius' && github.event_name == 'pull_request' && github.base_ref == 'main'
env:
RELNOTE_FOUND: false
steps:
- name: Checkout radius-project/radius
uses: actions/checkout@v4
- name: Get supported versions from versions.yaml
id: get-supported-versions
uses: mikefarah/[email protected]
with:
# Get a comma-separated list of supported versions
cmd: yq '.supported[].version' versions.yaml | tr '\n' ',' | sed 's/,$//'
- name: Determine desired release version
id: get-version
run: |
./.github/scripts/release-get-version.sh ${{ steps.get-supported-versions.outputs.result }} "."
- name: Find the previous tag
uses: actions/github-script@v7
id: latest-release-tag
with:
github-token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
result-encoding: string
script: |
const { data } = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
})
return data.tag_name
- name: Generate the release notes
uses: actions/github-script@v7
id: generate-notes
with:
github-token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
result-encoding: string
script: |
const { data } = await github.rest.repos.generateReleaseNotes({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: '${{ steps.get-version.outputs.release-version }}',
target_commitish: 'main',
previous_tag_name: '${{ steps.latest-release-tag.outputs.result }}',
})
return data.body
- uses: marocchino/sticky-pull-request-comment@v2
with:
header: relnote-${{ github.run_id }}
number: ${{ github.event.pull_request.number }}
hide: true
hide_classify: 'OUTDATED'
message: |
## Release Information
* Previous version: ${{ steps.latest-release-tag.outputs.result }}
* New version: ${{ steps.get-version.outputs.release-version }}
## Change logs
```
${{ steps.generate-notes.outputs.result }}
```
- name: Find release note
shell: bash
run: |
if [ -f ./docs/release-notes/${{ steps.get-version.outputs.release-version }}.md ]; then
echo "RELNOTE_FOUND=true" >> $GITHUB_ENV
fi
- uses: marocchino/sticky-pull-request-comment@v2
continue-on-error: true
if: ${{ !contains(steps.get-version.outputs.release-version, '-rc') && env.RELNOTE_FOUND == 'false' }}
with:
header: relnote-${{ github.run_id }}
number: ${{ github.event.pull_request.number }}
append: true
message: |
## :warning: Missing release note :warning:
This is the official Radius release. Create the release note by following instruction:
1. Create ./docs/release-notes/${{ steps.get-version.outputs.release-version }}.md from [release note template](https://github.com/radius-project/radius/blob/main/docs/release-notes/template.md)
2. Update the each section and add the above Change logs to the end of release note.
3. Push release note changes to the PR branch.
- name: Stop the workflow if release is the official and its release note is not found.
if: ${{ !contains(steps.get-version.outputs.release-version, '-rc') && env.RELNOTE_FOUND == 'false' }}
run: exit 1
release:
name: Create a new Radius release
if: github.repository == 'radius-project/radius' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout radius-project/radius@main
uses: actions/checkout@v4
with:
repository: radius-project/radius
ref: main
token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
path: radius
- name: Checkout radius-project/deployment-engine@main
uses: actions/checkout@v4
with:
repository: radius-project/deployment-engine
ref: main
token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
path: deployment-engine
- name: Checkout radius-project/recipes@main
uses: actions/checkout@v4
with:
repository: radius-project/recipes
ref: main
token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
path: recipes
- name: Checkout radius-project/dashboard@main
uses: actions/checkout@v4
with:
repository: radius-project/dashboard
ref: main
token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
path: dashboard
- name: Checkout radius-project/bicep-types-aws@main
uses: actions/checkout@v4
with:
repository: radius-project/bicep-types-aws
ref: main
token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
path: bicep-types-aws
- name: Set up GitHub credentials
run: |
git config --global user.name "Radius CI Bot"
git config --global user.email "[email protected]"
- name: Get supported versions from versions.yaml
id: get-supported-versions
uses: mikefarah/[email protected]
with:
# Get a comma-separated list of supported versions
cmd: yq '.supported[].version' ./radius/versions.yaml | tr '\n' ',' | sed 's/,$//'
- name: Determine desired release version
id: get-version
run: |
./radius/.github/scripts/release-get-version.sh ${{ steps.get-supported-versions.outputs.result }} radius
- name: Check if release branch exists
id: release-branch-exists
uses: actions/github-script@v7
with:
result-encoding: string
script: |
try {
const { data } = await github.rest.repos.getBranch({
owner: context.repo.owner,
repo: context.repo.repo,
branch: '${{ steps.get-version.outputs.release-branch-name }}',
})
if (data && data.name == '${{ steps.get-version.outputs.release-branch-name }}' && context.ref == 'refs/heads/main' && context.eventName == 'push') {
console.log("Release branch ${{ steps.get-version.outputs.release-branch-name }} already exists and this is a push to main.")
return 'true'
} else {
console.log("This is not a push to main.")
return 'false'
}
} catch (error) {
console.log("Release branch ${{ steps.get-version.outputs.release-branch-name }} does not exist.")
return 'false'
}
- name: Generate release summary
if: steps.release-branch-exists.outputs.result == 'false'
run: |
echo "## Release" >> $GITHUB_STEP_SUMMARY
echo "* Release driver: $GITHUB_ACTOR ">> $GITHUB_STEP_SUMMARY
echo "* Supported versions: ${{ steps.get-supported-versions.outputs.result }}" >> $GITHUB_STEP_SUMMARY
echo "* Desired release tag: ${{ steps.get-version.outputs.release-version }}" >> $GITHUB_STEP_SUMMARY
echo "* Desired release branch: ${{ steps.get-version.outputs.release-branch-name }}" >> $GITHUB_STEP_SUMMARY
echo "* Release date: $(date)" >> $GITHUB_STEP_SUMMARY
- name: Release radius-project/radius version ${{ steps.get-version.outputs.release-version }}
if: success() && steps.release-branch-exists.outputs.result == 'false'
run: |
./radius/.github/scripts/release-create-tag-and-branch.sh radius ${{ steps.get-version.outputs.release-version }} ${{ steps.get-version.outputs.release-branch-name }}
- name: Release radius-project/deployment-engine version ${{ steps.get-version.outputs.release-version }}
if: success() && steps.release-branch-exists.outputs.result == 'false'
run: |
./radius/.github/scripts/release-create-tag-and-branch.sh deployment-engine ${{ steps.get-version.outputs.release-version }} ${{ steps.get-version.outputs.release-branch-name }}
- name: Release radius-project/recipes version ${{ steps.get-version.outputs.release-version }}
if: success() && steps.release-branch-exists.outputs.result == 'false'
run: |
./radius/.github/scripts/release-create-tag-and-branch.sh recipes ${{ steps.get-version.outputs.release-version }} ${{ steps.get-version.outputs.release-branch-name }}
- name: Release radius-project/dashboard version ${{ steps.get-version.outputs.release-version }}
if: success() && steps.release-branch-exists.outputs.result == 'false'
run: |
./radius/.github/scripts/release-create-tag-and-branch.sh dashboard ${{ steps.get-version.outputs.release-version }} ${{ steps.get-version.outputs.release-branch-name }}
- name: Release radius-project/bicep-types-aws version ${{ steps.get-version.outputs.release-version }}
if: success() && steps.release-branch-exists.outputs.result == 'false'
run: |
./radius/.github/scripts/release-create-tag-and-branch.sh bicep-types-aws ${{ steps.get-version.outputs.release-version }} ${{ steps.get-version.outputs.release-branch-name }}