Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #5 from schacon/master

Use script to upload binary to github
  • Loading branch information...
commit 28de9d74b7d19fbc7683ddfd03578ce5c669ba98 2 parents 58b0f9c + 2587e91
@timcharper authored
View
2  Disk Image/README.txt
@@ -2,7 +2,7 @@ Git OSX Installer
=================
=================
-http://code.google.com/p/git-osx-installer/
+https://github.com/timcharper/git-osx-installer/
INSTALLATION
View
8 build_package_test_and_bundle.sh
@@ -26,7 +26,7 @@ echo "Testing the installer..."
. test_installer.sh
-echo "Git Installer $GIT_VERSION - OS X - Snow Leopard - Intel Universal" | pbcopy
-open "http://code.google.com/p/git-osx-installer/downloads/entry"
-sleep 1
-open "./"
+echo "To upload build, run:"
+echo
+echo "./upload-to-github.rb timcharper timcharper/git-osx-installer Disk\ Image/$PACKAGE_NAME.pkg 'Git Installer $GIT_VERSION - OS X - Snow Leopard - Intel Universal'"
+
View
53 upload-to-github.rb
@@ -0,0 +1,53 @@
+#! /usr/bin/env ruby
+#
+# ruby upload-to-github.rb user user/repo file '(description)'
+#
+
+require 'rubygems'
+require 'json'
+
+if ARGV.size < 3
+ puts "\nUSAGE: upload-to-github.rb [user] [user/repo] [filepath] ('description')"
+ exit
+end
+
+user = ARGV[0]
+repo = ARGV[1]
+file = ARGV[2]
+desc = ARGV[3] rescue ''
+
+def url(path)
+ "https://api.github.com#{path}"
+end
+
+size = File.size(file)
+fname = File.basename(file)
+
+pass=`git gui--askpass "Password for #{user}"`.chomp
+
+# create entry
+args =
+data = `curl -s -XPOST -d '{"name":"#{fname}","size":#{size},"description":"#{desc}"}' -u "#{user}:#{pass}" #{url("/repos/#{repo}/downloads")}`
+data = JSON.parse(data)
+
+# upload file to bucket
+cmd = "curl -s "
+cmd += "-F \"key=#{data['path']}\" "
+cmd += "-F \"acl=#{data['acl']}\" "
+cmd += "-F \"success_action_status=201\" "
+cmd += "-F \"Filename=#{data['name']}\" "
+cmd += "-F \"AWSAccessKeyId=#{data['accesskeyid']}\" "
+cmd += "-F \"Policy=#{data['policy']}\" "
+cmd += "-F \"Signature=#{data['signature']}\" "
+cmd += "-F \"Content-Type=#{data['mime_type']}\" "
+cmd += "-F \"file=@#{file}\" "
+cmd += "https://github.s3.amazonaws.com/"
+
+xml = `#{cmd}`
+
+if m = /\<Location\>(.*)\<\/Location\>/.match(xml)
+ puts "Your file is uploaded to:"
+ puts m[1].gsub('%2F', '/') # not sure i want to fully URL decode this, but these will not do
+else
+ puts "Upload failed. Response is:\n\n #{xml}"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.