@@ -65,19 +65,18 @@ namespace :unified_release do
65
65
DESC
66
66
task :bump , :version do |_ , args |
67
67
abort ( '[!] Required argument [version] missing' ) unless ( version = args [ :version ] )
68
-
69
- files = [ 'elasticsearch/elasticsearch.gemspec' ]
70
- RELEASE_TOGETHER . each do |gem |
71
- files << Dir [ "./#{ gem } /**/**/version.rb" ]
72
- end
73
-
68
+ files = [ 'elasticsearch/elasticsearch.gemspec' ] + RELEASE_TOGETHER . map { |gem | Dir [ "./#{ gem } /**/**/version.rb" ] }
74
69
version_regexp = Regexp . new ( /VERSION = ("|'([0-9.]+(-SNAPSHOT)?)'|")/ )
75
70
gemspec_regexp = Regexp . new ( /'elasticsearch-api',\s +'([0-9x.]+)'/ )
76
71
77
72
files . flatten . each do |file |
78
73
content = File . read ( file )
79
74
is_gemspec_file = file . match? ( 'gemspec' )
80
- regexp = is_gemspec_file ? gemspec_regexp : version_regexp
75
+ regexp = if is_gemspec_file
76
+ gemspec_regexp
77
+ else
78
+ version_regexp
79
+ end
81
80
82
81
if ( match = content . match ( regexp ) )
83
82
old_version = match [ 1 ]
@@ -89,12 +88,36 @@ namespace :unified_release do
89
88
else
90
89
match = content . match ( version_regexp )
91
90
old_version = match [ 1 ]
92
- content . gsub! ( old_version , "'#{ args [ : version] } '" )
91
+ content . gsub! ( old_version , "'#{ version } '" )
93
92
end
94
- puts "[#{ old_version } ] -> [#{ args [ : version] } ] in #{ file . gsub ( './' , '' ) } "
93
+ puts "[#{ old_version } ] -> [#{ version } ] in #{ file . gsub ( './' , '' ) } "
95
94
File . open ( file , 'w' ) { |f | f . puts content }
96
95
end
97
96
rescue StandardError => e
98
- abort "[!!!] #{ e . class } : #{ e . message } "
97
+ raise "[!!!] #{ e . class } : #{ e . message } "
98
+ end
99
+
100
+ desc <<-DESC
101
+ Bump the version in test matrixes:
102
+ - .ci/test-matrix.yml
103
+ - .github/workflows
104
+
105
+ Example:
106
+
107
+ $ rake unified_release:bump_matrix[42.0.0]
108
+ DESC
109
+ task :bump_matrix , :version do |_ , args |
110
+ abort ( '[!] Required argument [version] missing' ) unless ( version = args [ :version ] )
111
+
112
+ files = [ '.ci/test-matrix.yml' , '.github/workflows/main.yml' , '.github/workflows/unified-release.yml' ]
113
+ regexp = Regexp . new ( /([0-9]{1,2}\. [0-9]{1,2}\. [0-9]{1,2}?+(-SNAPSHOT)?)/ )
114
+ files . each do |file |
115
+ content = File . read ( file )
116
+ match = content . match ( regexp )
117
+ old_version = match [ 1 ]
118
+ content . gsub! ( old_version , args [ :version ] )
119
+ puts "[#{ old_version } ] -> [#{ version } ] in #{ file . gsub ( './' , '' ) } "
120
+ File . open ( file , 'w' ) { |f | f . puts content }
121
+ end
99
122
end
100
123
end
0 commit comments