github.com/quay/claircore@v1.5.28/.github/scripts/changelog-update (about)

     1  #!/bin/sh
     2  set -e
     3  while getopts hf: flag; do
     4  	case "$flag" in
     5  		f) prevtag="$OPTARG" ;;
     6  		h|?) printf 'Usage: %s [-f prevtag] [next]\n' "$0" >&2
     7  			printf '  -f prev\tforce previous tag (instead of guessing)\n' >&2
     8  			exit 2 ;;
     9  	esac
    10  done
    11  shift $((OPTIND - 1))
    12  
    13  [ -z "$prevtag" ] && prevtag="$(git tag --sort=-taggerdate --merged | grep '^v' | sed 1q)"
    14  nexttag="${1:-$(echo "$prevtag" | cut -d. -f-2).$(($(echo "$prevtag" | cut -d. -f3)+1))}"
    15  if echo "${nexttag}" | grep -vq '^v[0-9]\+\.[0-9]\+\.[0-9]\+'; then
    16  	printf 'bad tag format: %s\n' "${nexttag}" >&2
    17  	exit 1
    18  fi
    19  : previous tag: "${prevtag}"
    20  : guessed next tag: "${nexttag}"
    21  
    22  work=$(mktemp -d)
    23  trap 'rm -rf "$work"' EXIT
    24  newlog="${work}/CHANGELOG.md"
    25  
    26  "$(git rev-parse --show-toplevel)/.github/scripts/changelog-render" -f "${prevtag}" "${nexttag}" >"${newlog}"
    27  cat "$(git rev-parse --show-toplevel)/CHANGELOG.md" >>"${newlog}"
    28  cp "${newlog}" "$(git rev-parse --show-toplevel)/CHANGELOG.md"