github.com/noironetworks/cilium-net@v1.6.12/contrib/release/tag-release.sh (about)

     1  #!/bin/bash
     2  # SPDX-License-Identifier: Apache-2.0
     3  # Copyright 2020 Authors of Cilium
     4  
     5  DIR=$(dirname $(readlink -ne $BASH_SOURCE))
     6  source $DIR/lib/common.sh
     7  source $DIR/../backporting/common.sh
     8  
     9  REMOTE="$(get_remote)"
    10  CHARTS_PATH="${CHARTS_PATH:-$GOPATH/src/github.com/cilium/charts}"
    11  CHARTS_TOOL="prepare_artifacts.sh"
    12  RELEASES_URL="https://github.com/cilium/cilium/releases"
    13  VERSION=""
    14  
    15  usage() {
    16      echo "usage: $0 [VERSION]"
    17      echo "CHARTS_REPO Path to local copy of github.com/cilium/charts"
    18      echo
    19      echo "--help     Print this help message"
    20  }
    21  
    22  handle_args() {
    23      if [[ "$1" = "--help" ]] || [[ "$1" = "-h" ]]; then
    24          usage
    25          common::exit 1
    26      fi
    27  
    28      if [[ ! -e VERSION ]]; then
    29          common::exit 1 "VERSION file not found. Is this directory a Cilium repository?"
    30      fi
    31  
    32      if [[ ! -e "$CHARTS_PATH/$CHARTS_TOOL" ]]; then
    33          usage
    34          common::exit 1 "CHARTS_PATH='$CHARTS_PATH' invalid. Clone from github.com/cilium/charts"
    35      fi
    36  
    37      if ! which hub >/dev/null; then
    38          echo "This tool relies on 'hub' from https://github.com/github/hub ." 1>&2
    39          common::exit 1 "Please install this tool first."
    40      fi
    41  
    42      if [[ $# -ge 1 ]]; then
    43          VERSION="$1"
    44      fi
    45  }
    46  
    47  main() {
    48      handle_args "$@"
    49  
    50      local ersion="$(cat VERSION)"
    51      if [[ "$VERSION" != "" ]]; then
    52          ersion="$(echo $VERSION | sed 's/^v//')"
    53      fi
    54      local version="v$ersion"
    55  
    56      if [[ ! -e $version-changes.txt ]]; then
    57          common::exit 1 "Generate release notes via contrib/release/start-release.sh"
    58      fi
    59  
    60      echo "Current HEAD is:"
    61      git log --oneline -1 $(git rev-parse HEAD)
    62      echo "Create git tags for $version with this commit"
    63      if ! common::askyorn ; then
    64          common::exit 0 "Aborting release preparation."
    65      fi
    66  
    67      logrun -s git tag -a $ersion -s -m "Release $version"
    68      logrun -s git tag -a $version -s -m "Release $version"
    69      logrun -s git push $REMOTE $version $ersion
    70  
    71      # Leave $version-changes.txt around so we can generate release notes later
    72      echo -e "$ersion\n" > $version-release-summary.txt
    73      echo "We are pleased to release Cilium $version." >>  $version-release-summary.txt
    74      tail -n+4 $version-changes.txt >> $version-release-summary.txt
    75      logecho "Creating Github draft release"
    76      logrun hub release create -d -F $version-release-summary.txt $version
    77      logecho "Browse to $RELEASES_URL to see the draft release"
    78  
    79      logecho
    80      logecho "Next steps:"
    81      logecho "* Wait for cilium docker images to be prepared"
    82      logecho "* Prepare the helm template changes"
    83      logecho "* When docker images are available, test deployment of new version"
    84      logecho "* Push templates and announce release on GitHub / Slack"
    85  }
    86  
    87  main "$@"