github.com/argoproj/argo-cd/v2@v2.10.9/hack/generate-release-notes.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ]; then
     4  cat <<-EOM
     5  USAGE:
     6  
     7    generate-release-notes.sh NEW_REF OLD_REF NEW_VERSION
     8  
     9  EXAMPLES:
    10  
    11    # For releasing a new minor version:
    12    generate-release-notes.sh release-2.5 release-2.4 v2.5.0-rc1 > /tmp/release.md
    13  
    14    # For a patch release:
    15    generate-release-notes.sh release-2.4 v2.4.13 v2.4.14 > /tmp/release.md
    16  EOM
    17  exit 1
    18  fi
    19  
    20  function to_list_items() {
    21    sed 's/^/- /'
    22  }
    23  
    24  function strip_last_word() {
    25    sed 's/ [^ ]*$//'
    26  }
    27  
    28  function nonempty_line_count() {
    29    sed '/^\s*$/d' | wc -l | tr -d ' \n'
    30  }
    31  
    32  function only_last_word() {
    33    awk 'NF>1{print $NF}'
    34  }
    35  
    36  new_ref=$1
    37  old_ref=$2
    38  version=$3
    39  
    40  cat <<-EOM
    41  ## Quick Start
    42  
    43  ### Non-HA:
    44  
    45  \`\`\`shell
    46  kubectl create namespace argocd
    47  kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/$version/manifests/install.yaml
    48  \`\`\`
    49  
    50  ### HA:
    51  
    52  \`\`\`shell
    53  kubectl create namespace argocd
    54  kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/$version/manifests/ha/install.yaml
    55  \`\`\`
    56  
    57  ## Release signatures
    58  
    59  All Argo CD container images and CLI binaries are signed by cosign. See the [documentation](https://argo-cd.readthedocs.io/en/stable/operator-manual/signed-release-assets/) on how to verify the signatures.
    60  \`\`\`shell
    61  -----BEGIN PUBLIC KEY-----
    62  MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEesHEB7vX5Y2RxXypjMy1nI1z7iRG
    63  JI9/gt/sYqzpsa65aaNP4npM43DDxoIy/MQBo9s/mxGxmA+8UXeDpVC9vw==
    64  -----END PUBLIC KEY-----
    65  \`\`\`
    66  
    67  ## Upgrading
    68  
    69  If upgrading from a different minor version, be sure to read the [upgrading](https://argo-cd.readthedocs.io/en/stable/operator-manual/upgrading/overview/) documentation.
    70  
    71  EOM
    72  
    73  # Adapted from https://stackoverflow.com/a/67029088/684776
    74  less_log=$(git log --pretty="format:%s %ae" --cherry-pick --left-only --no-merges "$new_ref...$old_ref")
    75  more_log=$(git log --pretty="format:%s %ae" "$new_ref..$old_ref")
    76  
    77  new_commits=$(diff --new-line-format="" --unchanged-line-format="" <(echo "$less_log") <(echo "$more_log") | grep -v "Merge pull request from GHSA")
    78  new_commits_no_email=$(echo "$new_commits" | strip_last_word)
    79  features=$(echo "$new_commits_no_email" | grep '^feat' | to_list_items)
    80  fixes=$(echo "$new_commits_no_email" | grep '^fix' | to_list_items)
    81  docs=$(echo "$new_commits_no_email" | grep '^docs' | to_list_items)
    82  other=$(echo "$new_commits_no_email" | grep -v -e '^feat' -e '^fix' -e '^docs' -e '^\[Bot\]' | to_list_items)
    83  
    84  contributors_num=$(echo "$new_commits" | only_last_word | sort -u | nonempty_line_count)
    85  
    86  new_commits_num=$(echo "$new_commits" | nonempty_line_count)
    87  features_num=$(echo "$features" | nonempty_line_count)
    88  fixes_num=$(echo "$fixes" | nonempty_line_count)
    89  docs_num=$(echo "$docs" | nonempty_line_count)
    90  other_num=$(echo "$other" | nonempty_line_count)
    91  
    92  previous_contributors=$(git log --pretty="format:%an %ae" "$old_ref" | sort -uf)
    93  all_contributors=$(git log --pretty="format:%an %ae" "$new_ref" | sort -uf)
    94  new_contributors=$(diff --new-line-format="" --unchanged-line-format="" <(echo "$all_contributors") <(echo "$previous_contributors"))
    95  new_contributors_num=$(echo "$new_contributors" | only_last_word | nonempty_line_count)  # Count contributors by email
    96  new_contributors_names=$(echo "$new_contributors" | strip_last_word | to_list_items)
    97  
    98  new_contributors_message=""
    99  if [ "$new_contributors_num" -gt 0 ]; then
   100    new_contributors_message=" ($new_contributors_num of them new)"
   101  fi
   102  
   103  echo "## Changes"
   104  echo
   105  echo "This release includes $new_commits_num contributions from $contributors_num contributors$new_contributors_message with $features_num features and $fixes_num bug fixes."
   106  echo
   107  if [ "$new_contributors_num" -lt 20 ] && [ "$new_contributors_num" -gt 0 ]; then
   108    echo "A special thanks goes to the $new_contributors_num new contributors:"
   109    echo "$new_contributors_names"
   110    echo
   111  fi
   112  if [ "$features_num" -gt 0 ]; then
   113    echo "### Features ($features_num)"
   114    echo
   115    echo "$features"
   116    echo
   117  fi
   118  if [ "$fixes_num" -gt 0 ]; then
   119    echo "### Bug fixes ($fixes_num)"
   120    echo
   121    echo "$fixes"
   122    echo
   123  fi
   124  if [ "$docs_num" -gt 0 ]; then
   125    echo "### Documentation ($docs_num)"
   126    echo
   127    echo "$docs"
   128    echo
   129  fi
   130  if [ "$other_num" -gt 0 ]; then
   131    echo "### Other ($other_num)"
   132    echo
   133    echo "$other"
   134    echo
   135  fi