Last active
October 26, 2021 07:48
-
-
Save mskarbek/aa7ac1273d924d4b2049c74801e95f62 to your computer and use it in GitHub Desktop.
repo tagging
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
#!/usr/bin/env bash | |
LAST_TAG=$(git tag --list v*|sort|tail -n 1) | |
if [[ -z ${LAST_TAG} ]]; then | |
TAG=$(date +%y.%m.1) | |
else | |
LAST_TAG_YEAR=$(echo ${LAST_TAG}|awk -F. '{print $1}') | |
LAST_TAG_MONTH=$(echo ${LAST_TAG}|awk -F. '{print $2}') | |
LAST_TAG_BUILD=$(echo ${LAST_TAG}|awk -F. '{print $3}') | |
if [[ $(date +v%y) != ${LAST_TAG_YEAR} ]]; then | |
TAG=$(date +%y.%m.1) | |
else | |
if [[ $(date +%m) != ${LAST_TAG_MONTH} ]]; then | |
TAG=$(date +%y.%m.1) | |
else | |
TAG_BUILD=$((LAST_TAG_BUILD+1)) | |
TAG=$(date +%y.%m.${TAG_BUILD}) | |
fi | |
fi | |
fi | |
echo ${TAG} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment