Adding theoretical main variation (#17904)

This commit is contained in:
George Karr 2024-04-02 13:26:31 -05:00 committed by GitHub
parent 8a22f13f53
commit 011d97fad1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,14 +45,14 @@
# :;::, # :;::,
# #
# #
# /$$$$$$$$ /$$ /$$$$$$$$ /$$$$$$$$ /$$$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$$ /$$$$$$ /$$ /$$ # /$$$$$$$$ /$$ /$$$$$$$$ /$$$$$$$$ /$$$$$$$$
# | $$_____/| $$ | $$_____/| $$_____/|__ $$__/ | $$__ $$ /$$__ $$|__ $$__//$$__ $$| $$ | $$ # | $$_____/| $$ | $$_____/| $$_____/|__ $$__/
# | $$ | $$ | $$ | $$ | $$ | $$ \ $$| $$ \ $$ | $$ | $$ \__/| $$ | $$ # | $$ | $$ | $$ | $$ | $$
# | $$$$$ | $$ | $$$$$ | $$$$$ | $$ | $$$$$$$/| $$$$$$$$ | $$ | $$ | $$$$$$$$ # | $$$$$ | $$ | $$$$$ | $$$$$ | $$
# | $$__/ | $$ | $$__/ | $$__/ | $$ | $$____/ | $$__ $$ | $$ | $$ | $$__ $$ # | $$__/ | $$ | $$__/ | $$__/ | $$
# | $$ | $$ | $$ | $$ | $$ | $$ | $$ | $$ | $$ | $$ $$| $$ | $$ # | $$ | $$ | $$ | $$ | $$
# | $$ | $$$$$$$$| $$$$$$$$| $$$$$$$$ | $$ | $$ | $$ | $$ | $$ | $$$$$$/| $$ | $$ # | $$ | $$$$$$$$| $$$$$$$$| $$$$$$$$ | $$
# |__/ |________/|________/|________/ |__/ |__/ |__/ |__/ |__/ \______/ |__/ |__/ # |__/ |________/|________/|________/ |__/
# #
# /$$$$$$$ /$$$$$$$$ /$$ /$$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$$ /$$$$$$$ # /$$$$$$$ /$$$$$$$$ /$$ /$$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$$ /$$$$$$$
# | $$__ $$| $$_____/| $$ | $$_____/ /$$__ $$ /$$__ $$| $$_____/| $$__ $$ # | $$__ $$| $$_____/| $$ | $$_____/ /$$__ $$ /$$__ $$| $$_____/| $$__ $$
@ -68,6 +68,7 @@ usage() {
echo "Usage: $0 [options] (optional|start_version)" echo "Usage: $0 [options] (optional|start_version)"
echo "" echo ""
echo "Options:" echo "Options:"
echo " -a, --main_release This is a release based off of main and not a tagged patch."
echo " -c, --cherry_pick_resolved The script has been run, had merge conflicts, and those have been resolved and all cherry picks completed manually." echo " -c, --cherry_pick_resolved The script has been run, had merge conflicts, and those have been resolved and all cherry picks completed manually."
echo " -d, --dry_run Perform a trial run with no changes made" echo " -d, --dry_run Perform a trial run with no changes made"
echo " -f, --force Skip all confirmations" echo " -f, --force Skip all confirmations"
@ -83,6 +84,9 @@ usage() {
echo "" echo ""
echo "Environment Variables:" echo "Environment Variables:"
echo " OPEN_API_KEY Open API key used for fallback if not provided via -o or --open-api-key option" echo " OPEN_API_KEY Open API key used for fallback if not provided via -o or --open-api-key option"
echo " SLACK_GENERAL_TOKEN Slack token to publish via curl to #general"
echo " SLACK_HELP_INFRA_TOKEN Slack token to publish via curl to #help-infrastructure"
echo " SLACK_HELP_ENG_TOKEN Slack token to publish via curl to #help-engineering"
echo "" echo ""
echo "Examples:" echo "Examples:"
echo " $0 -d Dry run the script" echo " $0 -d Dry run the script"
@ -176,14 +180,22 @@ validate_and_format_date() {
} }
print_announce_info() { print_announce_info() {
qa_ticket=`gh issue list --search "Release QA: $target_milestone in:title" --json url | jq -r .[0].url`
docker_deploy=`gh run list --workflow goreleaser-snapshot-fleet.yaml --json event,url,headBranch --limit 100 | jq -r "[.[]|select(.headBranch==\"$target_patch_branch\")][0].url"`
echo echo
echo "For announcing in #help-engineering" echo "For announcing in #help-engineering"
echo "====================================================" echo "===================================================="
echo "Release $target_milestone QA ticket and docker publish" echo "Release $target_milestone QA ticket and docker publish"
echo "QA ticket for Release $target_milestone " `gh issue list --search "Release QA: $target_milestone in:title" --json url | jq -r .[0].url` echo "QA ticket for Release $target_milestone " $qa_ticket
echo "Docker Deploy status " `gh run list --workflow goreleaser-snapshot-fleet.yaml --json event,url,headBranch --limit 100 | jq -r "[.[]|select(.headBranch==\"$target_patch_branch\")][0].url"` echo "Docker Deploy status " $docker_deploy
echo "List of tickets pulled into release https://github.com/fleetdm/fleet/milestone/$target_milestone_number" echo "List of tickets pulled into release https://github.com/fleetdm/fleet/milestone/$target_milestone_number"
echo echo
slack_hook_url=https://hooks.slack.com/services
app_id=T019PP37ALW
announce_text="Release $target_milestone QA ticket and docker publish\nQA ticket for Release $target_milestone $qa_ticket\nDocker Deploy status $docker_deploy\nList of tickets pulled into release https://github.com/fleetdm/fleet/milestone/$target_milestone_number"
curl -X POST -H 'Content-type: application/json' \
--data "{\"text\":\"$announce_text\"}" \
$slack_hook_url/$app_id/$SLACK_HELP_ENG_TOKEN
} }
update_release_notes() { update_release_notes() {
@ -242,18 +254,15 @@ publish() {
# Slack # Slack
slack_hook_url=https://hooks.slack.com/services slack_hook_url=https://hooks.slack.com/services
app_id=T019PP37ALW app_id=T019PP37ALW
general_channel_id=B06RZ60NUHX/tzaDZOvFCSvS2HC6rECi3Mvu
help_infra_channel_id=B06RLDFLC75/biuacbLxWRsDhv0hLA2qnLbX
help_eng_channel_id=B06RDTMUP1U/x2R36PXvW13KE6daxMiUK6W7
announce_text=":cloud: :rocket: The latest version of Fleet is $target_milestone.\nMore info: https://github.com/fleetdm/fleet/releases/tag/$next_tag\nUpgrade now: https://fleetdm.com/docs/deploying/upgrading-fleet" announce_text=":cloud: :rocket: The latest version of Fleet is $target_milestone.\nMore info: https://github.com/fleetdm/fleet/releases/tag/$next_tag\nUpgrade now: https://fleetdm.com/docs/deploying/upgrading-fleet"
curl -X POST -H 'Content-type: application/json' \ curl -X POST -H 'Content-type: application/json' \
--data "{\"text\":\"$announce_text\"}" \ --data "{\"text\":\"$announce_text\"}" \
$slack_hook_url/$app_id/$general_channel_id $slack_hook_url/$app_id/$SLACK_GENERAL_TOKEN
curl -X POST -H 'Content-type: application/json' \ curl -X POST -H 'Content-type: application/json' \
--data "{\"text\":\"$announce_text\nDogfood Deployed $dogfood_deploy\"}" \ --data "{\"text\":\"$announce_text\nDogfood Deployed $dogfood_deploy\"}" \
$slack_hook_url/$app_id/$help_infra_channel_id $slack_hook_url/$app_id/$SLACK_HELP_INFRA_TOKEN
} }
# Validate we have all commands required to perform this script # Validate we have all commands required to perform this script
@ -271,11 +280,13 @@ target_version=""
print_info=false print_info=false
publish_release=false publish_release=false
release_notes=false release_notes=false
main_release=false
# Parse long options manually # Parse long options manually
for arg in "$@"; do for arg in "$@"; do
shift shift
case "$arg" in case "$arg" in
"--main_release") set -- "$@" "-a" ;;
"--cherry_pick_resolved") set -- "$@" "-c" ;; "--cherry_pick_resolved") set -- "$@" "-c" ;;
"--dry-run") set -- "$@" "-d" ;; "--dry-run") set -- "$@" "-d" ;;
"--force") set -- "$@" "-f" ;; "--force") set -- "$@" "-f" ;;
@ -293,8 +304,9 @@ for arg in "$@"; do
done done
# Extract options and their arguments using getopts # Extract options and their arguments using getopts
while getopts "cdfhmo:prs:t:uv:" opt; do while getopts "acdfhmo:prs:t:uv:" opt; do
case "$opt" in case "$opt" in
a) main_release=true ;;
c) cherry_pick_resolved=true ;; c) cherry_pick_resolved=true ;;
d) dry_run=true ;; d) dry_run=true ;;
f) force=true ;; f) force=true ;;
@ -345,6 +357,19 @@ if [ -z "$open_api_key" ]; then
fi fi
fi fi
if [ -n "$SLACK_GENERAL_TOKEN" ]; then
echo "Error: No SLACK_GENERAL_TOKEN environment variable." >&2
exit 1
fi
if [ -n "$SLACK_HELP_INFRA_TOKEN" ]; then
echo "Error: No SLACK_HELP_INFRA_TOKEN environment variable." >&2
exit 1
fi
if [ -n "$SLACK_HELP_ENG_TOKEN" ]; then
echo "Error: No SLACK_HELP_ENG_TOKEN environment variable." >&2
exit 1
fi
if [[ "$target_date" != "" ]]; then if [[ "$target_date" != "" ]]; then
validate_and_format_date $target_date validate_and_format_date $target_date
fi fi
@ -384,7 +409,13 @@ fi
start_ver_tag=fleet-$start_version start_ver_tag=fleet-$start_version
if [[ "$main_release" == "true" ]]; then
echo "Main release from $start_version to $next_ver"
start_ver_tag=main
else
echo "Patch release from $start_version to $next_ver" echo "Patch release from $start_version to $next_ver"
fi
if [ "$force" = "false" ]; then if [ "$force" = "false" ]; then
read -r -p "If this is correct confirm yes to continue? [y/N] " response read -r -p "If this is correct confirm yes to continue? [y/N] " response
case "$response" in case "$response" in
@ -404,6 +435,10 @@ target_milestone="${next_ver:1}"
target_milestone_number=`gh api repos/:owner/:repo/milestones | jq -r ".[] | select(.title==\"$target_milestone\") | .number"` target_milestone_number=`gh api repos/:owner/:repo/milestones | jq -r ".[] | select(.title==\"$target_milestone\") | .number"`
# patch-fleet-v4.47.3 # patch-fleet-v4.47.3
target_patch_branch="patch-fleet-$next_ver" target_patch_branch="patch-fleet-$next_ver"
if [[ "$main_release" == "true" ]]; then
target_patch_branch="prepare-fleet-$next_ver"
fi
# fleet-v4.47.3 # fleet-v4.47.3
next_tag="fleet-$next_ver" next_tag="fleet-$next_ver"
@ -438,6 +473,7 @@ if [ "$cherry_pick_resolved" = "false" ]; then
# TODO Fail if not found # TODO Fail if not found
if [ "$dry_run" = "false" ]; then if [ "$dry_run" = "false" ]; then
git checkout $start_ver_tag git checkout $start_ver_tag
git pull origin $start_ver_tag
else else
echo "DRYRUN: Would have checked out starting tag $start_ver_tag" echo "DRYRUN: Would have checked out starting tag $start_ver_tag"
fi fi
@ -494,6 +530,7 @@ if [ "$cherry_pick_resolved" = "false" ]; then
commits="" commits=""
if [[ "$main_release" == "false" ]]; then
for pr in ${total_prs[*]}; for pr in ${total_prs[*]};
do do
output=`gh pr view $pr --json state,mergeCommit,baseRefName` output=`gh pr view $pr --json state,mergeCommit,baseRefName`
@ -556,6 +593,7 @@ if [ "$cherry_pick_resolved" = "false" ]; then
fi fi
done done
fi fi
fi
if [[ "$failed" == "false" ]]; then if [[ "$failed" == "false" ]]; then