Skip to content

Instantly share code, notes, and snippets.

@mskarbek
Last active October 26, 2021 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mskarbek/aa7ac1273d924d4b2049c74801e95f62 to your computer and use it in GitHub Desktop.
Save mskarbek/aa7ac1273d924d4b2049c74801e95f62 to your computer and use it in GitHub Desktop.
repo tagging
#!/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