Skip to content

Commit

Permalink
Add release dev script
Browse files Browse the repository at this point in the history
  • Loading branch information
ikolesn committed Jan 26, 2024
1 parent 0828360 commit e08e15e
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions dev-bin/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -eu -o pipefail

changelog=$(cat CHANGELOG.md)

regex='
## v([0-9]+\.[0-9]+\.[0-9]+) \(([0-9]{4}-[0-9]{2}-[0-9]{2})\)
((.|
)*)
'

if [[ ! $changelog =~ $regex ]]; then
echo "Could not find date line in change log!"
exit 1
fi

version="${BASH_REMATCH[1]}"
date="${BASH_REMATCH[2]}"
notes="$(echo "${BASH_REMATCH[3]}" | sed -n -E '/^## v[0-9]+\.[0-9]+\.[0-9]+/,$!p')"

echo "$notes"
if [[ "$date" != "$(date +"%Y-%m-%d")" ]]; then
echo "$date is not today!"
exit 1
fi

tag="v$version"

if [ -n "$(git status --porcelain)" ]; then
echo ". is not clean." >&2
exit 1
fi

echo $"go mod tidy:"

go mod tidy

echo $"Test results:"

go test -race -v ./...

echo $'\nDiff:'
git diff

echo $'\nRelease notes:'
echo "$notes"

read -e -p "Push to origin? " should_push

if [ "$should_push" != "y" ]; then
echo "Aborting"
exit 1
fi

git push

gh release create --target "$(git branch --show-current)" -t "$version" -n "$notes" "$tag"

0 comments on commit e08e15e

Please sign in to comment.