github.com/noironetworks/cilium-net@v1.6.12/contrib/release/submit-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 BRANCH="${1:-""}" 10 if [ "$BRANCH" = "" ]; then 11 BRANCH=$(git symbolic-ref --short HEAD | sed 's/.*\(v[0-9]\.[0-9]\).*/\1/') 12 fi 13 BRANCH=$(echo "$BRANCH" | sed 's/^v//') 14 15 RELEASE="v$(cat VERSION)" 16 SUMMARY=${2:-} 17 GENERATE_SUMMARY=false 18 if [ "$SUMMARY" = "" ]; then 19 SUMMARY="$RELEASE-changes.txt" 20 GENERATE_SUMMARY=true 21 fi 22 23 if ! git branch -a | grep -q "origin/v$BRANCH$" || [ ! -e $SUMMARY ]; then 24 echo "usage: $0 [branch version] [release-summary]" 1>&2 25 echo 1>&2 26 echo "Ensure 'branch version' is available in 'origin' and the summary file exists" 1>&2 27 exit 1 28 fi 29 30 if ! hub help | grep -q "pull-request"; then 31 echo "This tool relies on 'hub' from https://github.com/github/hub." 1>&2 32 echo "Please install this tool first." 1>&2 33 exit 1 34 fi 35 36 if ! git diff --quiet; then 37 echo "Local changes found in git tree. Exiting release process..." 1>&2 38 exit 1 39 fi 40 41 if ! git log --oneline | grep -q $RELEASE; then 42 echo "Latest commit does not match commit title for release:" 1>&2 43 git log -1 44 exit 1 45 fi 46 47 if $GENERATE_SUMMARY; then 48 CHANGELOG=$SUMMARY 49 SUMMARY="$RELEASE-pr-$(date --rfc-3339=date).txt" 50 echo "Prepare for release $RELEASE" > $SUMMARY 51 tail -n+4 $CHANGELOG >> $SUMMARY 52 fi 53 54 echo -e "Sending PR for branch v$BRANCH:\n" 1>&2 55 cat $SUMMARY 1>&2 56 echo -e "\nSending pull request..." 2>&1 57 PR_BRANCH=$(git rev-parse --abbrev-ref HEAD) 58 git push origin "$PR_BRANCH" 59 hub pull-request -b "v$BRANCH" -l kind/release,backport/$BRANCH -F $SUMMARY