Skip to content

Instantly share code, notes, and snippets.

@Drowze
Last active June 3, 2017 00:22
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 Drowze/5f8b50485519d43ff51a6a418b3fe383 to your computer and use it in GitHub Desktop.
Save Drowze/5f8b50485519d43ff51a6a418b3fe383 to your computer and use it in GitHub Desktop.
Rake task to create git tag with timestamp and all the merge events since last tag
namespace :git do
desc 'Create a tag with release name and merge events since last tag'
# expects merge events with no-ff, as gitlab does by default
APP_NAME = ''
MERGE_EVENTS_SINCE_LAST_TAG =
`git log \`git describe --tags --abbrev=0\`..HEAD --merges --oneline`
def release_name
"#{APP_NAME}_release-#{Time.now.utc.strftime("%Y%m%d%H%M%S")}"
end
task :create_release do
release_name = "#{release_name}"
puts "Tagging release as '#{release_name}'"
sh "git tag -a #{release_name} -m \"#{MERGE_EVENTS_SINCE_LAST_TAG}\""
sh "git push origin --tags"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment