releasy 0.2.0rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/.gitignore +17 -0
  2. data/.yardopts +4 -0
  3. data/CHANGELOG.md +24 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.md +165 -0
  7. data/Rakefile +31 -0
  8. data/bin/7z.sfx +0 -0
  9. data/bin/releasy +7 -0
  10. data/lib/releasy.rb +18 -0
  11. data/lib/releasy/archivers.rb +12 -0
  12. data/lib/releasy/archivers/archiver.rb +74 -0
  13. data/lib/releasy/archivers/dmg.rb +18 -0
  14. data/lib/releasy/archivers/exe.rb +23 -0
  15. data/lib/releasy/archivers/seven_zip.rb +12 -0
  16. data/lib/releasy/archivers/tar_archiver.rb +14 -0
  17. data/lib/releasy/archivers/tar_bzip2.rb +13 -0
  18. data/lib/releasy/archivers/tar_gzip.rb +13 -0
  19. data/lib/releasy/archivers/zip.rb +12 -0
  20. data/lib/releasy/builders.rb +12 -0
  21. data/lib/releasy/builders/builder.rb +52 -0
  22. data/lib/releasy/builders/ocra_builder.rb +43 -0
  23. data/lib/releasy/builders/osx_app.rb +158 -0
  24. data/lib/releasy/builders/source.rb +27 -0
  25. data/lib/releasy/builders/windows_builder.rb +65 -0
  26. data/lib/releasy/builders/windows_folder.rb +47 -0
  27. data/lib/releasy/builders/windows_folder_from_ruby_dist.rb +150 -0
  28. data/lib/releasy/builders/windows_installer.rb +117 -0
  29. data/lib/releasy/builders/windows_standalone.rb +37 -0
  30. data/lib/releasy/cli.rb +12 -0
  31. data/lib/releasy/cli/install_sfx.rb +66 -0
  32. data/lib/releasy/dsl_wrapper.rb +71 -0
  33. data/lib/releasy/mixins/exec.rb +14 -0
  34. data/lib/releasy/mixins/has_archivers.rb +37 -0
  35. data/lib/releasy/mixins/has_gemspecs.rb +42 -0
  36. data/lib/releasy/mixins/register.rb +47 -0
  37. data/lib/releasy/project.rb +300 -0
  38. data/lib/releasy/version.rb +3 -0
  39. data/lib/releasy/windows_wrapper_maker.rb +90 -0
  40. data/lib/releasy/windows_wrapper_maker/Gemfile +8 -0
  41. data/media/releasy.png +0 -0
  42. data/releasy.gemspec +37 -0
  43. data/test/releasy/archivers_test.rb +65 -0
  44. data/test/releasy/builders/data/Info.plist +51 -0
  45. data/test/releasy/builders/data/Main.rb +12 -0
  46. data/test/releasy/builders/data/relapse_runner.rb +1 -0
  47. data/test/releasy/builders/data/set_app_executable.sh +3 -0
  48. data/test/releasy/builders/helpers/helper.rb +47 -0
  49. data/test/releasy/builders/ocra_builder_test.rb +37 -0
  50. data/test/releasy/builders/osx_app_test.rb +107 -0
  51. data/test/releasy/builders/source_test.rb +43 -0
  52. data/test/releasy/builders/windows_builder_test.rb +26 -0
  53. data/test/releasy/builders/windows_folder_from_ruby_dist_test.rb +105 -0
  54. data/test/releasy/builders/windows_folder_test.rb +56 -0
  55. data/test/releasy/builders/windows_installer_test.rb +62 -0
  56. data/test/releasy/builders/windows_standalone_test.rb +58 -0
  57. data/test/releasy/cli/install_sfx_test.rb +90 -0
  58. data/test/releasy/dsl_wrapper_test.rb +79 -0
  59. data/test/releasy/integration/source_test.rb +122 -0
  60. data/test/releasy/mixins/register_test.rb +52 -0
  61. data/test/releasy/project_test.rb +198 -0
  62. data/test/releasy/windows_wrapper_maker_test.rb +61 -0
  63. data/test/teststrap.rb +52 -0
  64. data/test/yard_test.rb +61 -0
  65. data/test_project/Gemfile +9 -0
  66. data/test_project/LICENSE.txt +1 -0
  67. data/test_project/README.txt +2 -0
  68. data/test_project/bin/test_app +3 -0
  69. data/test_project/lib/test_app.rb +6 -0
  70. data/test_project/lib/test_app/stuff.rb +1 -0
  71. data/test_project/test_app.icns +0 -0
  72. data/test_project/test_app.ico +0 -0
  73. data/wrappers/put_wrappers_here_for_testing.txt +17 -0
  74. metadata +236 -0
