Created
June 24, 2011 03:07
-
-
Save joshuaflanagan/1044142 to your computer and use it in GitHub Desktop.
Example rake task that downloads CI artifacts to publish nuget packages to the official feed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Downloads from CI and pushes nuget packages to the official feed" | |
task :release, [:package] do |t, args| | |
require 'open-uri' | |
release_path = "#{buildsupport_path}/nuget_release" | |
clean_dir release_path | |
# The @teamcity_build_id is a unique identifier for the build configuration (looks like "bt234"). You can usually figure it out from your project url | |
artifact_url = "http://teamcity.codebetter.com/guestAuth/repository/downloadAll/#{@teamcity_build_id}/.lastSuccessful/artifacts.zip" | |
puts "downloading artifacts from teamcity.codebetter.com" | |
artifact = open(artifact_url) | |
unzip_file artifact.path, release_path | |
FileList["#{release_path}/*.nupkg"].exclude(".symbols.nupkg").each do |nupkg| | |
next if args[:package] && Nuget.package_name(nupkg).downcase != args[:package].downcase | |
sh "#{nuget} push #{nupkg}" do |ok, res| | |
puts "May not have published #{nupkg}" unless ok | |
end | |
end | |
end | |
def clean_dir(path) | |
mkdir_p path, :verbose => false | |
rm_r Dir.glob(File.join(path, "*.*")), :verbose => false | |
end | |
def unzip_file (file, destination) | |
require 'rubygems' | |
require 'zip/zip' | |
Zip::ZipFile.open(file) { |zip_file| | |
zip_file.each { |f| | |
f_path=File.join(destination, f.name) | |
FileUtils.mkdir_p(File.dirname(f_path)) | |
zip_file.extract(f, f_path) unless File.exist?(f_path) | |
} | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment