Skip to content

Commit 57f1dee

Browse files
committed
Release script: Use 'make allplatforms'
Instead of relying on gox. Parallel builds aren't really necessary.
1 parent 6271c0f commit 57f1dee

File tree

1 file changed

+19
-32
lines changed

1 file changed

+19
-32
lines changed

dorelease.py

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
ETAGFILE = os.path.join(DESTDIR, "etags")
2828
ETAGS = {}
2929

30-
VERSION = {}
30+
VERSION = ""
3131

3232

3333
def run(cmd, **kwargs):
@@ -113,37 +113,23 @@ def build():
113113
"""
114114
Build binaries.
115115
"""
116-
platforms = ["linux/amd64", "windows/386", "windows/amd64", "darwin/amd64"]
117-
print(f"--> Building binary for {', '.join(platforms)}")
116+
run(["make", "clean"]) # clean before build
117+
cmd = ["make", "allplatforms"]
118118
verfilename = "version"
119119
with open(verfilename) as verfile:
120120
verinfo = verfile.read()
121121

122-
VERSION["version"] = re.search(r"version=(.*)", verinfo).group(1)
123-
cmd = ["git", "rev-list", "--count", "HEAD"]
124-
VERSION["build"] = int(check_output(cmd).strip().decode())
125-
cmd = ["git", "rev-parse", "HEAD"]
126-
VERSION["commit"] = check_output(cmd).strip().decode()
127-
print(("Version: {version} "
128-
"Build: {build:06d} "
129-
"Commit: {commit}").format(**VERSION))
130-
ldflags = ("-X main.gincliversion={version} "
131-
"-X main.build={build:06d} "
132-
"-X main.commit={commit}").format(**VERSION)
133-
output = os.path.join(DESTDIR, "{{.OS}}-{{.Arch}}", "gin")
134-
cmd = [
135-
"gox", f"-output={output}",
136-
f"-osarch={' '.join(platforms)}", f"-ldflags={ldflags}"
137-
]
122+
global VERSION
123+
VERSION = re.search(r"version=(.*)", verinfo).group(1)
138124
print(f"Running {' '.join(cmd)}")
139125
if run(cmd) > 0:
140126
die("Build failed")
141127

142128
print()
143129
print("--> Build succeeded")
144130
print("--> The following files were built:")
145-
ginfiles = glob(os.path.join(DESTDIR, "*", "gin"))
146-
ginfiles.extend(glob(os.path.join(DESTDIR, "*", "gin.exe")))
131+
ginfiles = glob(os.path.join("build", "*", "gin"))
132+
ginfiles.extend(glob(os.path.join("build", "*", "gin.exe")))
147133
print("\n".join(ginfiles), end="\n\n")
148134

149135
plat = sys.platform
@@ -216,7 +202,7 @@ def package_linux_plain(binfile):
216202
_, osarch = os.path.split(dirname)
217203
# simple binary archive
218204
shutil.copy("README.md", dirname)
219-
arc = f"gin-cli-{VERSION['version']}-{osarch}.tar.gz"
205+
arc = f"gin-cli-{VERSION}-{osarch}.tar.gz"
220206
archive = os.path.join(PKGDIR, arc)
221207
cmd = ["tar", "-czf", archive, "-C", dirname, fname, "README.md"]
222208
print(f"Running {' '.join(cmd)}")
@@ -265,7 +251,7 @@ def docker_cleanup():
265251

266252
# create directory structure
267253
pkgname = "gin-cli"
268-
pkgnamever = f"{pkgname}-{VERSION['version']}"
254+
pkgnamever = f"{pkgname}-{VERSION}"
269255
debmdsrc = os.path.join("debdock", "debian")
270256
pkgdir = os.path.join(tmpdir, pkgname)
271257
debcapdir = os.path.join(pkgdir, "DEBIAN")
@@ -301,7 +287,7 @@ def docker_cleanup():
301287
# Adding version number to debian control file
302288
controlpath = os.path.join(debcapdir, "control")
303289
with open(controlpath) as controlfile:
304-
controllines = controlfile.read().format(**VERSION)
290+
controllines = controlfile.read().format(version=VERSION)
305291

