github.com/noironetworks/cilium-net@v1.6.12/contrib/release/prep-changelog.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 RELEASE_TOOL_PATH="${RELEASE_TOOL_PATH:-$GOPATH/src/github.com/cilium/release}" 10 RELNOTES="$RELEASE_TOOL_PATH/release" 11 RELNOTESCACHE="release-state.json" 12 13 usage() { 14 logecho "usage: $0 <OLD-VERSION> <NEW-VERSION>" 15 logecho "OLD-VERSION Previous release version for comparison" 16 logecho "NEW-VERSION Target release version" 17 logecho 18 logecho "--help Print this help message" 19 } 20 21 handle_args() { 22 if ! common::argc_validate 2; then 23 usage 2>&1 24 common::exit 1 25 fi 26 27 if [[ "$1" = "--help" ]] || [[ "$1" = "-h" ]]; then 28 usage 29 common::exit 0 30 fi 31 32 if ! echo "$1" | grep -q "[0-9]\+\.[0-9]\+\.[0-9]\+"; then 33 usage 2>&1 34 common::exit 1 "Invalid OLD-VERSION ARG \"$1\"; Expected X.Y.Z" 35 fi 36 37 if ! echo "$2" | grep -q "[0-9]\+\.[0-9]\+\.[0-9]\+[-rc0-9]*"; then 38 usage 2>&1 39 common::exit 1 "Invalid NEW-VERSION ARG \"$1\"; Expected X.Y.Z[-rcW]" 40 fi 41 } 42 43 main() { 44 handle_args "$@" 45 46 local old_version="$(echo $1 | sed 's/^v//')" 47 local ersion="$(echo $2 | sed 's/^v//')" 48 local version="v$ersion" 49 50 logecho "Generating CHANGELOG.md" 51 rm -f $RELNOTESCACHE 52 echo -e "# Changelog\n\n## $version" > $version-changes.txt 53 $RELNOTES --base $old_version --head $(git rev-parse HEAD) >> $version-changes.txt 54 cp $version-changes.txt CHANGELOG-new.md 55 if [[ -e CHANGELOG.md ]]; then 56 tail -n+2 CHANGELOG.md >> CHANGELOG-new.md 57 fi 58 mv CHANGELOG-new.md CHANGELOG.md 59 logecho "Generated CHANGELOG.md" 60 } 61 62 main "$@"