Class: Buildr::Release

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

Constant Summary collapse

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

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

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


160
161
162
# File 'lib/buildr/core/build.rb', line 160

def tag_name
  @tag_name
end

Class Method Details

.checkObject

:call-seq:

check()

Check that we don’t have any local changes in the working copy. Fails if it finds anything in the working copy that is not checked into source control.



212
213
214
215
# File 'lib/buildr/core/build.rb', line 212

def check
  fail "SVN URL must contain 'trunk' or 'branches/...'" unless Svn.repo_url =~ /(trunk)|(branches.*)$/
  fail "Uncommitted SVN files violate the First Principle Of Release!\n#{Svn.uncommitted_files}" unless Svn.uncommitted_files.empty?
end

.extract_versionObject

:call-seq:

extract_version() => this_version

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



182
183
184
185
186
187
# File 'lib/buildr/core/build.rb', line 182

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.



166
167
168
169
170
171
172
173
174
175
# File 'lib/buildr/core/build.rb', line 166

def make
  check
  with_release_candidate_version do |release_candidate_buildfile| 
    options = ['--buildfile', release_candidate_buildfile, 'DEBUG=no']
    options << '--environment' << Buildr.environment unless Buildr.environment.to_s.empty?
    buildr %w{clean upload}, options
  end
  tag_release
  commit_new_snapshot
end

.tag_url(svn_url, version) ⇒ Object

:call-seq:

tag_url(svn_url, version) => tag_url

Returns the SVN url for the tag. Can tag from the trunk or from branches. Can handle the two standard repository layouts.

- http://my.repo/foo/trunk => http://my.repo/foo/tags/1.0.0
- http://my.repo/trunk/foo => http://my.repo/tags/foo/1.0.0


197
198
199
200
201
202
203
204
205
# File 'lib/buildr/core/build.rb', line 197

def tag_url(svn_url, version)
  trunk_or_branches = Regexp.union(%r{^(.*)/trunk(.*)$}, %r{^(.*)/branches(.*)/([^/]*)$})
  match = trunk_or_branches.match(svn_url)
  prefix = match[1] || match[3]
  suffix = match[2] || match[4]
  tag = tag_name || version
  tag = tag.call(version) if Proc === tag
  prefix + '/tags' + suffix + '/' + tag
end