github.com/abdfnx/gh-api@v0.0.0-20210414084727-f5432eec23b8/script/changelog (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  current_tag="${GITHUB_REF#refs/tags/}"
     5  start_ref="HEAD"
     6  
     7  # Find the previous release on the same branch, skipping prereleases if the
     8  # current tag is a full release
     9  previous_tag=""
    10  while [[ -z $previous_tag || ( $previous_tag == *-* && $current_tag != *-* ) ]]; do
    11    previous_tag="$(git describe --tags "$start_ref"^ --abbrev=0)"
    12    start_ref="$previous_tag"
    13  done
    14  
    15  git log "$previous_tag".. --reverse --merges --oneline --grep='Merge pull request #' | \
    16    while read -r sha title; do
    17      pr_num="$(grep -o '#[[:digit:]]\+' <<<"$title")"
    18      pr_desc="$(git show -s --format=%b "$sha" | sed -n '1,/^$/p' | tr $'\n' ' ')"
    19      printf "* %s %s\n\n" "$pr_desc" "$pr_num"
    20    done