Class: Rake::XForge::Release
- Defined in:
- lib/rake/contrib/xforge/release.rb
Overview
This Rake task releases files to RubyForge and other GForge instaces or SourceForge clones. In its most simple usage it looks like:
project = MetaProject::Project::XForge::RubyForge.new('xforge')
# Create a new release of the xforge project on Rubyforge.
task :release => [:gem] do
Rake::XForge::Release.new(project) {}
end
The previous example will use defaults where it can. It will prompt you for your xForge user name and password before it uploads all gems under the pkg folder and creates a RubyForge release.
While defaults are nice, you may want a little more control. You can specify additional attributes:
-
#user_name
-
#password
-
#changes_file
-
#version
-
#files
-
#release_name
-
#release_notes
-
#release_changes
-
#package_name
Example:
project = MetaProject::Project::XForge::RubyForge.new('xforge')
task :release => [:gem] do
release_files = FileList[ 'pkg/*.gem', 'CHANGES' ]
Rake::XForge::Release.new(project) do |xf|
# Never hardcode user name and password in the Rakefile!
xf.user_name = ENV['RUBYFORGE_USER']
xf.password = ENV['RUBYFORGE_PASSWORD']
xf.files = release_files.to_a
xf.release_name = "XForge 0.1"
end
This can be invoked from the command line:
rake release RUBYFORGE_USER=myuser \
RUBYFORGE_PASSWORD=mypassword
If you don’t like blocks, you can do like this:
project = MetaProject::Project::XForge::RubyForge.new('xforge')
task :release => [:gem] do
xf = Rake::XForge::Release.new(project)
... # Set additional attributes
xf.execute
end
Instance Attribute Summary collapse
-
#files ⇒ Object
An array of files that should be uploaded to xForge.
-
#package_name ⇒ Object
Optional package name.
-
#release_changes ⇒ Object
Optional unless the CHANGES file is in a format different than expected.
-
#release_name ⇒ Object
The name of the release.
-
#release_notes ⇒ Object
Optional unless the CHANGES file is in a format different than expected.
Attributes inherited from Base
Instance Method Summary collapse
-
#execute ⇒ Object
Runs the release task.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Rake::XForge::Base
Instance Attribute Details
#files ⇒ Object
An array of files that should be uploaded to xForge. If this is not provided, the Rake task will default to one of two values. If the constant ::PKG_FILE_NAME is defined, then @files is [“pkg/#PKG_FILE_NAME.gem”]. Otherwise, it is all .gem files under the pkg directory.
61 62 63 |
# File 'lib/rake/contrib/xforge/release.rb', line 61 def files @files end |
#package_name ⇒ Object
Optional package name. This is necessary for projects that have more than one released package. If not defined, then the first package ID that is found on the xForge release page will be used.
75 76 77 |
# File 'lib/rake/contrib/xforge/release.rb', line 75 def package_name @package_name end |
#release_changes ⇒ Object
Optional unless the CHANGES file is in a format different than expected. You can set the change notes with this value.
71 72 73 |
# File 'lib/rake/contrib/xforge/release.rb', line 71 def release_changes @release_changes end |
#release_name ⇒ Object
The name of the release. If this is unset, MetaProject will try to set it with the values of ::PKG_NAME and ::PKG_VERSION, #version, or the project name.
65 66 67 |
# File 'lib/rake/contrib/xforge/release.rb', line 65 def release_name @release_name end |
#release_notes ⇒ Object
Optional unless the CHANGES file is in a format different than expected. You can set the release notes with this value.
68 69 70 |
# File 'lib/rake/contrib/xforge/release.rb', line 68 def release_notes @release_notes end |
Instance Method Details
#execute ⇒ Object
Runs the release task.
78 79 80 81 82 83 84 85 86 |
# File 'lib/rake/contrib/xforge/release.rb', line 78 def execute raise "'release_name' not defined." unless @release_name raise "'files' not defined." unless @files raise "'release_notes' not defined." unless @release_notes raise "'release_changes' not defined." unless @release_changes session = @project.login(user_name, password) session.release(@release_name, @files, @release_notes, @release_changes, @package_name) end |