Skip to content

Commit d00d654

Browse files
committed
release scripts cleaned up
1 parent c9b88c1 commit d00d654

File tree

4 files changed

+92
-38
lines changed

4 files changed

+92
-38
lines changed

pup.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1+
# This file was generated by release.py
12
require 'formula'
2-
33
class Pup < Formula
44
homepage 'https://github.com/EricChiang/pup'
5-
version '0.3.5'
5+
version '0.3.6'
66

77
if Hardware.is_64_bit?
8-
url 'https://github.com/EricChiang/pup/releases/download/v0.3.5/pup_darwin_amd64.zip'
9-
sha1 '6991dc9408e02adfa0ed5866eb7e284a94d79a77'
8+
url 'https://github.com/EricChiang/pup/releases/download/v0.3.6/pup_darwin_amd64.zip'
9+
sha1 '549ce1c7e3ad5ec0129fa46736821676ebb797a1'
1010
else
11-
url 'https://github.com/EricChiang/pup/releases/download/v0.3.5/pup_darwin_386.zip'
12-
sha1 'ec58d15a39ab821caa5f903035862690bbeb4dfe'
11+
url 'https://github.com/EricChiang/pup/releases/download/v0.3.6/pup_darwin_386.zip'
12+
sha1 '3738b27bb47bfe4bb7bd682fd93ac8701f323264'
1313
end
1414

1515
def install
1616
bin.install 'pup'
1717
end
18-
end
18+
end

release.py

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env python
2+
3+
import hashlib
4+
import os
5+
import re
6+
import shutil
7+
import subprocess as sp
8+
9+
from string import Template
10+
from zipfile import ZipFile
11+
12+
brew_formula_template = Template("""
13+
# This file was generated by release.py
14+
require 'formula'
15+
class Pup < Formula
16+
homepage 'https://github.com/EricChiang/pup'
17+
version '${version}'
18+
19+
if Hardware.is_64_bit?
20+
url 'https://github.com/EricChiang/pup/releases/download/v${version}/pup_darwin_amd64.zip'
21+
sha1 '${darwin_amd64_sha1}'
22+
else
23+
url 'https://github.com/EricChiang/pup/releases/download/v${version}/pup_darwin_386.zip'
24+
sha1 '${darwin_386_sha1}'
25+
end
26+
27+
def install
28+
bin.install 'pup'
29+
end
30+
end
31+
""".strip())
32+
33+
version_re = re.compile(r'\nvar VERSION string = \"([0-9\.]+)\"\n')
34+
35+
if __name__ == "__main__":
36+
with open("pup.go", "r") as f:
37+
version = version_re.findall(f.read())
38+
39+
assert len(version) == 1, "[-] Failed to find current version %s" % (version,)
40+
version = version[0]
41+
print "[+] Version found:", version
42+
43+
if os.path.isdir("./dist"):
44+
print "[+] Directory 'dist' exists. Removing it."
45+
shutil.rmtree("./dist")
46+
47+
print "[+] Cross-compiling pup."
48+
sp.check_call(["gox", "-output", "dist/{{.Dir}}_{{.OS}}_{{.Arch}}"])
49+
50+
print "[+] Zipping executables."
51+
sha1sums = {}
52+
for fi in os.listdir("./dist"):
53+
exe = os.path.join("dist", "pup")
54+
zipname = os.path.join("dist", fi)
55+
if fi.endswith(".exe"):
56+
exe += ".exe"
57+
zipname = zipname.rstrip(".exe")
58+
zipname += ".zip"
59+
os.rename(os.path.join("dist", fi), exe)
60+
with ZipFile(zipname, "w") as z:
61+
z.write(exe, os.path.basename(exe))
62+
os.remove(exe)
63+
h = hashlib.sha1()
64+
with open(zipname, "r") as z:
65+
h.update(z.read())
66+
sha1sum = h.hexdigest()
67+
print "[+] %s: %s" % (sha1sum, zipname,)
68+
sha1sums[zipname] = sha1sum
69+
70+
t = brew_formula_template.substitute(
71+
version=version,
72+
darwin_amd64_sha1 = sha1sums["dist/pup_darwin_amd64.zip"],
73+
darwin_386_sha1 = sha1sums["dist/pup_darwin_386.zip"],
74+
)
75+
print "[+] Updating brew formula."
76+
with open("pup.rb", "w") as f:
77+
f.write(t)

release.sh

-23
This file was deleted.

tests/expected_output.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
c00fef10d36c1166cb5ac886f9d25201b720e37e #footer
22
a7bb8dbfdd638bacad0aa9dc3674126d396b74e2 #footer li
3-
06fb3f64027084bbe52af06951aeea7d2750dcff #footer li + a
4-
da788c5138342d0228bfc86976bd9202419e43a6 #footer li + a attr{title}
5-
8edb39cbf74ed66687c4eb4e0abfe36153c186a8 #footer li > li
3+
da39a3ee5e6b4b0d3255bfef95601890afd80709 #footer li + a
4+
da39a3ee5e6b4b0d3255bfef95601890afd80709 #footer li + a attr{title}
5+
da39a3ee5e6b4b0d3255bfef95601890afd80709 #footer li > li
66
a92e50c09cd56970625ac3b74efbddb83b2731bb table li
77
505c04a42e0084cd95560c233bd3a81b2c59352d table li:first-child
88
505c04a42e0084cd95560c233bd3a81b2c59352d table li:first-of-type
@@ -32,12 +32,12 @@ a55bb21d37fbbd3f8f1b551126795fbc733451fe :only-child
3232
641037814e358487d1938fc080e08f72a3846ef8 [class=summary]
3333
641037814e358487d1938fc080e08f72a3846ef8 [class="summary"]
3434
613bf65ac4042b6ee0a7a47f08732fdbe1b5b06b #toc
35-
dbc580de40eeb8448f0dbe1b98d74cf799a6868b #toc li + a
36-
6a2c6153bce7945b88d7c818fe11aaae232725b3 #toc li + a text{}
37-
91f36a7072f0740b170eeaac01b0be00ec528664 #toc li + a json{}
38-
0cd687baaf08605bf6a68e3c285c5e8a41e0c9b2 #toc li + a + span
35+
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li + a
36+
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li + a text{}
37+
97d170e1550eee4afc0af065b78cda302a97674c #toc li + a json{}
38+
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li + a + span
3939
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li + span
40-
5d6e3ed3cfe310cde185cbfe1bba6aa7ec2a7f8d #toc li > li
40+
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li > li
4141
87eee1189dd5296d6c010a1ad329fc53c6099d72 li a:not([rel])
4242
055f3c98e9160beb13f72f1009ad66b6252a9bba link, a
4343
055f3c98e9160beb13f72f1009ad66b6252a9bba link ,a

0 commit comments

Comments
 (0)