@@ -0,0 +1,17 @@
1
+ pkg
2
+ *.swp
3
+ *.swo
4
+ *.log
5
+ .DS_Store
6
+ .yardoc
7
+ tmp
8
+ tags
9
+ ctags
10
+ .bundle
11
+ .idea/
12
+ doc/
13
+ test_output
14
+ test_project/test_app.exe
15
+ Gemfile.lock
16
+ wrappers/*.tar.gz
17
+ wrappers/*.7z
@@ -0,0 +1,4 @@
1
+ --title 'Releasy Documentation'
2
+ -
3
+ CHANGELOG.md
4
+ LICENSE.txt
@@ -0,0 +1,24 @@
1
+ Releasy Change Log
2
+ ==================
3
+
4
+ v0.2.0
5
+ ------
6
+
7
+ * Name changed from "relapse" to "releasy" because of universal dislike and/or confusion about it :)
8
+ * Warning: API changed significantly from v0.1.0 because it was dreadful :D
9
+ * Allowed outputs to be configured separately from the project.
10
+ * Included gems in osx-app more safely, so that no files will be missing.
11
+ * Added `:exe` archive format (Windows self-extractor, used on any OS).
12
+ * Added `:dmg` archive format (OS X self-extractor, used on OS X only).
13
+ * Added `:windows_folder_from_ruby_dist` output (windows folder made from a RubyInstaller archive, used on OSX/Linux).
14
+ * Allowed project and outputs to have archive formats (when called on Project, affecting all outputs).
15
+ * Archive formats can have a different `#extension` set.
16
+ * Output formats can have a different `#folder_suffix` set.
17
+ * No longer require Innosetup to be installed in order to create `:windows_folder` output.
18
+ * Added command, 'releasy install-sfx' that installs the self-extractor package for 7z, to enable :exe archiving (non-Windows only).
19
+ * Lots of other things fixes, refactors and additions, that I lost track of :$
20
+
21
+ v0.1.0
22
+ ------
23
+
24
+ * First public release as "relapse"
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Bil Bas (Spooner)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,165 @@
1
+ Releasy
2
+ =======
3
+
4
+ _Releasy_ automates the release of Ruby applications (name comes from "Release + easy").
5
+ By configuring a {Releasy::Project} in your application's rakefile, Releasy can generates a number of Rake tasks for use
6
+ when there is a need to release a new version of the application.
7
+
8
+ Releasy allows cross-platform releases, relying on pre-made OS X or Windows wrappers to act as templates
9
+ (Releasy is able to make the latter type of wrapper itself).
10
+
11
+ * Author: [Bil Bas (Spooner)](https://github.com/Spooner)
12
+ * Licence: [MIT](http://www.opensource.org/licenses/mit-license.php)
13
+ * [Github project](https://github.com/Spooner/releasy)
14
+ * [Reporting issues](https://github.com/Spooner/releasy/issues)
15
+ * Wrappers used to build cross-platform releases:
16
+ - _Windows:_ [RubyInstaller 7-ZIP archives](http://rubyinstaller.org/downloads/); Ruby 1.8.7, 1.9.2 or 1.9.3
17
+ - _OS X:_ [libgosu downloads](http://www.libgosu.org/downloads/). Latest version of the OS X-compatible wrapper is "gosu-mac-wrapper-0.7.41.tar.gz" which uses Ruby 1.9.2 and includes some binary gems: Gosu, Chipmunk and TexPlay.
18
+ * Tested on Ruby 1.9.3 and 1.8.7 on Windows, Lubuntu and OS X. However, since this is an early version, please ensure that you double-check any releases created by Releasy before publishing them!
19
+
20
+ Output types supported
21
+ ----------------------
22
+
23
+ The project can create one or more release folders:
24
+
25
+ * `:source` - Plain source folder, which can be used by anyone with Ruby already installed.
26
+ * `:osx_app` - OS X application bundle (.app) build, requiring a pre-made Ruby OS X wrapper [Note that this only contains binary gems for Gosu, TexPlay and Chipmunk, but will work with applications using any other source gems].
27
+ * `:windows_folder` - A folder containing Ruby, application source files and an EXE to run them [creation on Windows only]
28
+ * `:windows_folder_from_ruby_dist` - A folder containing Ruby, application source files and an EXE to run them, requiring a copy of a RubyInstaller archive [creation on OSX/Linux]
29
+ * `:windows_installer` - A regular Windows installer [creation on Windows only and requires InnoSetup to be installed]
30
+ * `:windows_standalone` - Standalone EXE file that self-extracts to a temporary directory - slower startup than the other Windows options [creation on Windows only]
31
+
32
+ Archive types supported
33
+ -----------------------
34
+
35
+ Optionally, release folders can be archived using one or more of:
36
+
37
+ * `:dmg` - OS X self-extractor (.dmg - requires `hdiutil` to be installed, so only available on OS X)
38
+ * `:exe` - Windows self-extractor (.exe - Includes a 7z decompression module, so not efficient for small releases)
39
+ * `:"7z"` - 7Zip format (.7z - Best compression)
40
+ * `:tar_bz2` - BZip2 tarball (.tar.bz2)
41
+ * `:tar_gz` - GZip tarball (.tar.gz)
42
+ * `:zip` - Standard zip format (.zip - Poor compression, but best compatibility)
43
+
44
+ Example
45
+ -------
46
+
47
+ ### Project's Rakefile
48
+
49
+ # Example is from my game, Alpha Channel.
50
+ require 'rubygems'
51
+ require 'bundler/setup' # Releasy doesn't require that your application uses bundler, but it does make things easier.
52
+ require 'releasy'
53
+ require 'lib/alpha_channel/version'
54
+
55
+ #<<<
56
+ Releasy::Project.new do
57
+ name "Alpha Channel"
58
+ version AlphaChannel::VERSION
59
+
60
+ executable "bin/alpha_channel.rbw"
61
+ files `git ls-files`.split("\n")
62
+ files.exclude '.gitignore'
63
+
64
+ exposed_files ["README.html", "LICENSE.txt"]
65
+ add_link "http://spooner.github.com/games/alpha_channel", "Alpha Channel website"
66
+
67
+ # Create a variety of releases, for all platforms.
68
+ add_build :osx_app do
69
+ add_archive :tar_gz
70
+ url "com.github.spooner.games.alpha_channel"
71
+ wrapper "../osx_app/gosu-mac-wrapper-0.7.41.tar.gz"
72
+ icon "media/icon.icns"
73
+ end
74
+
75
+ add_build :source
76
+
77
+ add_build :windows_folder do
78
+ icon "media/icon.ico"
79
+ add_archive :exe
80
+ exclude_encoding
81
+ end
82
+
83
+ add_build :windows_installer do
84
+ icon "media/icon.ico"
85
+ exclude_encoding
86
+ start_menu_group "Spooner Games"
87
+ readme "README.html" # User asked if they want to view readme after install.
88
+ license "LICENSE.txt" # User asked to read this and confirm before installing.
89
+ end
90
+
91
+ add_archive :zip # All outputs given this archive format.
92
+ end
93
+ #>>>
94
+
95
+ ### Tasks created
96
+
97
+ Note: The `windows:folder`, `windows:installer` and `windows:standalone` will be created only if running on Windows.
98
+ The `windows:folder_from_ruby_dist` task will not be created if running on Windows.
99
+
100
+ rake build # Build all outputs
101
+ rake build:osx # Build all osx outputs
102
+ rake build:osx:app # Build OS X app
103
+ rake build:source # Build source folder
104
+ rake build:windows # Build all Windows outputs
105
+ rake build:windows:folder # Build source/exe folder 1.4.0
106
+ rake build:windows:installer # Build installer 1.4.0 [Innosetup]
107
+ rake package # Package all
108
+ rake package:osx # Package all OS X
109
+ rake package:osx:app # Package all :osx_app
110
+ rake package:osx:app:tar_gz # Create pkg/alpha_channel_1_4_0_OSX.tar.gz
111
+ rake package:osx:app:zip # Create pkg/alpha_channel_1_4_0_OSX.zip
112
+ rake package:source # Package all :source
113
+ rake package:source:zip # Create pkg/alpha_channel_1_4_0_SOURCE.zip
114
+ rake package:windows # Package all Windows outputs
115
+ rake package:windows:folder # Package all :windows_folder outputs
116
+ rake package:windows:folder:exe # Create pkg/alpha_channel_1_4_0_WIN32.exe
117
+ rake package:windows:folder:zip # Create pkg/alpha_channel_1_4_0_WIN32.zip
118
+ rake package:windows:installer # Package all :windows_installer
119
+ rake package:windows:installer:zip # Create pkg/alpha_channel_1_4_0_WIN32_I...
120
+
121
+ CLI Commands
122
+ ------------
123
+
124
+ Releasy also provides some supplementary commands:
125
+
126
+ * `releasy install-sfx [options]` - Installs a copy of the Windows self-extractor in the local 7z installation, to allow use of the `:exe` archive format (it comes with the Windows version of 7z, so only need to use this command on OS X/Linux).
127
+
128
+
129
+ External Requirements (Optional, but recommended)
130
+ --------------------------------
131
+
132
+ ### To create package archives (except `:dmg`)
133
+
134
+ [7z](http://www.7-zip.org) must be installed.
135
+
136
+ - Installing on OS X homebrew:
137
+
138
+ <pre>brew install p7zip</pre>
139
+
140
+ - Installing on Ubuntu/Debian:
141
+
142
+ <pre>sudo apt-get install p7zip-full</pre>
143
+
144
+ - Installing on Windows (or other OS)
145
+
146
+ * [Download](http://www.7-zip.org/download.html)
147
+
148
+ ### To create `:windows_installer` output (Windows only)
149
+
150
+ [InnoSetup](http://www.jrsoftware.org/isdl.php) must be installed.
151
+
152
+ Credits
153
+ -------
154
+
155
+ * Thanks to jlnr for creating "RubyGosu App.app", an OS X application bundle used to wrap application code.
156
+ * Thanks to larsh for the [Ocra gem](http://ocra.rubyforge.org/), which is used for generating Win32 executables.
157
+ * Thanks to jlnr and shawn42 for help testing on OS X; without you I would have been screwed!
158
+ * Thanks to shawn42 and everyone at #gosu and #rubylang for suggestions on how to improve the API.
159
+ * Thanks to kyrylo for coming up with the name, Releasy!
160
+
161
+ Third Party Assets included
162
+ ---------------------------
163
+
164
+ * bin/7z.sfx - Windows [7z 9.20](http://www.7-zip.org) self-extractor module [License: [GNU LGPL](http://www.7-zip.org/license.txt)]
165
+
@@ -0,0 +1,31 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup(:development)
4
+ require 'rake'
5
+ # Hack to ensure rake testtask/clean will load on Ruby 1.8.x
6
+ Gem.loaded_specs['rake'].add_self_to_load_path if RUBY_VERSION =~ /^1\.8\.\d+/
7
+ require 'rake/testtask'
8
+ require 'rake/clean'
9
+ require 'yard'
10
+
11
+ CLEAN << "test_output" # Created by running tests.
12
+
13
+ Bundler::GemHelper.install_tasks
14
+
15
+ desc "Run all tests"
16
+ task :test do
17
+ Rake::TestTask.new do |t|
18
+ t.libs << "test"
19
+ t.pattern = "test/**/*_test.rb"
20
+ t.verbose = false
21
+ end
22
+ end
23
+
24
+ YARD::Rake::YardocTask.new
25
+
26
+ desc "Run a yard server to auto-update docs"
27
+ task :yard_server do
28
+ system "bundle exec yard server --reload"
29
+ end
30
+
31
+ task :default => :test
Binary file
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require 'releasy'
5
+ require 'releasy/cli'
6
+
7
+ Releasy::Cli.run ARGV
@@ -0,0 +1,18 @@
1
+ require 'rake'
2
+
3
+ $LOAD_PATH.unshift File.expand_path("..", __FILE__)
4
+
5
+ # Application release manager.
6
+ module Releasy
7
+ def self.win_platform?; RUBY_PLATFORM =~ /mingw|win32/; end
8
+
9
+ # An error caused when Releasy configuration is incorrect or inconsistent.
10
+ class ConfigError < StandardError; end
11
+
12
+ # Modules used to extend Releasy classes.
13
+ module Mixins; end
14
+ end
15
+
16
+ require "releasy/version"
17
+ require "releasy/project"
18
+
@@ -0,0 +1,12 @@
1
+ require 'releasy/mixins/register'
2
+
3
+ module Releasy
4
+ # Contains all {Archiver} types.
5
+ module Archivers
6
+ extend Mixins::Register
7
+ end
8
+ end
9
+
10
+ %w[dmg exe seven_zip tar_bzip2 tar_gzip zip].each do |archiver|
11
+ require "releasy/archivers/#{archiver}"
12
+ end
@@ -0,0 +1,74 @@
1
+ require 'digest/md5'
2
+
3
+ require "releasy/mixins/exec"
4
+
5
+ module Releasy
6
+ module Archivers
7
+ # Archives a build folder.
8
+ #
9
+ # @abstract
10
+ class Archiver
11
+ include Rake::DSL
12
+ include Mixins::Exec
13
+
14
+ MD5_READ_SIZE = 128 * 64 # MD5 likes 128 byte chunks.
15
+
16
+ # @return [Project] Project this Archiver was created by.
17
+ attr_reader :project
18
+ # @return [String] Extension of archive to be created (such as ".zip").
19
+ attr_accessor :extension
20
+
21
+ def type; self.class::TYPE; end
22
+
23
+ def initialize(project)
24
+ @project = project
25
+ @extension = self.class::DEFAULT_EXTENSION
26
+ end
27
+
28
+ protected
29
+ # Generate tasks to create the archive of this file.
30
+ def generate_tasks(output_task, folder)
31
+ pkg = package folder
32
+
33
+ desc "Create #{pkg}"
34
+ task "package:#{output_task}:#{type}" => pkg
35
+
36
+ file pkg => folder do
37
+ archive folder
38
+ end
39
+ end
40
+
41
+ protected
42
+ def archive(folder)
43
+ pkg = package folder
44
+ Rake::FileUtilsExt.verbose project.verbose?
45
+
46
+ puts "Creating #{pkg}" if project.verbose?
47
+ rm pkg if File.exist? pkg
48
+ cd project.output_path do
49
+ exec command(File.basename folder)
50
+ end
51
+
52
+ File.open("#{pkg}.MD5", "w") {|f| f.puts checksum(pkg) } if project.send :create_md5s?
53
+ end
54
+
55
+ protected
56
+ def package(folder); "#{folder}#{extension[0, 1] == '.' ? '' : '.'}#{extension}"; end
57
+
58
+ protected
59
+ def command(folder)
60
+ %[7z a -mmt -bd -t#{type} -mx9 "#{package(folder)}" "#{folder}"]
61
+ end
62
+
63
+ protected
64
+ def checksum(filename)
65
+ digest = Digest::MD5.new
66
+ File.open(filename, "rb") do |file|
67
+ digest << file.read(MD5_READ_SIZE) until file.eof?
68
+ end
69
+
70
+ digest.hexdigest
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,18 @@
1
+ require "releasy/archivers/archiver"
2
+
3
+ module Releasy
4
+ module Archivers
5
+ # OS X .dmg format (self-extractor).
6
+ class Dmg < Archiver
7
+ TYPE = :dmg
8
+ DEFAULT_EXTENSION = ".dmg"
9
+
10
+ Archivers.register self
11
+
12
+ protected
13
+ def command(folder)
14
+ %[GZIP=-9 hdiutil create -fs HFS+ -srcfolder "#{folder}" -volname "#{project.name} #{project.version}" "#{package(folder)}"]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+ require "releasy/archivers/archiver"
2
+
3
+ module Releasy
4
+ module Archivers
5
+ # Windows self-extracting archive.
6
+ #
7
+ # If not on Windows, run "releasy install-sfx" after installing 7z, before you can use this.
8
+ class Exe < Archiver
9
+ TYPE = :exe
10
+ DEFAULT_EXTENSION = ".exe"
11
+
12
+ SFX_NAME = "7z.sfx"
13
+ SFX_FILE = File.expand_path("../../../../bin/#{SFX_NAME}", __FILE__)
14
+
15
+ Archivers.register self
16
+
17
+ protected
18
+ def command(folder)
19
+ %[7z a -mmt -bd -t7z -mx9 -sfx#{SFX_NAME} "#{package(folder)}" "#{folder}"]
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,12 @@
1
+ require "releasy/archivers/archiver"
2
+
3
+ module Releasy
4
+ module Archivers
5
+ # 7z archive format (LZMA)
6
+ class SevenZip < Archiver
7
+ TYPE = :"7z"
8
+ DEFAULT_EXTENSION = ".7z"
9
+ Archivers.register self
10
+ end
11
+ end
12
+ end