icinga-php-thirdparty/bin/make-release.sh

66 lines
1.5 KiB
Bash
Raw Normal View History

2017-10-27 14:41:48 +02:00
#!/bin/bash
VERSION="$1"
NO_OPT="$2"
2017-10-27 14:41:48 +02:00
if [[ -z $VERSION ]]; then
echo "USAGE: $0 <version> [--no-tag|--no-checkout]"
2017-10-27 14:41:48 +02:00
echo " e.g.: $0 0.1.0"
exit 1
fi
2019-05-16 17:35:34 +02:00
function fail {
local msg="$1"
echo "ERROR: $msg"
exit 1
}
2017-10-27 14:41:48 +02:00
TAG=$(git tag | grep -c "$VERSION")
if [[ "$TAG" -ne "0" ]]; then
2017-10-27 14:41:48 +02:00
echo -n "Version $VERSION has already been tagged: "
git tag | grep "$VERSION"
exit 1
fi
if [ "$NO_OPT" != "--no-checkout" ]; then
BRANCH="stable/$VERSION"
git checkout -b "$BRANCH" || fail "Version branch $BRANCH already exists"
else
BRANCH=$(git rev-parse --abbrev-ref HEAD)
fi
2017-10-27 14:41:48 +02:00
git rm -rf vendor
rm -rf vendor
2019-05-16 17:35:34 +02:00
rm -f composer.lock
composer install || fail "composer install failed"
2017-10-27 14:41:48 +02:00
find vendor/ -type f -name "*.php" \
| grep -v '/examples/' \
| grep -v '/example/' \
| grep -v '/tests/' \
| grep -v '/test/' \
2019-05-16 17:35:34 +02:00
| xargs -L1 git add -f
find vendor/ -type f -name LICENSE | xargs -L1 git add -f
find vendor/ -type f -name '*.json' | xargs -L1 git add -f
find asset/ -type f | xargs -L1 git add -f
2021-05-28 11:02:26 +02:00
echo "v$VERSION" > VERSION
git add VERSION
git add composer.lock -f
2017-10-27 14:41:48 +02:00
git commit -m "Version v$VERSION"
rm -rf vendor
git checkout vendor
2019-05-16 17:35:34 +02:00
composer validate --no-check-all --strict || fail "Composer validate failed"
2017-10-27 14:41:48 +02:00
if [ -z "$NO_OPT" ]; then
git tag -a v$VERSION -m "Version v$VERSION"
echo "Finished, tagged v$VERSION"
echo "Now please run:"
else
echo "Finished, but not tagged yet"
echo "Now please run:"
echo "git tag -s v$VERSION -m \"Version v$VERSION\""
fi
2017-10-27 14:41:48 +02:00
echo "git push origin "$BRANCH":"$BRANCH" && git push --tags"