From 7f9431963958935293d2a79d4ba45a9dd4cbb9c1 Mon Sep 17 00:00:00 2001 From: Ivan Valdes Date: Tue, 12 Nov 2024 11:25:41 -0700 Subject: [PATCH] release: add a prompt to release GitHub release Signed-off-by: Ivan Valdes --- scripts/release.sh | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index 8742623d6e2..b2f2986796d 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -337,19 +337,26 @@ main() { log_warning "WARNING: If not running on DRY_MODE, please do the GitHub release manually." log_warning "" else + read -p "Create GitHub draft release in ${REPOSITORY} [y/N]? " -r confirm + [[ "${confirm,,}" == "y" ]] || exit 1 + local gh_repo local release_notes_temp_file local release_url local gh_release_args=() - # For the main branch (v3.6), we should mark the release as a prerelease. - # The release-3.5 (v3.5) branch, should be marked as latest. And release-3.4 (v3.4) - # should be left without any additional mark (therefore, it doesn't need a special argument). - if [ "${BRANCH}" = "main" ]; then - gh_release_args=(--prerelease) - elif [ "${BRANCH}" = "release-3.5" ]; then - gh_release_args=(--latest) - fi + # Explicitly set release arguments per branch. + case "${BRANCH}" in + "main") + gh_release_args=(--latest=false --prerelease=true) + ;; + "release-3.5") + gh_release_args=(--latest=true --prerelease=false) + ;; + *) + gh_release_args=(--latest=false --prerelease=false) + ;; + esac if [ "${REPOSITORY}" = "$(pwd)" ]; then gh_repo=$(git remote get-url origin) @@ -391,8 +398,19 @@ main() { release_url=$(gh --repo "${gh_repo}" release view "${RELEASE_VERSION}" --json url --jq '.url') log_warning "" - log_warning "WARNING: The GitHub release for ${RELEASE_VERSION} has been created as a draft, please go to ${release_url} and release it." + log_warning "WARNING: The GitHub release for ${RELEASE_VERSION} has been created as a draft, please review it at ${release_url}." log_warning "" + + # Give a 10 minute timeout to the user to confirm the release. + read -p "Release GitHub release for ${RELEASE_VERSION} [y/N]? " -t 600 -r confirm + if [[ "${confirm,,}" == "y" ]]; then + maybe_run gh release edit "${RELEASE_VERSION}" \ + --repo "${gh_repo}" \ + --draft=false \ + "${gh_release_args[@]}" + else + log_warning "GitHub release for ${RELEASE_VERSION} has not been released. If manually releasing, please ensure that the bottom checkboxes are as expected (v3.4 with no option selected, v3.5 set as the latest release, v3.6 set as pre-release)." + fi fi log_success "Success."