-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathrelease.yml
383 lines (335 loc) · 14.9 KB
/
release.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
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
parameters:
- name: dotnetStagingPipelineResource
type: string
- name: dotnetMajorVersion
type: string
- name: isPreviewRelease
type: boolean
- name: releaseName
type: string
- name: releaseBranchName
type: string
- name: createReleaseAnnouncement
type: boolean
default: true
- name: announcementGist
type: string
- name: submitReleasePR
type: boolean
default: true
- name: createGitHubRelease
type: string
- name: isDryRun
type: boolean
default: false
stages:
- stage: Release
displayName: Release
dependsOn:
- PreRelease
- ReleaseApproval
variables:
- template: ../variables/pipelines.yml
- group: DotNet-Source-Build-Bot-Secrets
- group: DotNet-DotNetCli-Storage
- group: DotNetBot-GitHub-AllBranches
- name: releasePrRepo
value: dotnet/installer
- name: releasePrForkRepo
value: dotnet-sb-bot/installer
- name: announcementOrg
value: dotnet
- name: announcementRepo
value: source-build
- name: storageAccountName
value: dotnetcli
- name: blobContainerName
value: source-built-artifacts
- name: artifactsUploadBaseFilePath
${{ if parameters.isDryRun }}:
value: testing
${{ else }}:
value: assets
- name: sdkUploadBaseFilePath
${{ if parameters.isDryRun }}:
value: testing
${{ else }}:
value: sdks
- name: Codeql.Enabled
value: true
- ${{ if eq(parameters.dotnetMajorVersion, '6.0') }}:
- name: sourceBuildArtifactLeg
value: Build_Tarball_x64 CentOS7-Offline_Artifacts
- name: sourceBuiltArtifactsFileName
value: Private.SourceBuilt.Artifacts.$(sdkVersion).tar.gz
- name: sdkArtifactFileName
value: dotnet-sdk-$(sdkVersion)-*.tar.gz
- ${{ if eq(parameters.dotnetMajorVersion, '7.0') }}:
- name: sourceBuildArtifactLeg
value: Build_Tarball_x64 CentOSStream8-Offline_Artifacts
- name: sourceBuiltArtifactsFileName
value: Private.SourceBuilt.Artifacts.$(sdkVersion).tar.gz
- name: sdkArtifactFileName
value: dotnet-sdk-$(sdkVersion)-*.tar.gz
- ${{ if eq(parameters.dotnetMajorVersion, '8.0') }}:
- name: sourceBuildArtifactLeg
value: CentOSStream8_Offline_MsftSdk_x64_Artifacts
- name: sourceBuiltArtifactsFileName
value: Private.SourceBuilt.Artifacts.8.0.100.centos.8-x64.tar.gz
- name: sdkArtifactFileName
value: dotnet-sdk-*.tar.gz
# GitHub release is skipped for 6.0/7.0
# For dry run, we only create a draft release
- name: createGitHubRelease
${{ if eq(parameters.createGitHubRelease, 'auto') }}:
${{ if or(eq(parameters.dotnetMajorVersion, '6.0'), eq(parameters.dotnetMajorVersion, '7.0')) }}:
value: skip
${{ else }}:
${{ if parameters.isDryRun }}:
value: draft
${{ else }}:
value: full
${{ else }}:
value: ${{ parameters.createGitHubRelease }}
# Variables from the Pre-Release stage
- name: release
value: $[ stageDependencies.PreRelease.PreRelease.outputs['ReadReleaseInfo.Release'] ]
- name: sdkVersion
value: $[ stageDependencies.PreRelease.PreRelease.outputs['ReadReleaseInfo.SdkVersion'] ]
- name: runtimeVersion
value: $[ stageDependencies.PreRelease.PreRelease.outputs['ReadReleaseInfo.RuntimeVersion'] ]
- name: releaseChannel
value: $[ stageDependencies.PreRelease.PreRelease.outputs['ReadReleaseInfo.ReleaseChannel'] ]
- name: releaseTag
value: $[ stageDependencies.PreRelease.PreRelease.outputs['ReadReleaseInfo.ReleaseTag'] ]
- ${{ if or(eq(parameters.dotnetMajorVersion, '6.0'), eq(parameters.dotnetMajorVersion, '7.0')) }}:
- name: officialBuildPipelineId
value: $(INSTALLER_TARBALL_BUILD_CI_PIPELINE_ID)
- name: officialBuildRunId
value: $[ stageDependencies.PreRelease.PreRelease.outputs['AssociatedPipelineRuns.InstallerTarballBuildRunId'] ]
- ${{ else }}:
- name: officialBuildPipelineId
value: $(DOTNET_DOTNET_CI_PIPELINE_ID)
- name: officialBuildRunId
value: $[ stageDependencies.PreRelease.PreRelease.outputs['AssociatedPipelineRuns.DotnetDotnetRunId'] ]
- name: dotnetDotnetCommit
value: $[ stageDependencies.PreRelease.PreRelease.outputs['AssociatedPipelineRuns.DotnetDotnetCommit'] ]
jobs:
- job: Release
displayName: Announcements, PRs & Release
steps:
- checkout: self
path: dotnet-source-build
- ${{ if and(ne(variables.createGitHubRelease, 'skip'), ne(parameters.dotnetMajorVersion, '6.0'), ne(parameters.dotnetMajorVersion, '7.0')) }}:
- checkout: dotnet-dotnet
displayName: Checkout dotnet-dotnet
path: dotnet-dotnet
fetchDepth: 0
fetchTags: true
- script: |
set -euo pipefail
prerelease=''
if [ "${{ parameters.isPreviewRelease }}" = True ]; then
prerelease='--prerelease'
fi
draft=''
if [ "${{ variables.createGitHubRelease }}" = draft ]; then
draft='--draft'
fi
gh release create "$(releaseTag)" \
--repo dotnet/dotnet \
--title "${{ parameters.releaseName }}" \
--target "$(dotnetDotnetCommit)" \
$prerelease \
$draft
displayName: Create GitHub release
env:
GH_TOKEN: $(BotAccount-dotnet-bot-repo-PAT)
# Skip release tag validation for draft releases as the tag won't be immediately visible until the draft is published
- ${{ if or(eq(variables.createGitHubRelease, 'skip'), eq(variables.createGitHubRelease, 'full'), eq(parameters.dotnetMajorVersion, '6.0'), eq(parameters.dotnetMajorVersion, '7.0')) }}:
- script: |
set -euo pipefail
if [[ "$(releaseChannel)" == '6.0' || "$(releaseChannel)" == '7.0' ]]; then
repo='installer'
else
repo='dotnet'
fi
# Checks for all matching tags (there can be more, e.g. 7.0.100 will match 7.0.100-preview.1.21102.12)
query="{ repository(owner: \"dotnet\", name: \"$repo\") { refs(refPrefix: \"refs/tags/\", last: 100, query: \"$(releaseTag)\") { nodes { name }}}}"
tags=$(gh api graphql -f query="$query" --template '{{.data.repository.refs.nodes}}')
# Find the exact match
if echo "$tags" | grep -q "map\[name:$(releaseTag)\]"; then
echo "Tag $(releaseTag) exists"
else
echo "##vso[task.logissue type=error]Tag $(releaseTag) does not exist in dotnet/$repo"
exit 1
fi
displayName: Validate release tag
env:
GH_TOKEN: $(BotAccount-dotnet-sb-bot-pat)
- ${{ if parameters.createReleaseAnnouncement }}:
- script: |
set -euxo pipefail
query='query { repository(owner: "${{ variables.announcementOrg }}", name: "${{ variables.announcementRepo }}") { id } }'
echo "${query}"
repo_id=$( gh api graphql -f query="$query" --template '{{.data.repository.id}}' )
echo ${{ variables.announcementOrg }}/${{ variables.announcementRepo }} repo ID is ${repo_id}
query='query { repository(name: "${{ variables.announcementRepo }}", owner: "${{ variables.announcementOrg }}") { discussionCategories(first: 10) { edges { node { id, name } } } } }'
echo "${query}"
category_id=$( gh api graphql -f query="$query" --template '{{range .data.repository.discussionCategories.edges}}{{if eq .node.name "Announcements"}}{{.node.id}}{{end}}{{end}}' )
echo Discussion Category ID is ${category_id}
echo "##vso[task.setvariable variable=RepoId]$repo_id"
echo "##vso[task.setvariable variable=DiscussionCategoryId]$category_id"
displayName: Get announcement category
env:
GH_TOKEN: $(BotAccount-dotnet-sb-bot-pat)
- script: |
set -euo pipefail
echo "Repo ID is $(RepoId)"
echo "Discussion Category ID is $(DiscussionCategoryId)"
if [[ -z '${{ parameters.announcementGist }}' ]]; then
echo "Loading announcement template from source-build-release-announcement.md"
prerelease=''
if [ ${{ parameters.isPreviewRelease }} = True ]; then
prerelease='--prerelease'
fi
announcement=$("./create-announcement-draft.sh" \
--template "source-build-release-announcement.md" \
--channel "$(releaseChannel)" \
$prerelease \
--release "$(release)" \
--release-name "${{ parameters.releaseName }}" \
--runtime-version "$(runtimeVersion)" \
--sdk-version "$(sdkVersion)" \
--tag "$(releaseTag)")
# Get the line in the template that is prefixed with "Title:" and remove the prefix
title=$(echo "$announcement" | grep "^Title:" | cut -d " " -f2-)
# Get the inverse of the above selection
body=$(echo "$announcement" | grep -v "^Title:")
else
echo "Loading announcement template from gist ${{ parameters.announcementGist }}"
# Get title from the gist name
set +o pipefail # gh fails with 141 but returns the correct output
title="$(gh gist view '${{ parameters.announcementGist }}' --raw | head -n 1)"
body="$(gh gist view '${{ parameters.announcementGist }}' | tail -n +2)"
if [[ -z "$title" ]]; then
echo "##vso[task.logissue type=error]Could not get title from gist ${{ parameters.announcementGist }}"
exit 1
fi
if [[ -z "$body" ]]; then
echo "##vso[task.logissue type=error]Could not get announcement text from gist ${{ parameters.announcementGist }}"
exit 1
fi
set -o pipefail
fi
query='mutation($RepoId: ID!, $categoryId: ID!, $body: String!, $title: String!) { createDiscussion(input: {repositoryId: $RepoId, categoryId: $categoryId, body: $body, title: $title}) { discussion { url } } }'
if [ ${{ parameters.isDryRun }} = True ]; then
set +x
echo -e "\n\n\n#########################\n\n"
echo "Doing a dry run, not submitting announcement."
echo -e "\n\n#########################\n\n\n"
echo "Announcement title: $title"
echo "Announcement body: $body"
else
echo "Submitting announcement."
announcement_url=$( gh api graphql -F RepoId=$(RepoId) -F categoryId=$(DiscussionCategoryId) -F body="$body" -F title="$title" -f query="$query" --template '{{.data.createDiscussion.discussion.url}}' )
echo "Announcement URL: $announcement_url"
echo "Tag URL: $TAG_URL"
echo "Release Notes URL: $RELEASE_NOTES_URL"
fi
displayName: Submit announcement discussion
workingDirectory: $(Agent.BuildDirectory)/dotnet-source-build/eng
env:
GH_TOKEN: $(BotAccount-dotnet-sb-bot-pat)
- ${{ if parameters.submitReleasePR }}:
- task: DownloadPipelineArtifact@2
name: DownloadSourceBuiltArtifactsStep
displayName: Download Source-Built Artifacts
inputs:
source: specific
project: $(AZDO_PROJECT)
pipeline: $(officialBuildPipelineId)
runVersion: specific
runId: $(officialBuildRunId)
artifact: $(sourceBuildArtifactLeg)
patterns: $(sourceBuiltArtifactsFileName)
- task: DownloadPipelineArtifact@2
name: DownloadSourceBuiltSDKStep
displayName: Download Source-Built SDK
inputs:
source: specific
project: $(AZDO_PROJECT)
pipeline: $(officialBuildPipelineId)
runVersion: specific
runId: $(officialBuildRunId)
artifact: $(sourceBuildArtifactLeg)
patterns: $(sdkArtifactFileName)
- template: ../steps/upload-to-blob-storage.yml
parameters:
file: $(PIPELINE.WORKSPACE)/$(sourceBuiltArtifactsFileName)
accountName: $(storageAccountName)
containerName: $(blobContainerName)
uploadPath: $(artifactsUploadBaseFilePath)
azureStorageKey: $(dotnetcli-storage-key)
- template: ../steps/upload-to-blob-storage.yml
parameters:
file: $(PIPELINE.WORKSPACE)/$(sdkArtifactFileName)
accountName: $(storageAccountName)
containerName: $(blobContainerName)
uploadPath: $(sdkUploadBaseFilePath)
azureStorageKey: $(dotnetcli-storage-key)
- script: |
set -euo pipefail
export RELEASE_DATE=$(date +"%B %Y") # e.g. "March 2022"
export RUNTIME_VERSION="$(runtimeVersion)"
export SDK_VERSION="$(sdkVersion)"
template="$(envsubst < source-build-release-pr.md)"
# Get the line in the template that is prefixed with "Title:" and remove the prefix
title=$(echo "$template" | grep "^Title:" | cut -d " " -f2-)
# Get the inverse of the above selection
body=$(echo "$template" | grep -v "^Title:")
echo "TargetRepo: $(releasePrRepo)"
echo "ForkRepo: $(releasePrForkRepo)"
echo "SdkVersion: $(sdkVersion)"
echo "Title: $title"
echo "Body: $body"
extraArgs=()
if [[ "$(releaseChannel)" == '6.0' || "$(releaseChannel)" == '7.0' ]]; then
extraArgs+=("--globalJson" "src/SourceBuild/tarball/content/global.json")
extraArgs+=("--versionsProps" "eng/Versions.props")
fi
if [ "${{ parameters.isPreviewRelease }}" = True ]; then
target_branch='main'
else
target_branch="${{ parameters.releaseBranchName }}"
if [[ "$target_branch" == internal/* ]]; then
target_branch="${target_branch#internal/}"
fi
fi
if [ "${{ parameters.isDryRun }}" = True ]; then
echo "Doing a dry run, not submitting PR. Would have called:"
echo "./submit-source-build-release-pr.sh"
echo " --setupGitAuth"
echo " --targetRepo $(releasePrRepo)"
echo " --forkRepo $(releasePrForkRepo)"
echo " --sdkVersion $(sdkVersion)"
echo " --title $title"
echo " --body $body"
echo " --targetBranch $target_branch"
echo " ${extraArgs[@]}"
else
echo "Submitting PR"
./submit-source-build-release-pr.sh \
--setupGitAuth \
--targetRepo "$(releasePrRepo)" \
--forkRepo "$(releasePrForkRepo)" \
--sdkVersion "$(sdkVersion)" \
--title "$title" \
--body "$body" \
--targetBranch "$target_branch" \
"${extraArgs[@]}"
fi
displayName: Submit Release PR
workingDirectory: $(Agent.BuildDirectory)/dotnet-source-build/eng
env:
GH_TOKEN: $(BotAccount-dotnet-sb-bot-pat)