mirror of
https://github.com/eth-p/bat-extras.git
synced 2024-12-12 09:10:45 +01:00
developer: Add release message generation to release.sh
This commit is contained in:
parent
04912ff8fd
commit
00eafe67d0
83
release.sh
83
release.sh
@ -7,23 +7,30 @@
|
||||
# -----------------------------------------------------------------------------
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DATE="$(date +%Y%m%d)"
|
||||
VERSION="$(<"${HERE}/version.txt")"
|
||||
VERSION_EXPECTED="$(date +%Y.%m.%d)"
|
||||
LIB="$HERE/lib"
|
||||
source "${LIB}/print.sh"
|
||||
source "${LIB}/opt.sh"
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Options.
|
||||
OPT_TAG="v${DATE}"
|
||||
OPT_ARTIFACT="bat-extras-${DATE}.zip"
|
||||
OPT_SKIP_TAG=true
|
||||
OPT_SINCE=
|
||||
OPT_BIN_DIR="$HERE/bin"
|
||||
OPT_DOC_DIR="$HERE/doc"
|
||||
|
||||
while shiftopt; do
|
||||
case "$OPT" in
|
||||
--tag) OPT_SKIP_TAG=false ;;
|
||||
--since)
|
||||
shiftval
|
||||
OPT_SINCE="$OPT_VAL"
|
||||
if ! git rev-parse "$OPT_SINCE" &>/dev/null; then
|
||||
printc "%{RED}%s: unknown commit or tag for '%s'\n" "$PROGRAM" "$OPT"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
printc "%{RED}%s: unknown option '%s'%{CLEAR}" "$PROGRAM" "$OPT"
|
||||
@ -32,6 +39,15 @@ while shiftopt; do
|
||||
esac
|
||||
done
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Verify the version matches today's date.
|
||||
if [[ "$VERSION" != "$VERSION_EXPECTED" ]]; then
|
||||
printc "%{RED}The expected version does not match %{WHITE}version.txt%{RED}!%{CLEAR}\n"
|
||||
printc "%{RED}Expected: %{YELLOW}%s%{CLEAR}\n" "$VERSION_EXPECTED"
|
||||
printc "%{RED}Actual: %{YELLOW}%s%{CLEAR}\n" "$VERSION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build files.
|
||||
|
||||
@ -66,3 +82,62 @@ zip -r "$OPT_ARTIFACT" \
|
||||
"$OPT_DOC_DIR"
|
||||
|
||||
printc "%{YELLOW}Package created as %{BLUE}%s%{YELLOW}.%{CLEAR}\n" "$OPT_ARTIFACT"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Print template description package.
|
||||
|
||||
printc "%{YELLOW}Release description:%{CLEAR}\n"
|
||||
|
||||
# Get the commit hash.
|
||||
COMMIT="$(git rev-parse HEAD)"
|
||||
|
||||
# Get the release date string.
|
||||
DATE_DAY="$(date +%e | sed 's/ //')"
|
||||
DATE_SUFFIX=""
|
||||
case "$DATE_DAY" in
|
||||
11|12|13) DATE_SUFFIX="th" ;;
|
||||
*1) DATE_SUFFIX="st" ;;
|
||||
*2) DATE_SUFFIX="nd" ;;
|
||||
*3) DATE_SUFFIX="rd" ;;
|
||||
*) DATE_SUFFIX="th" ;;
|
||||
esac
|
||||
DATE_STR="$(date +'%B') ${DATE_DAY}${DATE_SUFFIX}, $(date +'%Y')"
|
||||
|
||||
# Get the changelog.
|
||||
CHANGELOG=''
|
||||
if [[ -n "$OPT_SINCE" ]]; then
|
||||
ref="$(git rev-parse HEAD)"
|
||||
end="$(git rev-parse "$OPT_SINCE")"
|
||||
while [[ "$ref" != "$end" ]]; do
|
||||
ref_message="$(git show -s --format=%s "$ref")"
|
||||
ref="$(git rev-parse "${ref}~1")"
|
||||
|
||||
if [[ "$ref_message" =~ ^([a-z]):[[:space:]]*(.*)$ ]]; then
|
||||
ref_message="\`${BASH_REMATCH[1]}\`: ${BASH_REMATCH[2]}"
|
||||
fi
|
||||
|
||||
# Append to changelog.
|
||||
if [[ -z "$CHANGELOG" ]]; then
|
||||
CHANGELOG=" - ${ref_message}"
|
||||
else
|
||||
CHANGELOG="$CHANGELOG"$'\n'" - ${ref_message}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Print the template.
|
||||
sed '/\\$/{N;s/\\\n//;s/\n//p;}' <<-EOF
|
||||
This contains the latest versions of \
|
||||
[\`batgrep\`](https://github.com/eth-p/bat-extras/blob/${COMMIT}/doc/batgrep.md), \
|
||||
[\`batman\`](https://github.com/eth-p/bat-extras/blob/${COMMIT}/doc/batman.md), \
|
||||
[\`batwatch\`](https://github.com/eth-p/bat-extras/blob/${COMMIT}/doc/batwatch.md), and \
|
||||
[\`prettybat\`](https://github.com/eth-p/bat-extras/blob/${COMMIT}/doc/prettybat.md) \
|
||||
as of commit $(git rev-parse --short HEAD) (${DATE_STR}).
|
||||
|
||||
**This is provided as a convenience only.**
|
||||
I would still recommend following the installation instructions in \
|
||||
[the README](https://github.com/eth-p/bat-extras#installation-) for the most up-to-date versions.
|
||||
|
||||
### Changes
|
||||
$CHANGELOG
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue
Block a user