Skip to content

Instantly share code, notes, and snippets.

@victortrac
Created July 6, 2016 03:38
Show Gist options
  • Save victortrac/d24cd4713fd240fb36783425b4b9c673 to your computer and use it in GitHub Desktop.
Save victortrac/d24cd4713fd240fb36783425b4b9c673 to your computer and use it in GitHub Desktop.
git tag a release with commit messages
#!/bin/bash
# Check out production branch and bring it up to date.
git fetch origin
git checkout production
git reset --hard origin/production
# Create a name for the new tag.
NEW_TAG=$(date +"%Y%m%d-%H%M")
# Grab the last tag.
LAST_TAG=$(git tag | xargs -I@ git log --format=format:"%ai @%n" -1 @ | sort | awk '{print $4}' | tail -n1)
# Tag the release and push it to github.
git tag -a ${NEW_TAG} -m "$(git log --pretty=oneline --no-merges ${LAST_TAG}..${NEW_TAG})"
git push origin ${NEW_TAG}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment