Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby Thor snippet to package code on OSX
desc "osx", "create distribution package for Mac OS X"
method_option :dmg, :type => :boolean, :desc => "Create a DMG container instead of a zip file"
def osx
set_instance_variables
# clean staging folder
clean
osx_copy_to_staging(@product)
# get version info directly from JSON in staging folder in case this was build off a different version
version_filename = File.join(STAGING_FOLDER, @product, 'version.txt')
version = read_version_string(version_filename)
label = options[:label]
label = read_version_label(@product, version_filename) unless label
label = ".#{label}" if label
if options[:dmg]
# create the dmg file
source = File.join(STAGING_FOLDER, @product, "#{@product}.app".capitalize)
destination = "#{PKG_FOLDER}/#{@product}.#{version}.osx#{label}.dmg"
remove_file(destination)
run("hdiutil create #{destination} -volname #{@product} -size 200m -fs HFS+ -srcfolder #{source}")
else
source = File.join(STAGING_FOLDER, @product)
destination = "#{PKG_FOLDER}/#{@product}.#{version}.osx#{label}.zip"
remove_file(destination)
run "7za a -mx9 #{destination} #{source}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment