mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 00:45:19 +00:00
Adding theoretical main variation (#17904)
This commit is contained in:
parent
8a22f13f53
commit
011d97fad1
@ -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
|
||||||
|
|
||||||
echo "Patch release from $start_version to $next_ver"
|
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"
|
||||||
|
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,67 +530,69 @@ if [ "$cherry_pick_resolved" = "false" ]; then
|
|||||||
|
|
||||||
commits=""
|
commits=""
|
||||||
|
|
||||||
for pr in ${total_prs[*]};
|
if [[ "$main_release" == "false" ]]; then
|
||||||
do
|
for pr in ${total_prs[*]};
|
||||||
output=`gh pr view $pr --json state,mergeCommit,baseRefName`
|
do
|
||||||
state=`echo $output | jq -r .state`
|
output=`gh pr view $pr --json state,mergeCommit,baseRefName`
|
||||||
commit=`echo $output | jq -r .mergeCommit.oid`
|
state=`echo $output | jq -r .state`
|
||||||
target_branch=`echo $output | jq -r .baseRefName`
|
commit=`echo $output | jq -r .mergeCommit.oid`
|
||||||
echo -n "$pr $state $commit $target_branch:"
|
target_branch=`echo $output | jq -r .baseRefName`
|
||||||
if [[ "$state" != "MERGED" || "$target_branch" != "main" ]]; then
|
echo -n "$pr $state $commit $target_branch:"
|
||||||
echo " WARNING - Skipping pr https://github.com/fleetdm/fleet/pull/$pr"
|
if [[ "$state" != "MERGED" || "$target_branch" != "main" ]]; then
|
||||||
else
|
echo " WARNING - Skipping pr https://github.com/fleetdm/fleet/pull/$pr"
|
||||||
if [[ "$commit" != "" && "$commit" != "null" ]]; then
|
|
||||||
echo " Commit looks valid - $commit, adding to cherry-pick"
|
|
||||||
commits+="$commit "
|
|
||||||
else
|
else
|
||||||
echo " WARNING - invalid commit for pr https://github.com/fleetdm/fleet/pull/$pr - $commit"
|
if [[ "$commit" != "" && "$commit" != "null" ]]; then
|
||||||
|
echo " Commit looks valid - $commit, adding to cherry-pick"
|
||||||
|
commits+="$commit "
|
||||||
|
else
|
||||||
|
echo " WARNING - invalid commit for pr https://github.com/fleetdm/fleet/pull/$pr - $commit"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
#echo "======================================="
|
||||||
#echo "======================================="
|
done
|
||||||
done
|
|
||||||
|
|
||||||
for commit in $commits;
|
for commit in $commits;
|
||||||
do
|
do
|
||||||
# echo $commit
|
# echo $commit
|
||||||
timestamp=`git log -n 1 --pretty=format:%at $commit`
|
timestamp=`git log -n 1 --pretty=format:%at $commit`
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed to identify $commit, exiting"
|
echo "Failed to identify $commit, exiting"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# echo $timestamp
|
# echo $timestamp
|
||||||
time_map[$timestamp]=$commit
|
time_map[$timestamp]=$commit
|
||||||
done
|
done
|
||||||
|
|
||||||
timestamps=""
|
timestamps=""
|
||||||
for key in "${!time_map[@]}"; do
|
for key in "${!time_map[@]}"; do
|
||||||
timestamps+="$key\n"
|
timestamps+="$key\n"
|
||||||
done
|
done
|
||||||
for ts in `echo -e $timestamps | sort`; do
|
for ts in `echo -e $timestamps | sort`; do
|
||||||
commit_hash="${time_map[$ts]}"
|
commit_hash="${time_map[$ts]}"
|
||||||
# echo "# $ts $commit_hash"
|
# echo "# $ts $commit_hash"
|
||||||
if git branch --contains "$commit_hash" | $GREP_CMD -q "$(git rev-parse --abbrev-ref HEAD)"; then
|
if git branch --contains "$commit_hash" | $GREP_CMD -q "$(git rev-parse --abbrev-ref HEAD)"; then
|
||||||
echo "# Commit $commit_hash is on the current branch."
|
echo "# Commit $commit_hash is on the current branch."
|
||||||
is_on_current_branch=true
|
is_on_current_branch=true
|
||||||
else
|
else
|
||||||
# echo "# Commit $commit_hash is not on the current branch."
|
# echo "# Commit $commit_hash is not on the current branch."
|
||||||
if [[ "$failed" == "false" ]]; then
|
if [[ "$failed" == "false" ]]; then
|
||||||
|
|
||||||
if [ "$dry_run" = "false" ]; then
|
if [ "$dry_run" = "false" ]; then
|
||||||
git cherry-pick $commit_hash
|
git cherry-pick $commit_hash
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Cherry pick of $commit_hash failed. Please resolve then continue the cherry-picks manually"
|
echo "Cherry pick of $commit_hash failed. Please resolve then continue the cherry-picks manually"
|
||||||
failed=true
|
failed=true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "DRYRUN: Would have cherry picked $commit_hash"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "DRYRUN: Would have cherry picked $commit_hash"
|
echo "git cherry-pick $commit_hash"
|
||||||
fi
|
fi
|
||||||
else
|
is_on_current_branch=false
|
||||||
echo "git cherry-pick $commit_hash"
|
|
||||||
fi
|
fi
|
||||||
is_on_current_branch=false
|
done
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$failed" == "false" ]]; then
|
if [[ "$failed" == "false" ]]; then
|
Loading…
Reference in New Issue
Block a user