Class: Buildr::Release

Inherits:
Object show all
Defined in:
lib/buildr/core/build.rb

Overview

:nodoc:

Direct Known Subclasses

GitRelease, SvnRelease

Constant Summary collapse

THIS_VERSION_PATTERN =
/(THIS_VERSION|VERSION_NUMBER)\s*=\s*(["'])(.*)\2/

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.commit_messageObject

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.commit_message = lambda { |ver| "Changed version number to #{ver}" }


240
241
242
# File 'lib/buildr/core/build.rb', line 240

def commit_message
  @commit_message
end

.next_versionObject

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”



253
254
255
# File 'lib/buildr/core/build.rb', line 253

def next_version
  @next_version
end

.tag_nameObject

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}" }


234
235
236
# File 'lib/buildr/core/build.rb', line 234

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.



259
260
261
262
# File 'lib/buildr/core/build.rb', line 259

def add(release)
  @list ||= []
  @list |= [release]
end

.findObject

Finds and returns the Release instance for this project.



271
272
273
274
275
276
277
# File 'lib/buildr/core/build.rb', line 271

def find
  unless @release
    klass = list.detect { |impl| impl.applies_to? }
    @release = klass.new if klass
  end
  @release
end

.listObject

The list of supported Release implementations



266
267
268
# File 'lib/buildr/core/build.rb', line 266

def list
  @list ||= []
end

Instance Method Details

#checkObject



298
299
300
301
302
# File 'lib/buildr/core/build.rb', line 298

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_versionObject

:call-seq:

extract_version() => this_version

Extract the current version number from the buildfile. Raise an error if not found.



309
310
311
312
313
314
# File 'lib/buildr/core/build.rb', line 309

def extract_version
  buildfile = File.read(Buildr.application.buildfile.to_s)
  buildfile.scan(THIS_VERSION_PATTERN)[0][2]
rescue
  fail 'Looking for THIS_VERSION = "..." in your Buildfile, none found'
end

#makeObject

:call-seq:

make()

Make a release.



285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/buildr/core/build.rb', line 285

def make
  @this_version = extract_version
  check
  with_release_candidate_version do |release_candidate_buildfile|
    args = '-S', 'buildr', "_#{Buildr::VERSION}_", '--buildfile', release_candidate_buildfile
    args << '--environment' << Buildr.environment unless Buildr.environment.to_s.empty?
    args << 'clean' << 'upload' << 'DEBUG=no'
    ruby *args
  end
  tag_release resolve_tag
  update_version_to_next if this_version != resolve_next_version(this_version)
end

#tag_name=(tag_proc) ⇒ 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.find.tag_name = lambda { |ver| "foo-#{ver}" }

Deprecated: you should use Release.tag_name instead



321
322
323
324
# File 'lib/buildr/core/build.rb', line 321

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