2008-01-23 03:55:51 +00:00
|
|
|
#!/usr/bin/env ruby
|
2007-03-17 00:56:02 +00:00
|
|
|
|
2007-05-18 02:37:31 +00:00
|
|
|
require 'tempfile'
|
|
|
|
require 'open-uri'
|
|
|
|
require 'rexml/document'
|
|
|
|
include REXML
|
|
|
|
|
2007-10-14 20:58:46 +00:00
|
|
|
feed = ARGV[0] || 'nightly'
|
|
|
|
|
|
|
|
appcast = open("http://cogx.org/appcast/#{feed}.xml")
|
2007-05-18 02:37:31 +00:00
|
|
|
|
2007-05-19 15:07:03 +00:00
|
|
|
appcastdoc = Document.new(appcast)
|
2007-05-18 02:37:31 +00:00
|
|
|
|
|
|
|
#Get the latest revision from the appcast
|
2007-05-19 15:07:03 +00:00
|
|
|
appcast_revision = Regexp.new('\d+$').match(appcastdoc.elements['//channel/item/title'].text.to_s()).to_s().to_i() || 0
|
2007-03-17 00:56:02 +00:00
|
|
|
|
2007-05-21 13:40:45 +00:00
|
|
|
#Remove modified files that may cause conflicts.
|
2009-02-21 23:27:03 +00:00
|
|
|
%x[hg revert --all]
|
2007-05-21 13:40:45 +00:00
|
|
|
|
2009-02-21 23:15:13 +00:00
|
|
|
#Offset needed for SVN <=> HG conversion. We'll use 1000 because it's simple.
|
|
|
|
revision_offset = 1000
|
|
|
|
|
2007-03-17 00:56:02 +00:00
|
|
|
#Update to the latest revision
|
2009-02-21 23:15:13 +00:00
|
|
|
%x[hg pull -u]
|
|
|
|
latest_revision = %x[hg tip --style compact].match(/^[0-9]+/)[0].to_i() + revision_offset
|
2007-03-17 00:56:02 +00:00
|
|
|
|
2007-05-18 02:37:31 +00:00
|
|
|
if appcast_revision < latest_revision
|
2007-05-21 13:40:45 +00:00
|
|
|
#Get the changelog
|
2009-02-21 23:15:13 +00:00
|
|
|
changelog = %x[hg log --template '{desc}\n' -r #{latest_revision - revision_offset}:#{appcast_revision - revision_offset + 1}]
|
2007-03-17 00:56:02 +00:00
|
|
|
|
2007-05-19 22:13:55 +00:00
|
|
|
description = ''
|
|
|
|
ignore_next = false
|
|
|
|
changelog.each_line do |line|
|
|
|
|
if (ignore_next)
|
|
|
|
ignore_next = false
|
|
|
|
next
|
|
|
|
end
|
|
|
|
if Regexp.new('^-+$').match(line)
|
|
|
|
ignore_next = true
|
|
|
|
next
|
|
|
|
elsif Regexp.new('^\s*$').match(line)
|
|
|
|
next
|
|
|
|
end
|
|
|
|
description += line
|
|
|
|
end
|
|
|
|
|
2007-05-21 13:40:45 +00:00
|
|
|
#Remove the previous build directories
|
|
|
|
%x[find . -type d -name build -print0 | xargs -0 rm -r ]
|
2007-03-17 00:56:02 +00:00
|
|
|
|
2007-05-19 15:07:03 +00:00
|
|
|
#Update the version in the plist
|
2007-05-19 15:26:51 +00:00
|
|
|
plist = open('Info.plist')
|
2007-05-19 15:07:03 +00:00
|
|
|
plistdoc = Document.new(plist)
|
|
|
|
plist.close()
|
|
|
|
|
|
|
|
version_element = plistdoc.elements["//[. = 'CFBundleVersion']/following-sibling::string"];
|
2007-05-19 15:26:51 +00:00
|
|
|
version_element.text = "r#{latest_revision}"
|
2007-05-19 15:07:03 +00:00
|
|
|
|
2007-05-19 15:26:51 +00:00
|
|
|
newplist = open('Info.plist', 'w')
|
2008-01-23 16:22:41 +00:00
|
|
|
plistdoc.write(newplist)
|
2007-05-19 15:07:03 +00:00
|
|
|
newplist.close()
|
|
|
|
|
2007-05-21 13:40:45 +00:00
|
|
|
#Build Cog!
|
2007-07-04 14:46:33 +00:00
|
|
|
%x[xcodebuild -alltargets -configuration Release 2>&1].each_line do |line|
|
2007-05-21 13:40:45 +00:00
|
|
|
if line.match(/\*\* BUILD FAILED \*\*/)
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
filename = "Cog-r#{latest_revision}.tbz"
|
|
|
|
|
|
|
|
#Zip the app!
|
2007-10-14 20:58:46 +00:00
|
|
|
%x[rm -f build/Release/#{feed}.tar.bz2]
|
|
|
|
%x[tar -C build/Release -cjf build/Release/#{feed}.tar.bz2 Cog.app]
|
2007-05-21 13:40:45 +00:00
|
|
|
|
2007-10-14 20:58:46 +00:00
|
|
|
filesize = File.size("build/Release/#{feed}.tar.bz2")
|
2007-05-21 13:40:45 +00:00
|
|
|
|
|
|
|
#Send the new build to the server
|
2007-10-14 20:58:46 +00:00
|
|
|
%x[scp build/Release/#{feed}.tar.bz2 cogx@cogx.org:~/cogx.org/#{feed}_builds/#{filename}]
|
2007-05-21 13:40:45 +00:00
|
|
|
|
|
|
|
#Add new entry to appcast
|
|
|
|
new_item = Element.new('item')
|
|
|
|
|
|
|
|
new_item.add_element('title')
|
|
|
|
new_item.elements['title'].text = "Cog r#{latest_revision}"
|
|
|
|
|
|
|
|
new_item.add_element('description')
|
|
|
|
new_item.elements['description'].text = description
|
|
|
|
|
|
|
|
new_item.add_element('pubDate')
|
|
|
|
new_item.elements['pubDate'].text = Time.now().strftime("%a, %d %b %Y %H:%M:%S %Z") #RFC 822
|
|
|
|
|
2008-01-23 16:22:41 +00:00
|
|
|
new_item.add_element('sparkle:minimumSystemVersion')
|
|
|
|
new_item.elements['sparkle:minimumSystemVersion'].text = '10.5.0'
|
|
|
|
|
2007-05-21 13:40:45 +00:00
|
|
|
new_item.add_element('enclosure')
|
2007-10-14 20:58:46 +00:00
|
|
|
new_item.elements['enclosure'].add_attribute('url', "http://cogx.org/#{feed}_builds/#{filename}")
|
2007-05-21 13:40:45 +00:00
|
|
|
new_item.elements['enclosure'].add_attribute('length', filesize)
|
|
|
|
new_item.elements['enclosure'].add_attribute('type', 'application/octet-stream')
|
|
|
|
new_item.elements['enclosure'].add_attribute('sparkle:version', "r#{latest_revision}")
|
|
|
|
|
|
|
|
appcastdoc.insert_before('//channel/item', new_item)
|
|
|
|
|
|
|
|
#Limit number of entries to 5
|
|
|
|
appcastdoc.delete_element('//channel/item[position()>5]')
|
|
|
|
|
|
|
|
new_xml = Tempfile.new('appcast.xml')
|
2008-01-23 16:22:41 +00:00
|
|
|
appcastdoc.write(new_xml)
|
2007-05-21 13:40:45 +00:00
|
|
|
new_xml.close()
|
|
|
|
appcast.close()
|
2009-02-21 23:15:13 +00:00
|
|
|
|
2007-05-21 13:40:45 +00:00
|
|
|
#Send the updated appcast to the server
|
2007-10-14 20:58:46 +00:00
|
|
|
%x[scp #{new_xml.path} cogx@cogx.org:~/cogx.org/appcast/#{feed}.xml]
|
2007-05-21 13:40:45 +00:00
|
|
|
|
2007-03-17 00:56:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|