Assumes a repository structure of:
/path/to/Trunk
/path/to/Releases/YYYY-MM-DD--XX
Should be easy enough to modify to suit your needs. Comments welcome :)
Example usage:
vi /usr/local/bin/release (and dump snippet into it) chmod +x /usr/local/bin/release cd /path/to/checked-out-trunk release
#!/usr/bin/ruby today = Time.now.strftime('%Y-%m-%d') if `svn info`.to_a[1] !~ /^URL: (.*)\/Trunk$/ puts "Repository invalid. Must be in Trunk." exit end repo_url = $1 repo = repo_url.split('/').last release_url = repo_url + "/Releases" if `svn ls #{release_url}`.to_a.last =~ /#{today}--(\d+)/ num = $1.to_i + 1 else num = 1 end release = "#{today}--#{num}" cmd = "svn copy #{repo_url}/Trunk #{release_url}/#{release} -m 'copy #{repo} trunk to release #{release}'" puts cmd puts print "Execute command? " if gets.chomp.upcase != 'Y' puts "Nothing done." exit end `#{cmd}` puts "Copied as #{release}." puts "Execute on the remote machine:" puts "svn switch #{release_url}/#{release}"