Skip to content

Instantly share code, notes, and snippets.

@slfrsn
Last active December 15, 2015 11:43
Show Gist options
  • Save slfrsn/948f8594956cca940b04 to your computer and use it in GitHub Desktop.
Save slfrsn/948f8594956cca940b04 to your computer and use it in GitHub Desktop.
Creates a clean GitHub release archive using Automator to exclude .git files and folders.

Creating GitHub Release Archives with Automator

This script creates a clean GitHub release archive using Automator to exclude .git files and folders. To use this:

1. Create a new application in Automator
2. Add a Run AppleScript action to the workflow
3. Paste in the following code:

on run {input}
	set projectpath to POSIX path of (input as string)
	set projectparent to POSIX path of ((do shell script "dirname " & quoted form of projectpath) as string)
	set excludedfiles to "*.git* *.DS_Store*"
	
	-- Return the last path component (to get the project folder name)
	if projectpath is "/" then return "/"
	if item -1 of projectpath is "/" then set projectpath to text 1 thru -2 of projectpath
	set text item delimiters to "/"
	set projectname to text item -1 of projectpath
	
	-- Change working directory to project parent and create archive
	do shell script "cd \"" & projectparent & "\"; zip -r " & projectname & ".zip \"" & projectname & "\" -x " & excludedfiles
	return input
end run

4. Save as an application

All you have to do now is drag and drop the project folder onto the application.

Tested in OS X 10.11 beta 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment