githook/post-commit

22 lines
581 B
Bash

#!/bin/sh
# Script to ensure a tag for the current month exists
# Get the current year and month
YEAR_MONTH=$(date +%Y%m)
# Format the tag as v{year}{month}
TAG_NAME="v$YEAR_MONTH"
# Check if the tag already exists
if ! git rev-parse -q --verify "refs/tags/$TAG_NAME" >/dev/null; then
echo "Creating new tag for this month: $TAG_NAME"
# Create the tag
git tag -a "$TAG_NAME" -m "Monthly tag for $TAG_NAME"
# Optionally, you can push the tag to a remote repository
git push origin "$TAG_NAME"
else
echo "Tag for this month already exists: $TAG_NAME"
fi