Created
November 24, 2015 07:51
-
-
Save legal90/24dd614097281a580288 to your computer and use it in GitHub Desktop.
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
require 'atlas' | |
require 'semantic' | |
require 'net/http' | |
USERNAME = 'parallels' | |
DESC = '* Parallels Tools v11.1.0' | |
PROVIDER = 'parallels' | |
Atlas.configure do |config| | |
config.access_token = ENV['ATLAS_TOKEN'] | |
end | |
boxes = [ | |
'centos-5.11', | |
'centos-5.11-i386', | |
'centos-6.7', | |
'centos-6.7-i386', | |
'centos-7.1', | |
'debian-7.8', | |
'debian-7.8-i386', | |
'debian-8.1', | |
'ubuntu-12.04', | |
'ubuntu-12.04-i386', | |
'ubuntu-14.04', | |
'ubuntu-14.04-i386', | |
] | |
def box_release(name) | |
box_name = "#{USERNAME}/#{name}" | |
box = Atlas::Box.find(box_name) | |
latest_ver = box.versions.first.version | |
# Use :minor or :major in order to bump version appropriately | |
new_ver = Semantic::Version.new(latest_ver).increment!(:patch) | |
new_ver = new_ver.to_s | |
new_box_url = "http://download.parallels.com/desktop/vagrant/#{name}/#{new_ver}/parallels_#{name}.box" | |
# Let's validate each uri | |
uri = URI(new_box_url) | |
response = nil | |
Net::HTTP.start(uri.hostname, 80) {|http| | |
response = http.head(uri.path) | |
} | |
unless response.kind_of? Net::HTTPSuccess | |
puts ">>> ERROR! There is something wrong with that URL:\n#{new_box_url}" | |
puts "HTTP Response: #{response.code} #{response.message}" | |
puts "The new box version for '#{box_name}' wasn't released.\n" | |
return | |
end | |
# Create a new version on Atlas | |
version = box.create_version(version: new_ver, description: DESC) | |
# Add provider for that box | |
provider = version.create_provider(name: PROVIDER, url: new_box_url) | |
# Release it! | |
version.release | |
puts "Box '#{box_name}' version '#{new_ver}' was released successfully" | |
puts "Box URL: #{new_box_url}\n\n" | |
end | |
boxes.each do |b| | |
box_release(b) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment