Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #5 from schacon/master
Browse files Browse the repository at this point in the history
Use script to upload binary to github
  • Loading branch information
timcharper committed May 6, 2012
2 parents 58b0f9c + 2587e91 commit 28de9d7
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Disk Image/README.txt
Expand Up @@ -2,7 +2,7 @@ Git OSX Installer
================= =================
================= =================


http://code.google.com/p/git-osx-installer/ https://github.com/timcharper/git-osx-installer/




INSTALLATION INSTALLATION
Expand Down
8 changes: 4 additions & 4 deletions build_package_test_and_bundle.sh
Expand Up @@ -26,7 +26,7 @@ echo "Testing the installer..."


. test_installer.sh . test_installer.sh


echo "Git Installer $GIT_VERSION - OS X - Snow Leopard - Intel Universal" | pbcopy echo "To upload build, run:"
open "http://code.google.com/p/git-osx-installer/downloads/entry" echo
sleep 1 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'"
open "./"
53 changes: 53 additions & 0 deletions 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

0 comments on commit 28de9d7

Please sign in to comment.