release scripts cleaned up

pull/32/head
ericchiang 10 years ago
parent c9b88c1354
commit d00d65425a

@ -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

@ -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)

@ -1,23 +0,0 @@
#!/bin/bash
set -e
rm -f dist/*
gox -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}"
cd dist
for file in `ls`; do
if [[ $file == *.exe ]]
then
mv $file pup.exe
file=${file%.exe}
zip $file pup.exe
rm pup.exe
else
mv $file pup
zip $file pup
rm pup
fi
done

@ -1,8 +1,8 @@
c00fef10d36c1166cb5ac886f9d25201b720e37e #footer
a7bb8dbfdd638bacad0aa9dc3674126d396b74e2 #footer li
06fb3f64027084bbe52af06951aeea7d2750dcff #footer li + a
da788c5138342d0228bfc86976bd9202419e43a6 #footer li + a attr{title}
8edb39cbf74ed66687c4eb4e0abfe36153c186a8 #footer li > li
da39a3ee5e6b4b0d3255bfef95601890afd80709 #footer li + a
da39a3ee5e6b4b0d3255bfef95601890afd80709 #footer li + a attr{title}
da39a3ee5e6b4b0d3255bfef95601890afd80709 #footer li > li
a92e50c09cd56970625ac3b74efbddb83b2731bb table li
505c04a42e0084cd95560c233bd3a81b2c59352d table li:first-child
505c04a42e0084cd95560c233bd3a81b2c59352d table li:first-of-type
@ -32,12 +32,12 @@ a55bb21d37fbbd3f8f1b551126795fbc733451fe :only-child
641037814e358487d1938fc080e08f72a3846ef8 [class=summary]
641037814e358487d1938fc080e08f72a3846ef8 [class="summary"]
613bf65ac4042b6ee0a7a47f08732fdbe1b5b06b #toc
dbc580de40eeb8448f0dbe1b98d74cf799a6868b #toc li + a
6a2c6153bce7945b88d7c818fe11aaae232725b3 #toc li + a text{}
91f36a7072f0740b170eeaac01b0be00ec528664 #toc li + a json{}
0cd687baaf08605bf6a68e3c285c5e8a41e0c9b2 #toc li + a + span
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li + a
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li + a text{}
97d170e1550eee4afc0af065b78cda302a97674c #toc li + a json{}
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li + a + span
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li + span
5d6e3ed3cfe310cde185cbfe1bba6aa7ec2a7f8d #toc li > li
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li > li
87eee1189dd5296d6c010a1ad329fc53c6099d72 li a:not([rel])
055f3c98e9160beb13f72f1009ad66b6252a9bba link, a
055f3c98e9160beb13f72f1009ad66b6252a9bba link ,a

Loading…
Cancel
Save