Skip to content

Commit

Permalink
Enhancement (ci): Add release.sh to create releases
Browse files Browse the repository at this point in the history
  • Loading branch information
leojonathanoh committed Nov 22, 2023
1 parent e6f9f31 commit c926c96
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,9 @@ docker volume rm bf2stats_db-volume
## Release

```sh
# Bump version across docs and source code
MOST_RECENT_TAG_REGEX=$( git --no-pager tag -l --sort=-version:refname | head -n1 | sed 's@\.@\\.@g' )
TAG=2.5.1
git ls-files | grep -E '(^docker-compose.yml|^README.md|^docs/|index.php|bf2statistics.php|BF2StatisticsConfig.py)' | while read -r l; do sed -i "s/\b$MOST_RECENT_TAG_REGEX\b/$TAG/g" "$l"; done
git checkout -b "chore/bump-version-to-$TAG"
./release.sh "2.x.x"
git add .
git commit -m "Chore: Bump version to \`$TAG\`"
git commit -m "Chore: Release 2.x.x"
```

## FAQ
Expand Down
28 changes: 28 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/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

# Update version in docs, .php, and .sql files
git ls-files | grep -E '(^docker-compose.yml|^README.md|^docs/|index.php|bf2statistics.php|BF2StatisticsConfig.py)' | while read -r l; do
sed -i "s/$TAG_PREV/$TAG/g" "$l"
done

echo "Done bumping version to $TAG in all files. The release comment has been added in src/ASP/system/sql/migrations/migrations.php"

0 comments on commit c926c96

Please sign in to comment.