mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2024-12-27 23:38:07 +01:00
31 lines
765 B
Bash
31 lines
765 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
set -e
|
||
|
|
||
|
usage() {
|
||
|
echo "$0 <tag> <repo>" >&2;
|
||
|
}
|
||
|
|
||
|
if [ "$1" = "-h" -o "$1" = "--help" ]; then
|
||
|
usage
|
||
|
exit 1;
|
||
|
fi
|
||
|
|
||
|
if [ -z "$2" ]
|
||
|
then
|
||
|
REPO=$(git ls-remote --get-url origin | \
|
||
|
sed -u 's/git@//g; s/https:\/\///g; s/github.com\///g; s/\.git//g')
|
||
|
else
|
||
|
REPO=$2
|
||
|
fi
|
||
|
|
||
|
NEW_TAG=$1
|
||
|
CURRENT_DATE=$(date +"%Y-%m-%d")
|
||
|
|
||
|
LAST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
|
||
|
LAST_DATE=$(git log -1 --format=%ai $LAST_TAG)
|
||
|
|
||
|
CHANGES=$(curl -s "https://api.github.com/repos/${REPO}/pulls?state=closed" | \
|
||
|
jq --arg l "$LAST_DATE" -r '.[] | select((.merged_at != null) and (.closed_at > $l)) | "- [Pull #\(.number)](\(.html_url)): \(.title)"')
|
||
|
|
||
|
sed -i "4i ## [$NEW_TAG] - $CURRENT_DATE\n### Added\n${CHANGES//$'\n'/\\$'\n'}\n" CHANGELOG.md
|