@@ -31,6 +31,23 @@ def current_version
3131 content . match ( /VERSION = "(.+)"/ ) [ 1 ]
3232end
3333
34+ def extract_changelog_for_version ( version )
35+ changelog = File . read ( "CHANGELOG.md" )
36+
37+ # Find the section for this version
38+ version_pattern = /^## \[ #{ Regexp . escape ( version ) } \] [^\n ]*\n (.*?)(?=^## \[ |\z )/m
39+ match = changelog . match ( version_pattern )
40+
41+ if match
42+ # Clean up the changelog entries
43+ entries = match [ 1 ] . strip
44+ # Remove empty lines at the start and end
45+ entries . gsub ( /\A \s *\n +/ , '' ) . gsub ( /\n +\s *\z / , '' )
46+ else
47+ "No changelog entries found for version #{ version } "
48+ end
49+ end
50+
3451def bump_version ( version_type )
3552 unless %w[ major minor patch ] . include? ( version_type )
3653 puts "Invalid version type. Use: major, minor, or patch"
@@ -93,9 +110,16 @@ def create_git_tag
93110 system ( "git tag -d v#{ version } " )
94111 end
95112
96- system ( "git tag v#{ version } " )
113+ # Extract changelog entries for this version
114+ changelog_entries = extract_changelog_for_version ( version )
115+
116+ # Create tag message with version and changelog
117+ tag_message = "Release #{ version } \n \n #{ changelog_entries } "
118+
119+ # Create annotated tag with the changelog
120+ system ( "git" , "tag" , "-a" , "v#{ version } " , "-m" , tag_message )
97121
98- puts "Created git tag v#{ version } "
122+ puts "Created git tag v#{ version } with changelog entries "
99123end
100124
101125def push_gem_to_rubygems
0 commit comments