Skip to content
Permalink
Browse files

Validate if release is well prepared

  • Loading branch information...
dahlia committed Feb 26, 2019
1 parent 52bf74a commit 8ea3b257aa918deb83d33fe8fb35c4a0f2127a89
Showing with 69 additions and 0 deletions.
  1. +10 −0 hooks/commit-msg
  2. 0 hooks/pre-commit
  3. +59 −0 hooks/validate-release
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

version_regex='[Rr]elease ([0-9]+\.[0-9]+\.[0-9]+)'
if [[ "$(head -n1 "$1")" =~ $version_regex ]]; then
version="${BASH_REMATCH[1]}"
"$(dirname "$0")/validate-release" "$version"
fi

# vim: set filetype=sh ts=2 sw=2 et:
0 hooks/pre-commit 100644 → 100755
No changes.
@@ -0,0 +1,59 @@
#!/bin/bash
set -e

root="$(dirname "$0")/.."
if command -v realpath > /dev/null; then
root="$(realpath "$root")"
fi

if [[ "$#" -lt "1" ]]; then
{
echo "$0: error: missing version number"
echo "usage: $0 VERSION"
} > /dev/stderr
exit 1
fi

version="$1"

if [[ "$version" = *-dev ]]; then
{
echo "$0: error: the version number must not end with -dev suffix:"
echo " $version"
} > /dev/stderr
exit 1
fi

csproj="$root/Libplanet/Libplanet.csproj"
if command -v xmllint > /dev/null; then
csproj_version="$(xmllint \
--xpath './Project/PropertyGroup/Version/text()' \
"$csproj")"
else
version_regex='<Version>([0-9]+\.[0-9]+\.[0-9]+)</Version>'
if [[ "$(grep '<Version>[^>]*</Version>' "$csproj")" =~ $version_regex ]]
then
csproj_version="${BASH_REMATCH[1]}"
else
echo "$0: error: failed to find <Version> tag from $csproj file" \
> /dev/stderr
exit 1
fi
fi

if [[ "$csproj_version" != "$version" ]]; then
{
echo "$0: error: the version numbers must match"
echo " $version (tag)"
echo " $csproj_version ($csproj)"
} > /dev/stderr
exit 1
fi

if grep -i 'to be released' "$root/CHANGES.md" > /dev/stderr; then
echo "$0: error: $root/CHANGES.md file must not contain unreleased notes." \
> /dev/stderr
exit 1
fi

# vim: set filetype=sh ts=2 sw=2 et:

0 comments on commit 8ea3b25

Please sign in to comment.
You can’t perform that action at this time.