@@ -15,15 +15,15 @@ help() {
15
15
echo " WARNING: This does not perform the 'Add API capabilities', 'Performance testing' "
16
16
echo " or 'Documentation' steps. These steps must be performed manually BEFORE running this tool."
17
17
echo " "
18
- echo " WARNING: This script does not sign releases, publish releases to github or sent announcement"
19
- echo " emails. These steps must be performed manually AFTER running this tool."
18
+ echo " WARNING: This script does not send announcement emails. This step must be performed manually AFTER running this tool."
20
19
echo " "
21
20
echo " args:"
22
21
echo " version: version of etcd to release, e.g. '3.2.18'"
23
22
echo " flags:"
24
- echo " --no-upload: skip gs://etcd binary artifact uploads."
25
- echo " --no-docker-push: skip docker image pushes."
26
23
echo " --in-place: build binaries using current branch."
24
+ echo " --no-docker-push: skip docker image pushes."
25
+ echo " --no-gh-release: skip creating the GitHub release using gh."
26
+ echo " --no-upload: skip gs://etcd binary artifact uploads."
27
27
echo " "
28
28
}
29
29
@@ -92,6 +92,21 @@ main() {
92
92
exit 1
93
93
fi
94
94
95
+ if [ " ${NO_GH_RELEASE} " == 1 ]; then
96
+ echo " Skipping gh verification, --no-gh-release is set"
97
+ else
98
+ # Check that gh is installed and logged in.
99
+ echo " Check gh installation"
100
+ if ! command -v gh > /dev/null; then
101
+ log_error " Cannot find gh. Please follow the installation instructions at https://github.com/cli/cli#installation"
102
+ exit 1
103
+ fi
104
+ if ! gh auth status & > /dev/null; then
105
+ log_error " GitHub authentication failed for gh. Please run gh auth login."
106
+ exit 1
107
+ fi
108
+ fi
109
+
95
110
# If the release tag does not already exist remotely, create it.
96
111
log_callout " Create tag if not present"
97
112
if [ " ${remote_tag_exists} " -eq 0 ]; then
@@ -285,10 +300,74 @@ main() {
285
300
exit 1
286
301
fi
287
302
288
- # TODO: signing process
289
- log_warning " "
290
- log_warning " WARNING: The release has not been signed and published to github. This must be done manually."
291
- log_warning " "
303
+ if [ " ${DRY_RUN} " == " true" ] || [ " ${NO_GH_RELEASE} " == 1 ]; then
304
+ log_warning " "
305
+ log_warning " WARNING: Skipping creating GitHub release, --no-gh-release is set."
306
+ log_warning " WARNING: If not running on DRY_MODE, please do the GitHub release manually."
307
+ log_warning " "
308
+ else
309
+ local gh_repo
310
+ local release_notes_temp_file
311
+ local release_url
312
+ local gh_release_args=()
313
+
314
+ # For the main branch (v3.6), we should mark the release as a prerelease.
315
+ # The release-3.5 (v3.5) branch, should be marked as latest. And release-3.4 (v3.4)
316
+ # should be left without any additional mark (therefore, it doesn't need a special argument).
317
+ if [ " ${BRANCH} " = " main" ]; then
318
+ gh_release_args=(--prerelease)
319
+ elif [ " ${BRANCH} " = " release-3.5" ]; then
320
+ gh_release_args=(--latest)
321
+ fi
322
+
323
+ if [ " ${REPOSITORY} " = " $( pwd) " ]; then
324
+ gh_repo=$( git remote get-url origin)
325
+ else
326
+ gh_repo=" ${REPOSITORY} "
327
+ fi
328
+
329
+ gh_repo=$( echo " ${gh_repo} " | sed ' s/^[^@]\+@//' | sed ' s/https\?:\/\///' | sed ' s/\.git$//' | tr ' :' ' /' )
330
+ log_callout " Creating GitHub release for ${RELEASE_VERSION} on ${gh_repo} "
331
+
332
+ release_notes_temp_file=$( mktemp)
333
+
334
+ local release_version=${RELEASE_VERSION# v} # Remove the v prefix from the release version (i.e., v3.6.1 -> 3.6.1)
335
+ local release_version_major_minor=${release_version% .* } # Remove the patch from the version (i.e., 3.6)
336
+ local release_version_major=${release_version_major_minor% .* } # Extract the major (i.e., 3)
337
+ local release_version_minor=${release_version_major_minor/* ./ } # Extract the minor (i.e., 6)
338
+
339
+ # Disable sellcheck SC2016, the single quoted syntax for sed is intentional.
340
+ # shellcheck disable=SC2016
341
+ sed ' s/${RELEASE_VERSION}/' " ${RELEASE_VERSION} " ' /g' ./scripts/release_notes.tpl.txt |
342
+ sed ' s/${RELEASE_VERSION_MAJOR_MINOR}/' " ${release_version_major_minor} " ' /g' |
343
+ sed ' s/${RELEASE_VERSION_MAJOR}/' " ${release_version_major} " ' /g' |
344
+ sed ' s/${RELEASE_VERSION_MINOR}/' " ${release_version_minor} " ' /g' > " ${release_notes_temp_file} "
345
+
346
+ # This condition may seem redundant because of the previous check, but it's
347
+ # necessary because release-3.4 doesn't have the maybe_run function.
348
+ if [ " ${DRY_RUN} " == " false" ]; then
349
+ if ! gh --repo " ${gh_repo} " release view " ${RELEASE_VERSION} " & > /dev/null; then
350
+ gh release create " ${RELEASE_VERSION} " \
351
+ --repo " ${gh_repo} " \
352
+ --draft \
353
+ --title " ${RELEASE_VERSION} " \
354
+ --notes-file " ${release_notes_temp_file} " \
355
+ " ${gh_release_args[@]} "
356
+ fi
357
+
358
+ # Upload files one by one, as gh doesn't support passing globs as input.
359
+ find ./release ' (' -name ' *.tar.gz' -o -name ' *.zip' ' )' -exec \
360
+ gh --repo " ${gh_repo} " release upload " ${RELEASE_VERSION} " {} --clobber \;
361
+ gh --repo " ${gh_repo} " release upload " ${RELEASE_VERSION} " ./release/SHA256SUMS --clobber
362
+
363
+ release_url=$( gh --repo " ${gh_repo} " release view " ${RELEASE_VERSION} " --json url --jq ' .url' )
364
+
365
+ log_warning " "
366
+ log_warning " WARNING: The GitHub release for ${RELEASE_VERSION} has been created as a draft, please go to ${release_url} and release it."
367
+ log_warning " "
368
+ fi
369
+ fi
370
+
292
371
log_success " Success."
293
372
exit 0
294
373
}
@@ -297,6 +376,7 @@ POSITIONAL=()
297
376
NO_UPLOAD=0
298
377
NO_DOCKER_PUSH=0
299
378
IN_PLACE=0
379
+ NO_GH_RELEASE=0
300
380
301
381
while test $# -gt 0; do
302
382
case " $1 " in
@@ -317,6 +397,10 @@ while test $# -gt 0; do
317
397
NO_DOCKER_PUSH=1
318
398
shift
319
399
;;
400
+ --no-gh-release)
401
+ NO_GH_RELEASE=1
402
+ shift
403
+ ;;
320
404
* )
321
405
POSITIONAL+=(" $1 " ) # save it in an array for later
322
406
shift # past argument
0 commit comments