Created
August 1, 2022 09:33
-
-
Save ppabcd/47873024eebc20f26b6df05b16c7892e to your computer and use it in GitHub Desktop.
pre-commit without php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Version and Release Manager | |
VERSION_FILE="${PWD}/.version" | |
RELEASE="${PWD}/release" | |
VERSION="0.1.0" | |
TEXT_VERSION="v0.1.0" | |
if [ -f "$VERSION_FILE" ]; then | |
# Read file | |
VERSION=$(cat "$VERSION_FILE") | |
# delete v from text | |
VERSION=${VERSION#v} | |
# increment version | |
VERSION=$(echo "$VERSION" | awk -F. '{$NF+=1; print}') | |
# replace space to . | |
VERSION=$(echo "$VERSION" | sed 's/ /./g') | |
# write version to file | |
TEXT_VERSION="v$VERSION" | |
echo "${TEXT_VERSION}" >"$VERSION_FILE" | |
echo "Version: $TEXT_VERSION" | |
else | |
echo "Version file does not exist. Generate v0.1.0" | |
echo "v0.1.0" >"$VERSION_FILE" | |
fi | |
git add "$VERSION_FILE" | |
if [ -f "$RELEASE" ]; then | |
echo "Release file exists. Delete it." | |
git tag -a "${TEXT_VERSION}" -m "Release $TEXT_VERSION" | |
git push origin "${TEXT_VERSION}" | |
rm "$RELEASE" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment