@@ -33,15 +33,15 @@ help() {
33
33
echo " WARNING: This does not perform the 'Add API capabilities', 'Performance testing' "
34
34
echo " or 'Documentation' steps. These steps must be performed manually BEFORE running this tool."
35
35
echo " "
36
- echo " WARNING: This script does not sign releases, publish releases to github or sent announcement"
37
- echo " emails. These steps must be performed manually AFTER running this tool."
36
+ echo " WARNING: This script does not send announcement emails. This step must be performed manually AFTER running this tool."
38
37
echo " "
39
38
echo " args:"
40
39
echo " version: version of etcd to release, e.g. 'v3.2.18'"
41
40
echo " flags:"
42
- echo " --no-upload: skip gs://etcd binary artifact uploads."
43
- echo " --no-docker-push: skip docker image pushes."
44
41
echo " --in-place: build binaries using current branch."
42
+ echo " --no-docker-push: skip docker image pushes."
43
+ echo " --no-gh-release: skip creating the GitHub release using gh."
44
+ echo " --no-upload: skip gs://etcd binary artifact uploads."
45
45
echo " "
46
46
echo " One can perform a (dry-run) test release from any (uncommitted) branch using:"
47
47
echo " DRY_RUN=true REPOSITORY=\` pwd\` BRANCH='local-branch-name' ./scripts/release 3.5.0-foobar.2"
@@ -119,6 +119,21 @@ main() {
119
119
exit 1
120
120
fi
121
121
122
+ if [ " ${NO_GH_RELEASE} " == 1 ]; then
123
+ log_callout " Skipping gh verification, --no-gh-release is set"
124
+ else
125
+ # Check that gh is installed and logged in.
126
+ log_callout " Check gh installation"
127
+ if ! command -v gh > /dev/null; then
128
+ log_error " Cannot find gh. Please follow the installation instructions at https://github.com/cli/cli#installation"
129
+ exit 1
130
+ fi
131
+ if ! gh auth status & > /dev/null; then
132
+ log_error " GitHub authentication failed for gh. Please run gh auth login."
133
+ exit 1
134
+ fi
135
+ fi
136
+
122
137
# If the release tag does not already exist remotely, create it.
123
138
log_callout " Create tag if not present"
124
139
if [ " ${remote_tag_exists} " -eq 0 ]; then
@@ -314,10 +329,70 @@ main() {
314
329
exit 1
315
330
fi
316
331
317
- # TODO: signing process
318
- log_warning " "
319
- log_warning " WARNING: The release has not been signed and published to github. This must be done manually."
320
- log_warning " "
332
+ if [ " ${DRY_RUN} " == " true" ] || [ " ${NO_GH_RELEASE} " == 1 ]; then
333
+ log_warning " "
334
+ log_warning " WARNING: Skipping creating GitHub release, --no-gh-release is set."
335
+ log_warning " WARNING: If not running on DRY_MODE, please do the GitHub release manually."
336
+ log_warning " "
337
+ else
338
+ local gh_repo
339
+ local release_notes_temp_file
340
+ local release_url
341
+ local gh_release_args=()
342
+
343
+ # For the main branch (v3.6), we should mark the release as a prerelease.
344
+ # The release-3.5 (v3.5) branch, should be marked as latest. And release-3.4 (v3.4)
345
+ # should be left without any additional mark (therefore, it doesn't need a special argument).
346
+ if [ " ${BRANCH} " = " main" ]; then
347
+ gh_release_args=(--prerelease)
348
+ elif [ " ${BRANCH} " = " release-3.5" ]; then
349
+ gh_release_args=(--latest)
350
+ fi
351
+
352
+ if [ " ${REPOSITORY} " = " $( pwd) " ]; then
353
+ gh_repo=$( git remote get-url origin)
354
+ else
355
+ gh_repo=" ${REPOSITORY} "
356
+ fi
357
+
358
+ gh_repo=$( echo " ${gh_repo} " | sed ' s/^[^@]\+@//' | sed ' s/https\?:\/\///' | sed ' s/\.git$//' | tr ' :' ' /' )
359
+ log_callout " Creating GitHub release for ${RELEASE_VERSION} on ${gh_repo} "
360
+
361
+ release_notes_temp_file=$( mktemp)
362
+
363
+ local release_version=${RELEASE_VERSION# v} # Remove the v prefix from the release version (i.e., v3.6.1 -> 3.6.1)
364
+ local release_version_major_minor=${release_version% .* } # Remove the patch from the version (i.e., 3.6)
365
+ local release_version_major=${release_version_major_minor% .* } # Extract the major (i.e., 3)
366
+ local release_version_minor=${release_version_major_minor/* ./ } # Extract the minor (i.e., 6)
367
+
368
+ # Disable sellcheck SC2016, the single quoted syntax for sed is intentional.
369
+ # shellcheck disable=SC2016
370
+ sed ' s/${RELEASE_VERSION}/' " ${RELEASE_VERSION} " ' /g' ./scripts/release_notes.tpl.txt |
371
+ sed ' s/${RELEASE_VERSION_MAJOR_MINOR}/' " ${release_version_major_minor} " ' /g' |
372
+ sed ' s/${RELEASE_VERSION_MAJOR}/' " ${release_version_major} " ' /g' |
373
+ sed ' s/${RELEASE_VERSION_MINOR}/' " ${release_version_minor} " ' /g' > " ${release_notes_temp_file} "
374
+
375
+ if ! gh --repo " ${gh_repo} " release view " ${RELEASE_VERSION} " & > /dev/null; then
376
+ maybe_run gh release create " ${RELEASE_VERSION} " \
377
+ --repo " ${gh_repo} " \
378
+ --draft \
379
+ --title " ${RELEASE_VERSION} " \
380
+ --notes-file " ${release_notes_temp_file} " \
381
+ " ${gh_release_args[@]} "
382
+ fi
383
+
384
+ # Upload files one by one, as gh doesn't support passing globs as input.
385
+ maybe_run find ./release ' (' -name ' *.tar.gz' -o -name ' *.zip' ' )' -exec \
386
+ gh --repo " ${gh_repo} " release upload " ${RELEASE_VERSION} " {} --clobber \;
387
+ maybe_run gh --repo " ${gh_repo} " release upload " ${RELEASE_VERSION} " ./release/SHA256SUMS --clobber
388
+
389
+ release_url=$( gh --repo " ${gh_repo} " release view " ${RELEASE_VERSION} " --json url --jq ' .url' )
390
+
391
+ log_warning " "
392
+ log_warning " WARNING: The GitHub release for ${RELEASE_VERSION} has been created as a draft, please go to ${release_url} and release it."
393
+ log_warning " "
394
+ fi
395
+
321
396
log_success " Success."
322
397
exit 0
323
398
}
@@ -326,6 +401,7 @@ POSITIONAL=()
326
401
NO_UPLOAD=0
327
402
NO_DOCKER_PUSH=0
328
403
IN_PLACE=0
404
+ NO_GH_RELEASE=0
329
405
330
406
while test $# -gt 0; do
331
407
case " $1 " in
@@ -346,6 +422,10 @@ while test $# -gt 0; do
346
422
NO_DOCKER_PUSH=1
347
423
shift
348
424
;;
425
+ --no-gh-release)
426
+ NO_GH_RELEASE=1
427
+ shift
428
+ ;;
349
429
* )
350
430
POSITIONAL+=(" $1 " ) # save it in an array for later
351
431
shift # past argument
0 commit comments