306292
with open(controlpath, "w") as controlfile:
307293
controlfile.write(controllines)
@@ -361,7 +347,7 @@ def package_mac_plain(binfile):
361347
osarch = osarch.replace("darwin", "macos")
362348
# simple binary archive
363349
shutil.copy("README.md", dirname)
364-
archive = f"gin-cli-{VERSION['version']}-{osarch}.tar.gz"
350+
archive = f"gin-cli-{VERSION}-{osarch}.tar.gz"
365351
archive = os.path.join(PKGDIR, archive)
366352
cmd = ["tar", "-czf", archive, "-C", dirname, fname, "README.md"]
367353
print(f"Running {' '.join(cmd)}")
@@ -407,8 +393,8 @@ def package_mac_bundle(binfile, annex_tar):
407393

408394
with open("./macapp/gin-Info.plist", "rb") as plistfile:
409395
info = plistlib.load(plistfile, fmt=plistlib.FMT_XML)
410-
info["CFBundleVersion"] = VERSION["version"]
411-
info["CFBundleShortVersionString"] = VERSION["version"]
396+
info["CFBundleVersion"] = VERSION
397+
info["CFBundleShortVersionString"] = VERSION
412398
# info["CFBundleExecutable"] = "runshell"
413399
with open(os.path.join(ginapproot, "Contents", "Info.plist"),
414400
"wb") as plistfile:
@@ -418,7 +404,7 @@ def package_mac_bundle(binfile, annex_tar):
418404
_, osarch = os.path.split(dirname)
419405
osarch = osarch.replace("darwin", "macos")
420406

421-
archive = f"gin-cli-{VERSION['version']}-{osarch}-bundle.tar.gz"
407+
archive = f"gin-cli-{VERSION}-{osarch}-bundle.tar.gz"
422408
archive = os.path.join(PKGDIR, archive)
423409
print("Creating macOS bundle")
424410
if os.path.exists(archive):
@@ -481,7 +467,7 @@ def winbundle(binfile, git_pkg, annex_pkg):
481467
dirname, _ = os.path.split(binfile)
482468
_, osarch = os.path.split(dirname)
483469

484-
arc = f"gin-cli-{VERSION['version']}-{osarch}.zip"
470+
arc = f"gin-cli-{VERSION}-{osarch}.zip"
485471
arc = os.path.join(PKGDIR, arc)
486472
print("Creating Windows zip file")
487473
# need to change paths before making zip file
@@ -536,6 +522,7 @@ def main():
536522
print(f"Linux: {len(linux_bins)}")
537523
print(f"Windows: {len(win_bins)}")
538524
print(f"macOS: {len(darwin_bins)}")
525+
sys.exit(1)
539526

540527
# package stuff
541528
linux_pkg = package_linux_plain(linux_bins[0])
@@ -546,8 +533,8 @@ def main():
546533
mac_pkg = package_mac_plain(darwin_bins[0])
547534
mac_bundle = package_mac_bundle(darwin_bins[0], mac_annex_tar)
548535

549-
win_bin_32 = [wb for wb in win_bins if "386" in wb][0]
550-
win_bin_64 = [wb for wb in win_bins if "amd64" in wb][0]
536+
win_bin_32 = [wb for wb in win_bins if "windows32" in wb][0]
537+
win_bin_64 = [wb for wb in win_bins if "windows64" in wb][0]
551538
win_git_32 = [wg for wg in win_git_files if "32-bit" in wg][0]
552539
win_git_64 = [wg for wg in win_git_files if "64-bit" in wg][0]
553540

@@ -559,7 +546,7 @@ def link_latest(fname):
559546
Create symlinks with the version part replaced by 'latest' for the
560547
newly built package.
561548
"""
562-
latestname = fname.replace(VERSION["version"], "latest")
549+
latestname = fname.replace(VERSION, "latest")
563550
print(f"Linking {fname} to {latestname}")
564551
if os.path.lexists(latestname):
565552
os.unlink(latestname)

0 commit comments

Comments
 (0)