Class: Buildr::Release
Overview
:nodoc:
Direct Known Subclasses
Constant Summary collapse
- THIS_VERSION_PATTERN =
/(THIS_VERSION|VERSION_NUMBER)\s*=\s*(["'])(.*)\2/
Class Attribute Summary collapse
-
.commit_message ⇒ Object
Use this to specify a different commit message to commit the buildfile with the next version in source control.
-
.next_version ⇒ Object
Use this to specify the next version number to replace VERSION_NUMBER with in the buildfile.
-
.tag_name ⇒ Object
Use this to specify a different tag name for tagging the release in source control.
Class Method Summary collapse
-
.add(release) ⇒ Object
(also: <<)
:call-seq: add(MyReleaseClass).
-
.find ⇒ Object
Finds and returns the Release instance for this project.
-
.list ⇒ Object
The list of supported Release implementations.
Instance Method Summary collapse
- #check ⇒ Object
-
#extract_version ⇒ Object
:call-seq: extract_version() => this_version.
-
#make ⇒ Object
:call-seq: make().
-
#tag_name=(tag_proc) ⇒ Object
Use this to specify a different tag name for tagging the release in source control.
Class Attribute Details
.commit_message ⇒ Object
Use this to specify a different commit message to commit the buildfile with the next version in source control. You can set the commit message or a proc that will be called with the next version number, for example:
Release. = lambda { |ver| "Changed version number to #{ver}" }
261 262 263 |
# File 'lib/buildr/core/build.rb', line 261 def @commit_message end |
.next_version ⇒ Object
Use this to specify the next version number to replace VERSION_NUMBER with in the buildfile. You can set the next version or a proc that will be called with the current version number. For example, with the following buildfile:
THIS_VERSION = "1.0.0-rc1"
Release.next_version = lambda { |version|
version[-1] = version[-1].to_i + 1
version
}
Release.next_version will return “1.0.0-rc2”, so at the end of the release, the buildfile will contain VERSION_NUMBER = “1.0.0-rc2”
274 275 276 |
# File 'lib/buildr/core/build.rb', line 274 def next_version @next_version end |
.tag_name ⇒ Object
Use this to specify a different tag name for tagging the release in source control. You can set the tag name or a proc that will be called with the version number, for example:
Release.tag_name = lambda { |ver| "foo-#{ver}" }
255 256 257 |
# File 'lib/buildr/core/build.rb', line 255 def tag_name @tag_name end |
Class Method Details
.add(release) ⇒ Object Also known as: <<
:call-seq:
add(MyReleaseClass)
Add a Release implementation to the list of available Release classes.
280 281 282 283 |
# File 'lib/buildr/core/build.rb', line 280 def add(release) @list ||= [] @list |= [release] end |
.find ⇒ Object
Finds and returns the Release instance for this project.
292 293 294 295 296 297 298 |
# File 'lib/buildr/core/build.rb', line 292 def find unless @release klass = list.detect { |impl| impl.applies_to? } @release = klass.new if klass end @release end |
.list ⇒ Object
The list of supported Release implementations
287 288 289 |
# File 'lib/buildr/core/build.rb', line 287 def list @list ||= [] end |
Instance Method Details
#check ⇒ Object
320 321 322 323 324 |
# File 'lib/buildr/core/build.rb', line 320 def check if this_version == resolve_next_version(this_version) && this_version.match(/-SNAPSHOT$/) fail "The next version can't be equal to the current version #{this_version}.\nUpdate THIS_VERSION/VERSION_NUMBER, specify Release.next_version or use NEXT_VERSION env var" end end |
#extract_version ⇒ Object
:call-seq:
extract_version() => this_version
Extract the current version number from the buildfile. Raise an error if not found.
331 332 333 334 335 336 |
# File 'lib/buildr/core/build.rb', line 331 def extract_version buildfile = File.read(version_file) buildfile.scan(THIS_VERSION_PATTERN)[0][2] rescue fail 'Looking for THIS_VERSION = "..." in your Buildfile, none found' end |
#make ⇒ Object
:call-seq:
make()
Make a release.
306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/buildr/core/build.rb', line 306 def make @this_version = extract_version check with_release_candidate_version do |release_candidate_buildfile| args = [] args << 'buildr' << '--buildfile' << release_candidate_buildfile args << '--environment' << Buildr.environment unless Buildr.environment.to_s.empty? args << 'clean' << 'upload' << 'DEBUG=no' sh *args end tag_release resolve_tag update_version_to_next if this_version != resolve_next_version(this_version) end |
#tag_name=(tag_proc) ⇒ Object
343 344 345 346 |
# File 'lib/buildr/core/build.rb', line 343 def tag_name=(tag_proc) Buildr.application.deprecated "Release.find.tag_name is deprecated. You should use Release.tag_name instead" Release.tag_name=(tag_proc) end |