Skip to content

Commit

Permalink
Generate notes and command line parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuderman committed Feb 23, 2024
1 parent 54d93c8 commit ba4a0e9
Showing 1 changed file with 62 additions and 6 deletions.
68 changes: 62 additions & 6 deletions scripts/tag-and-release.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,67 @@
#!/usr/bin/env bash

# Date since the last release. We will search for commits newer than this.
# TODO There is probably some Git magic we could do to figure this out
SINCE=${SINCE:-2023-08-19}
# Determine our name for use in the help message.
SCRIPT=$(basename $(realpath $0))

# ANSI color codes for the console.
reset="\033[0m"
bold="\033[1m"
ital="\033[3m" # does not work on OS X

# Function used to highlight text.
function hi() {
echo -e "$bold$@$reset"
}

# The last version that was tagged.
# TODO There is probably some Git magic we could do to figure this out
LATEST=${LATEST:-5.7.6}
LATEST=$(git describe --tags `git rev-list --tags --max-count=1` | tr -d 'v')

# Date since the last release. We will search for commits newer than this.
SINCE=$(git log -1 --format=%as v$LATEST)

function help() {
less -RX << EOF
$(hi NAME)
$SCRIPT
$(hi DESCRIPTION)
Tags and generates a GitHub release for all commits that have "Automatic" in the
commit messages. These will be the commits that were generated by the packaging
GitHub action.
$(hi SYNOPSIS)
$SCRIPT --size DATE --latest TAG_NAME
$(hi OPTIONS)
-l|--latest the tag name of the last commit that was tagged. Default to $LATEST
-s|--since search the git log after this date (YYYY-MM-DD). Defaults to $SINCE
-h|--help prints this help message and exits
The $(hi --latest) and $(hi --since) fields will be determined from the Git log
if they are not provided.
EOF
}

while [[ $# > 0 ]] ; do
case $1 in
-l|--latest)
LATEST=$2
shift
;;
-s|--since)
SINCE=$2
shift
;;
-h|--help|help)
help
exit
;;
esac
shift
done
PREVIOUS="v$LATEST"

# Search the git log for commits that did an Automatic version bump.
git log --oneline --grep=Automatic --since=$SINCE | awk '{print $1,$NF}' | grep -v $LATEST | tail -r | while read -r line ; do
Expand All @@ -20,7 +75,8 @@ git log --oneline --grep=Automatic --since=$SINCE | awk '{print $1,$NF}' | grep
git tag -a -m "Automatic tagging of $tag" $tag
git push origin $tag
# Generate the release.
gh release create $tag --generate-notes --latest
gh release create $tag --generate-notes --latest --notes-start-tag $PREVIOUS
PREVIOUS=$tag
done
git checkout master
echo "Done."

0 comments on commit ba4a0e9

Please sign in to comment.