forked from wilson212/bf2stats
-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.sh
executable file
·29 lines (25 loc) · 997 Bytes
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
# This script makes it easy to create a new release.
# It requires git, which is only used to detect the previous tag.
set -eu
TAG=${1:-}
if [ -z "$TAG" ]; then
echo "Please specify a tag as a first argument."
exit 1
fi
TAG_REGEX='^[0-9]+\.[0-9]+\.[0-9]+$'
if ! echo "$TAG" | grep -E "$TAG_REGEX" > /dev/null; then
echo "Tag does not match regex: $TAG_REGEX"
exit 1
fi
TAG_PREV=$( git --no-pager tag -l --sort=-version:refname | head -n1 )
if ! echo "$TAG_PREV" | grep -E "$TAG_REGEX" > /dev/null; then
echo "Previous git tag is invalid. It does not match regex: $TAG_REGEX"
exit 1
fi
TAG_PREV_REGEX=$( echo "$TAG_PREV" | sed 's/\./\\./g' ) # '1.0.0' -> '1\.0\.0'
# Update version in docs, .php, and .sql files
git ls-files | grep -E '(README.md|docker-compose.yml|BF2StatisticsConfig.*\.py|src/ASP/index\.php|src/ASP/bf2statistics\.php)' | while read -r l; do
sed -i "s/$TAG_PREV_REGEX/$TAG/g" "$l"
done
echo "Done bumping version to $TAG in all files."