-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9b88c1
commit d00d654
Showing
4 changed files
with
92 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
# This file was generated by release.py | ||
require 'formula' | ||
|
||
class Pup < Formula | ||
homepage 'https://github.com/EricChiang/pup' | ||
version '0.3.5' | ||
version '0.3.6' | ||
|
||
if Hardware.is_64_bit? | ||
url 'https://github.com/EricChiang/pup/releases/download/v0.3.5/pup_darwin_amd64.zip' | ||
sha1 '6991dc9408e02adfa0ed5866eb7e284a94d79a77' | ||
url 'https://github.com/EricChiang/pup/releases/download/v0.3.6/pup_darwin_amd64.zip' | ||
sha1 '549ce1c7e3ad5ec0129fa46736821676ebb797a1' | ||
else | ||
url 'https://github.com/EricChiang/pup/releases/download/v0.3.5/pup_darwin_386.zip' | ||
sha1 'ec58d15a39ab821caa5f903035862690bbeb4dfe' | ||
url 'https://github.com/EricChiang/pup/releases/download/v0.3.6/pup_darwin_386.zip' | ||
sha1 '3738b27bb47bfe4bb7bd682fd93ac8701f323264' | ||
end | ||
|
||
def install | ||
bin.install 'pup' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env python | ||
|
||
import hashlib | ||
import os | ||
import re | ||
import shutil | ||
import subprocess as sp | ||
|
||
from string import Template | ||
from zipfile import ZipFile | ||
|
||
brew_formula_template = Template(""" | ||
# This file was generated by release.py | ||
require 'formula' | ||
class Pup < Formula | ||
homepage 'https://github.com/EricChiang/pup' | ||
version '${version}' | ||
if Hardware.is_64_bit? | ||
url 'https://github.com/EricChiang/pup/releases/download/v${version}/pup_darwin_amd64.zip' | ||
sha1 '${darwin_amd64_sha1}' | ||
else | ||
url 'https://github.com/EricChiang/pup/releases/download/v${version}/pup_darwin_386.zip' | ||
sha1 '${darwin_386_sha1}' | ||
end | ||
def install | ||
bin.install 'pup' | ||
end | ||
end | ||
""".strip()) | ||
|
||
version_re = re.compile(r'\nvar VERSION string = \"([0-9\.]+)\"\n') | ||
|
||
if __name__ == "__main__": | ||
with open("pup.go", "r") as f: | ||
version = version_re.findall(f.read()) | ||
|
||
assert len(version) == 1, "[-] Failed to find current version %s" % (version,) | ||
version = version[0] | ||
print "[+] Version found:", version | ||
|
||
if os.path.isdir("./dist"): | ||
print "[+] Directory 'dist' exists. Removing it." | ||
shutil.rmtree("./dist") | ||
|
||
print "[+] Cross-compiling pup." | ||
sp.check_call(["gox", "-output", "dist/{{.Dir}}_{{.OS}}_{{.Arch}}"]) | ||
|
||
print "[+] Zipping executables." | ||
sha1sums = {} | ||
for fi in os.listdir("./dist"): | ||
exe = os.path.join("dist", "pup") | ||
zipname = os.path.join("dist", fi) | ||
if fi.endswith(".exe"): | ||
exe += ".exe" | ||
zipname = zipname.rstrip(".exe") | ||
zipname += ".zip" | ||
os.rename(os.path.join("dist", fi), exe) | ||
with ZipFile(zipname, "w") as z: | ||
z.write(exe, os.path.basename(exe)) | ||
os.remove(exe) | ||
h = hashlib.sha1() | ||
with open(zipname, "r") as z: | ||
h.update(z.read()) | ||
sha1sum = h.hexdigest() | ||
print "[+] %s: %s" % (sha1sum, zipname,) | ||
sha1sums[zipname] = sha1sum | ||
|
||
t = brew_formula_template.substitute( | ||
version=version, | ||
darwin_amd64_sha1 = sha1sums["dist/pup_darwin_amd64.zip"], | ||
darwin_386_sha1 = sha1sums["dist/pup_darwin_386.zip"], | ||
) | ||
print "[+] Updating brew formula." | ||
with open("pup.rb", "w") as f: | ||
f.write(t) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters