Last active
June 3, 2017 00:22
-
-
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
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
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