This repository has been archived by the owner on Jun 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
73 lines (59 loc) · 2.19 KB
/
Rakefile
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require 'rexml/document'
module Spotify
def self.path
'/Applications/Spotify.app'
end
def self.bundle_version
plist_value :CFBundleVersion
end
def self.version
plist_value :CFBundleShortVersionString
end
def self.plist_value(key)
@spotify_plist ||= REXML::Document.new(File.new("#{path}/Contents/Info.plist"))
REXML::XPath.match(@spotify_plist, %Q{//key[text()="#{key.to_s}"]/following-sibling::string[1]}).pop.text
end
end
desc 'Update the SIMBL maximum bundle version to the current version of Spotify'
task :update do
lastify_plist = REXML::Document.new(File.new('Info.plist'))
array_node = REXML::XPath.match(lastify_plist, '//key[text()="SIMBLTargetApplications"]/following-sibling::array[1]')
max_version_node = REXML::XPath.match(array_node, '//key[text()="MaxBundleVersion"]/following-sibling::string[1]').pop
max_version_node.text = Spotify.bundle_version
File.open('Info.plist', 'w') {|f| f.write(lastify_plist) }
puts "\nVersion updated to #{Spotify.version} (#{Spotify.bundle_version})"
end
desc 'Recompile the plugin'
task :build do
system 'xcodebuild'
end
desc 'Creates a ZIP file of the current build'
task :package do
Dir.chdir 'build/Release'
system 'zip', '-r', "lastify-#{Spotify.version}.zip", 'Lastify.bundle'
end
desc 'Uploads a ZIP file of the current build to Github'
task :upload do
begin
require 'net/github-upload'
rescue LoadError
raise 'Please run `gem install net-github-upload` to continue'
end
login, token = ['github.user', 'github.token'].map{|key| `git config #{key}`.chomp }
github = Net::GitHub::Upload.new(:login => login, :token => token)
github.upload(:repos => 'lastify', :file => "build/Release/lastify-#{Spotify.version}.zip", :description => "for Spotify #{Spotify.version}")
end
namespace :spotify do
desc "Outputs the current Spotify version"
task :version do
puts "#{Spotify.version} (#{Spotify.bundle_version})"
end
desc 'Restart Spotify'
task :restart do
system 'killall', 'Spotify'
system 'open', Spotify.path
end
end
desc 'Runs the "update", "build" and "spotify:restart" tasks'
task :update_and_build => [:update, :build, :'spotify:restart']
task :default => :update_and_build