public
Description: Scripts to automate build numbering, packaging and distributing (via sparkle)
Homepage:
Clone URL: git://github.com/ncb/xcode-build-scripts.git
xcode-build-scripts / appcast.rb
100755 57 lines (48 sloc) 1.7 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env ruby
#
# Adapted from http://codeintensity.blogspot.com/2008/03/creating-sparkle-appcast-via-rake-tasks.html
#
# Nick Brawn
 
require 'yaml'
require 'rubygems'
require 'builder'
require 'Time'
APPCAST_URL = "http://YOURSITE.COM"
APPCAST_FILENAME = 'appcast.xml'
 
def make_appcast
  begin
    versions = YAML.load_file("/path/to/version_info.yml")
  rescue Exception => e
    raise StandardError, "appcast/version_info.yml could not be loaded: #{e.message}"
  end
  
  appcast = File.open("#{APPCAST_FILENAME}", 'w')
 
  xml = Builder::XmlMarkup.new(:target => appcast, :indent => 2)
 
  xml.instruct!
  xml.rss('xmlns:atom' => "http://www.w3.org/2005/Atom",
          'xmlns:sparkle' => "http://www.andymatuschak.org/xml-namespaces/sparkle",
          :version => "2.0") do
    xml.channel do
      xml.title('Pepper Appcast')
      xml.link(APPCAST_URL)
      xml.description('New build')
      xml.language('en')
      xml.pubDate(Time.now.rfc822)
      xml.lastBuildDate(Time.now.rfc822)
      xml.atom(:link, :href => "#{APPCAST_URL}/#{APPCAST_FILENAME}",
               :rel => "self", :type => "application/rss+xml")
 
      versions.each do |version|
        
        guid = version.first
        items = version[1]
        file = "/path/to/#{items['filename']}"
        
        xml.item do
          xml.title(items['title'])
          xml.description { xml << xml.pubDate(File.mtime(file)) }
          xml.enclosure(:url => "#{APPCAST_URL}/#{items['filename']}",
                        :length => "#{File.size(file)}", :type => "application/zip")
          xml.guid(guid, :isPermaLink => "false")
        end
      end
    end
  end
end
 
make_appcast