motion-sparkle-sandbox 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ea2fe074fe116c936f315bcf309dd105a02ce4a445b428ca3ab6cffca22a22fb
4
+ data.tar.gz: 3ab4895f626030ee44a6ef9a4182721d4a34a8cb560a553476770a25ae14b0f5
5
+ SHA512:
6
+ metadata.gz: b1a5ec3c5d6c2008e0fbcb63ece4c10b6d2cf222ef6f34fc769242efa6c6c9c06dd0f7b8457cc87d6cc53b4ed7a60597cc2b6a24d76f8957e8b7f4f33c6e2fb2
7
+ data.tar.gz: 7886312a026058f6b02933f8406325b49712910d69efac85380b6d1e46d6ec70c4014af07faf04e5893898b54cb667c690e95cba82096a85e05bbff384ee92b3
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+ Gemfile.lock
15
+
16
+ # YARD artifacts
17
+ .yardoc
18
+ _yardoc
19
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'bacon'
6
+ gem 'rake'
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Alexandre L. Solleiro <alex@webcracy.org>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,260 @@
1
+ # motion-sparkle-sandbox
2
+
3
+ Easily package and release updates of your RubyMotion app with Sparkle.
4
+
5
+ *NB: Sparkle only works for OS X projects*
6
+
7
+ ## Sandboxing
8
+
9
+ This version uses the [ui-separation-and-xpc branch](https://github.com/sparkle-project/Sparkle/tree/ui-separation-and-xpc) to support an app that uses sandboxing. Sparkle is in transition, and the sandbox version is slated for 2.0.
10
+
11
+ _Sparkle built from ui-separation-and-xpc#b1c3b313f53c95a91c8adc07b991ff9a306e6cf8 on Dec 9th, 2018_
12
+
13
+ [Reference thread](https://github.com/sparkle-project/Sparkle/issues/363)
14
+
15
+ ## Table of Contents
16
+
17
+ - [Overview](#overview)
18
+ - [Compatibility](#compatibility)
19
+ - [Installation](#installation)
20
+ - [Settings configuration](#settings-configuration)
21
+ - [Certificate configuration](#certificate-configuration)
22
+ - [Generate new certificates](#generate-new-certificates)
23
+ - [Use your existing certificates](#use-your-existing-certificates)
24
+ - [Notes about the public certificate](#notes-about-the-public-certificate)
25
+ - [Notes about the private certificate](#notes-about-the-private-certificate)
26
+ - [Warning regarding your private certificate](#warning-regarding-your-private-certificate)
27
+ - [Run rake sparkle:setup at any moment to make sure your config is OK](#run-rake-sparklesetup-at-any-moment-to-make-sure-your-config-is-ok)
28
+ - [Adding "Check for updates..." to the menu](#adding-check-for-updates-to-the-menu)
29
+ - [First publication](#first-publication)
30
+ - [Releasing updates](#releasing-updates)
31
+ - [1. Bump the version](#1-bump-the-version)
32
+ - [2. Build your app for release](#2-build-your-app-for-release)
33
+ - [3. Update your Release Notes](#3-update-your-release-notes)
34
+ - [4. Package the release](#4-package-the-release)
35
+ - [5. Upload](#5-upload)
36
+ - [Help, Limitations, Troubleshooting and Testing](#help-limitations-troubleshooting-and-testing)
37
+ - [Contributing](#contributing)
38
+ - [Credits](#credits)
39
+
40
+ ## Overview
41
+
42
+ [Sparkle](http://sparkle.andymatuschak.org/) powers the "Check for updates" feature of countless Mac applications.
43
+
44
+ In a nutshell, when users click "Check for updates..." in an app, Sparkle checks for available updates against an XML file that you post somewhere on the web. That XML file contains information about your new release, such as the version number, the URL of the package and its digital signature. If there's a newer version available than the one that is currently running, it'll ask for permission to retrieve the package and replace the current app with the new release.
45
+
46
+ While it's easy to use Sparkle with RubyMotion without `motion-sparkle-sandbox`, it's even easier if you use it. The gem takes care of the Sparkle framework integration, simplifies its configuration and then automates the preparation of a release, creating the ZIP, XML and release notes HTML file for you.
47
+
48
+ After building your app for release and running `rake sparkle:package`, all you need to do is upload 3 files to the URL you specify in the `Rakefile` and your users will be able to get the new release.
49
+
50
+ ## Compatibility
51
+
52
+ ### Mac OS X 10.10 and above
53
+
54
+ * Use the latest version of **motion-sparkle-sandbox**
55
+ * You will need RubyMotion version 2.38 or above for Yosemite compatibility
56
+ * Sparkle only supports Mac OS X 10.10 Yosemite and above
57
+
58
+ ## Installation
59
+
60
+ In your project's Gemfile, add:
61
+ ```ruby
62
+ # Gemfile
63
+
64
+ gem 'motion-sparkle'
65
+ ```
66
+ and then run
67
+
68
+ $ bundle install
69
+
70
+ ## Settings configuration
71
+
72
+ Configure Sparkle in your `Rakefile` using `motion-sparkle-sandbox`'s DSL:
73
+ ```ruby
74
+ # Rakefile
75
+
76
+ app.sparkle do
77
+ # Required setting
78
+ release :base_url, 'http://example.com/releases/current' # `current` is a folder, don't use a trailing slash
79
+
80
+ # Recommended setting
81
+ # This will set both your `app.version` and `app.short_version` to the same value
82
+ # It's fine not to use it, just remember to set both as Sparkle needs them
83
+ release :version, '1.0'
84
+
85
+ ## Optional settings and their default values and/or examples
86
+
87
+ ## Please note that `base_url` must always be set (at the moment),
88
+ ## even you override it completely with the options below
89
+
90
+ # Public Key
91
+ release :public_key, 'dsa_pub.pem' # default
92
+
93
+ # Appcast Feed
94
+ release :feed_base_url, 'http://downloads.example.com/releases' # defaults to base_url
95
+ release :feed_filename, 'releases.xml' # default
96
+
97
+ # Release Notes
98
+ release :notes_base_url, 'http://downloads.example.com/releases' # defaults to base_url
99
+ release :notes_filename, 'release_notes.html' # default
100
+
101
+ # App Package
102
+ release :package_base_url, 'http://downloads.example.com/releases' # defaults to base_url
103
+ release :package_filename, "#{app.name}.zip" # default
104
+ end
105
+ ```
106
+
107
+ To complete the configuration, run
108
+
109
+ $ rake sparkle:setup
110
+
111
+
112
+ If everything is OK, you should be informed that it's time to generate or configure your certificates.
113
+
114
+ ## Certificate configuration
115
+
116
+ For security, Sparkle allows you to sign your releases with a private certificate before distribution: when the user tries to install an update, Sparkle will check the package using the signature provided in the XML file and the public certificate contained in the running application.
117
+
118
+ motion-sparkle-sandbox makes it very easy to handle this. In fact, after the first setup, it becomes completely transparent to you as all is handled when you run `rake sparkle:package`.
119
+
120
+ You have two options: have Sparkle generate the certificates for you, or follow the instructions to use your existing ones.
121
+
122
+ ### Generate new certificates
123
+
124
+ $ rake sparkle:setup_certificates
125
+
126
+
127
+ ### Use your existing certificates
128
+
129
+ By default, your certificates need to be placed in the following directories:
130
+
131
+
132
+ ./resources/dsa_pub.pem # public certificate
133
+ ./sparkle/config/dsa_priv.pem # private certificate
134
+
135
+
136
+ ### Notes about the public certificate
137
+
138
+ The public certificate is placed at the root of the default `resources/` folder by default, as it needs to bundled with your app. If you chose to rename it, remember to set its correct value in the `Rakefile`, using `release :public_key, 'new_name.pem'`.
139
+
140
+ ### Notes about the private certificate
141
+
142
+ The private certificate cannot be renamed nor placed elsewhere. If you have an existing certificate, please name it `dsa_priv.pem` and place inside the `sparkle/config/` folder
143
+
144
+ ### Warning regarding your private certificate
145
+
146
+ Be careful when handling the private certificate: you should never lose it nor share it. If you do, you'd lose the ability to sign your packages and users wouldn't be able to update your app. If someone takes it, they could sign the packages in your name and have your users install who knows what.
147
+
148
+ Tips:
149
+ * add it go your `.gitignore` or equivalent
150
+ * make a backup of it
151
+
152
+ ### Run `rake sparkle:setup` at any moment to make sure your config is OK
153
+
154
+ When all is good, move forward. If you need help, you can always open an issue on Github.
155
+
156
+ ## Adding "Check for updates..." to the menu
157
+
158
+ Sparkle makes it incredibly easy to add a "Check for updates" feature to your app.
159
+
160
+ Sparkle's `SUUpdater` class has a shared updater instance that can serve as a `target` for Sparkle actions. To launch the typical Sparkle flow, call the `checkForUpdates:` action.
161
+
162
+ So, to launch the "Check for updates" flow, you can call `SUUpdater.new.checkForUpdates`.
163
+
164
+ Here's an example based on the RubyMotion default OS X app example, "Hello". You can check out Sparkle's documentation for more details and further ways to customize the experience.
165
+
166
+ This will add the classic "Check for updates..." entry on the menu; when the user clicks it, the nice default of experience of Sparkle will begin.
167
+
168
+ In `menu.rb`, right below the line that adds the "Preferences" item:
169
+ ```ruby
170
+ sparkle = addItemWithTitle("Check for updates...", action: nil, keyEquivalent: '')
171
+ sparkle.setTarget SUUpdater.new
172
+ sparkle.setAction 'checkForUpdates:'
173
+ ```
174
+
175
+ Once you build your application, you should be able to see a "Check for updates..." item in the Application menu. Using it will work but will quickly produce an error. Keep going to make it work.
176
+
177
+ ## First publication
178
+
179
+ Before you build, make sure you've set your `:base_url` to a destination where you can upload/download your files.
180
+
181
+ Note that packaging with motion-sparkle-sandbox only works with the `:release` target at the moment, so make sure your build with be compatible with `rake build:release`.
182
+
183
+ Run the setup command again to make sure it's all good:
184
+
185
+ $ rake sparkle:setup
186
+
187
+ If you're ready to go, run the `sparkle:package` task:
188
+
189
+ $ rake sparkle:package
190
+
191
+ This should create 3 files inside the `sparkle/release/` folder: a ZIP file of your app, an XML file and an HTML file with the release notes.
192
+
193
+ If you've set your `:base_url` correctly, go ahead and upload thoses files to the location you've specified. Run your app and click "Check for updates..." in the menu -- this time, it should say that it's running the latest version available.
194
+
195
+ ## Releasing updates
196
+
197
+ Once users are running a Sparkle-powered version, all you have to do is put updated versions of those files at the same location.
198
+
199
+ To do so, follow the same steps every time:
200
+
201
+ ### 1. Bump the version
202
+
203
+ ```ruby
204
+ # In your Rakefile
205
+
206
+ sparkle.app do
207
+ release :version, '1.1' # bump the versions
208
+ end
209
+ ```
210
+
211
+ ### 2. Build your app for release
212
+
213
+ $ rake build:release
214
+
215
+ ### 3. Update your Release Notes
216
+
217
+ Release notes are generated using an HTML file for content and an ERB file for layout. Sparkle uses Webkit to show them to your users at the time of update.
218
+
219
+ You can either change these files inside the `sparkle/config/` folder, or simply edit the resulting html file in `sparkle/release/` after you've packaged the release.
220
+
221
+ ### 4. Package the release
222
+
223
+ Run the `sparkle:package` task and you'll be one step away from distribution.
224
+
225
+ $ rake sparkle:package
226
+
227
+ ### 5. Upload
228
+
229
+ Upload the 3 files and your new version is up. When users click "Check for updates...", the app should now display your release notes and ask the user to update. And when they do, the app will update and relaunch itself cleanly.
230
+
231
+ Sparkle for the win.
232
+
233
+ ## Help, Limitations, Troubleshooting and Testing
234
+
235
+ If you need further help, please open an [Issue on Github](https://github.com/digitalmoksha/motion-sparkle-sandbox/issues/).
236
+
237
+ Limitations:
238
+
239
+ * Only tested with Ruby 1.9.3-p448
240
+ * Only works with ZIP files
241
+ * Only works with :release build target
242
+ * The Sparkle framework is horrendously copied multiple times
243
+
244
+ To further troubleshoot your case, you clone/fork the repo and go through the tests and the code.
245
+
246
+ To test, you can just run `$ bundle install` at the source of the repo to install the development dependencies and the run `$ rake` to execute the tests.
247
+
248
+ Test coverage currently only extends to configuration and certificate generation checking.
249
+
250
+ ## Contributing
251
+
252
+ Please do help with comments, issues and pull requests! The gem's repository is at [github.com/digitalmoksha/motion-sparkle-sandbox](https://github.com/digitalmoksha/motion-sparkle-sandbox/).
253
+
254
+ ## Credits
255
+
256
+ Contributors: [View all on Github](https://github.com/digitalmoksha/motion-sparkle-sandbox/graphs/contributors)
257
+
258
+ Originally created by [Alexandre L. Solleiro](http://github.com/webcracy), and forked from [webcracy/motion-sparkle](https://github.com/webcracy/motion-sparkle)
259
+
260
+ Huge thanks to [andymatuschak/Sparkle](https://github.com/andymatuschak/Sparkle) for creating and continuing to maintain Sparkle!
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ desc "Run all the specs"
4
+ task :spec do
5
+ sh "bundle exec bacon -q #{FileList['spec/*_spec.rb'].join(' ')}"
6
+ end
7
+ task :default => :spec
8
+ task :test => :spec
@@ -0,0 +1,11 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise "This file must be required within a RubyMotion project Rakefile."
3
+ end
4
+ require 'motion/project/sparkle'
5
+ require 'motion/project/install'
6
+ require 'motion/project/setup'
7
+ require 'motion/project/package'
8
+ require 'motion/project/templates'
9
+ require 'motion/project/appcast'
10
+ require 'motion/project/project'
11
+ require 'motion/project/rake_tasks'
@@ -0,0 +1,127 @@
1
+ module Motion::Project
2
+ class Sparkle
3
+
4
+ def create_release_notes
5
+ if File.exist?(release_notes_template_path)
6
+ File.open("#{release_notes_path}", "w") do |f|
7
+ template = File.read(release_notes_template_path)
8
+ f << ERB.new(template).result(binding)
9
+ end
10
+ App.info 'Create', "./#{release_notes_path}"
11
+ else
12
+ App.fail "Release notes template not found as expected at ./#{release_notes_template_path}"
13
+ end
14
+ end
15
+
16
+ def create_appcast
17
+ create_release_folder
18
+ appcast_file = File.open("#{sparkle_release_path}/#{appcast.feed_filename}", 'w') do |f|
19
+ xml_string = ''
20
+ doc = REXML::Formatters::Pretty.new
21
+ doc.write(appcast_xml, xml_string)
22
+ f << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
23
+ f << xml_string
24
+ f << "\n"
25
+ end
26
+ if appcast_file
27
+ App.info "Create", "./#{sparkle_release_path}/#{appcast.feed_filename}"
28
+ else
29
+ App.info "Fail", "./#{sparkle_release_path}/#{appcast.feed_filename} not created"
30
+ end
31
+ end
32
+
33
+ def appcast_xml
34
+ rss = REXML::Element.new 'rss'
35
+ rss.attributes['xmlns:atom'] = "http://www.w3.org/2005/Atom"
36
+ rss.attributes['xmlns:sparkle'] = "http://www.andymatuschak.org/xml-namespaces/sparkle"
37
+ rss.attributes['xmlns:version'] = "2.0"
38
+ rss.attributes['xmlns:dc'] = "http://purl.org/dc/elements/1.1/"
39
+ channel = rss.add_element 'channel'
40
+ channel.add_element('title').text = @config.name
41
+ channel.add_element('description').text = "#{@config.name} updates"
42
+ channel.add_element('link').text = @config.info_plist["SUFeedURL"]
43
+ channel.add_element('language').text = 'en'
44
+ channel.add_element('pubDate').text = Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")
45
+ atom_link = channel.add_element('atom:link')
46
+ atom_link.attributes['href'] = @config.info_plist["SUFeedURL"]
47
+ atom_link.attributes['rel'] = 'self'
48
+ atom_link.attributes['type'] = "application/rss+xml"
49
+ item = channel.add_element 'item'
50
+ item.add_element('title').text = "#{@config.name} #{@config.short_version}"
51
+ item.add_element('pubDate').text = Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")
52
+ guid = item.add_element('guid')
53
+ guid.text = "#{@config.name}-#{@config.short_version}"
54
+ guid.attributes['isPermaLink'] = false
55
+ item.add_element('sparkle:releaseNotesLink').text = "#{appcast.notes_url}"
56
+ enclosure = item.add_element('enclosure')
57
+ enclosure.attributes['url'] = "#{appcast.package_url}"
58
+ enclosure.attributes['length'] = "#{@package_size}"
59
+ enclosure.attributes['type'] = "application/octet-stream"
60
+ enclosure.attributes['sparkle:version'] = @config.version
61
+ enclosure.attributes['sparkle:shortVersionString'] = @config.short_version
62
+ enclosure.attributes['sparkle:dsaSignature'] = @package_signature
63
+ rss
64
+ end
65
+
66
+ def release_notes_template_path
67
+ sparkle_config_path + "release_notes.template.erb"
68
+ end
69
+
70
+ def release_notes_content_path
71
+ sparkle_config_path + "release_notes.content.html"
72
+ end
73
+
74
+ def release_notes_path
75
+ sparkle_release_path + appcast.notes_filename.to_s
76
+ end
77
+
78
+ def release_notes_content
79
+ if File.exist?(release_notes_content_path)
80
+ File.read(release_notes_content_path)
81
+ else
82
+ App.fail "Missing #{release_notes_content_path}"
83
+ end
84
+ end
85
+
86
+ def release_notes_html
87
+ release_notes_content
88
+ end
89
+
90
+
91
+ class Appcast
92
+ attr_accessor :base_url,
93
+ :feed_base_url,
94
+ :feed_filename,
95
+ :notes_base_url,
96
+ :notes_filename,
97
+ :package_base_url,
98
+ :package_filename,
99
+ :archive_folder
100
+
101
+ def initialize
102
+ @feed_base_url = nil
103
+ @feed_filename = 'releases.xml'
104
+ @notes_base_url = nil
105
+ @notes_filename = 'release_notes.html'
106
+ @package_base_url = nil
107
+ @package_filename = nil
108
+ @base_url = nil
109
+ @archive_folder = nil
110
+ end
111
+
112
+ def feed_url
113
+ "#{feed_base_url || base_url}/#{feed_filename}"
114
+ end
115
+
116
+ def notes_url
117
+ "#{notes_base_url || base_url}/#{notes_filename}"
118
+ end
119
+
120
+ def package_url
121
+ "#{package_base_url || base_url}/#{package_filename}"
122
+ end
123
+
124
+ end
125
+
126
+ end
127
+ end