Skip to content

Commit befd589

Browse files
oxr463cs01
andauthored
build binaries with github actions (#334)
Bug: #331 * Create release.yml * Update contributing.md * make build verification more strict * change name and set nox session to non-interactive Co-authored-by: Chad Smith <[email protected]>
1 parent 63e3b44 commit befd589

File tree

7 files changed

+172
-37
lines changed

7 files changed

+172
-37
lines changed

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: "Build gdbgui executables"
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
ubuntu_executable:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v1
10+
- name: Set up Python
11+
uses: actions/setup-python@v2
12+
with:
13+
python-version: "3.8"
14+
- name: Install dependencies
15+
run: |
16+
python -m pip install --upgrade pip
17+
python -m pip install nox
18+
- name: Compile linux gdbgui executable
19+
run: |
20+
nox --non-interactive --session build_executable_linux
21+
- name: Upload linux executable
22+
if: github.ref == 'refs/heads/master'
23+
uses: actions/upload-artifact@v1
24+
with:
25+
name: gdbgui_linux
26+
path: ./executable/linux
27+
28+
mac_executable:
29+
runs-on: macos-latest
30+
steps:
31+
- uses: actions/checkout@v1
32+
- name: Set up Python
33+
uses: actions/setup-python@v2
34+
with:
35+
python-version: "3.8"
36+
- name: Install dependencies
37+
run: |
38+
python -m pip install --upgrade pip
39+
python -m pip install nox
40+
- name: Compile mac gdbgui executable
41+
run: |
42+
nox --non-interactive --session build_executable_mac
43+
- name: Upload mac executable
44+
if: github.ref == 'refs/heads/master'
45+
uses: actions/upload-artifact@v1
46+
with:
47+
name: gdbgui_mac
48+
path: ./executable/mac
49+
50+
windows_executable:
51+
runs-on: windows-2019
52+
steps:
53+
- uses: actions/checkout@v1
54+
- name: Set up Python
55+
uses: actions/setup-python@v2
56+
with:
57+
python-version: "3.8"
58+
- name: Install dependencies
59+
run: |
60+
python -m pip install --upgrade pip
61+
python -m pip install nox
62+
- name: Compile windows gdbgui executable
63+
run: |
64+
nox --non-interactive --session build_executable_windows
65+
- name: Upload windows executable
66+
if: github.ref == 'refs/heads/master'
67+
uses: actions/upload-artifact@v1
68+
with:
69+
name: gdbgui_windows
70+
path: ./executable/windows

docs/contributing.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,3 @@ To build macOS executable, run the following on a mac:
121121
nox -s build_executable_current_os
122122
```
123123

124-
When creating a new release, build these executables, then create a new release in GitHub and attach the binaries to the release through GitHub's UI.

docs/installation.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ pip uninstall gdbgui
6969

7070
## Method 3: Download and Run Binary Executable
7171

72-
Download and run the binary executable for your system from [https://github.com/cs01/gdbgui/tree/master/downloads](https://github.com/cs01/gdbgui/tree/master/downloads).
73-
74-
!!! Note
75-
76-
These binaries may not always have the latest version of gdbgui available since their builds are not automatic. The latest version will always be available on PyPI.
72+
Download and run the binary executable for your system from [GitHub Releases](https://github.com/cs01/gdbgui/releases).
7773

7874
## System Dependencies for Python Package
7975

make_executable.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
#!/usr/bin/env python
22

3-
43
"""
4+
Build an executable of gdbgui for the current platform
55
"""
66

77

88
import subprocess
99
from sys import platform
1010
from gdbgui import __version__
11-
import os
12-
11+
import hashlib
12+
from pathlib import Path
13+
import logging
1314

15+
logging.basicConfig(level=logging.INFO)
1416
if platform.startswith("linux"):
1517
platform_dir = "linux"
1618
elif platform.startswith("darwin"):
1719
platform_dir = "mac"
18-
elif platform.startswith("win32"):
20+
elif platform == "win32":
1921
platform_dir = "windows"
2022
else:
2123
raise Exception("Unknown platform")
2224

2325

2426
def write_spec_with_gdbgui_version_in_name(spec_path, binary_name):
2527

26-
spec = (
27-
"""# -*- mode: python -*-
28+
spec = f"""# -*- mode: python -*-
2829
2930
# create executable with: pyinstaller gdbgui.spec
3031
# run executable with: dist/gdbgui
@@ -65,36 +66,56 @@ def write_spec_with_gdbgui_version_in_name(spec_path, binary_name):
6566
a.binaries,
6667
a.zipfiles,
6768
a.datas,
68-
name="%s",
69+
name="{binary_name}",
6970
debug=False,
7071
strip=False,
7172
upx=False,
7273
runtime_tmpdir=None,
7374
console=True)
7475
7576
"""
76-
% binary_name
77-
)
7877

7978
with open(spec_path, "w+") as f:
8079
f.write(spec)
8180

8281

82+
def verify(binary_path: str, version: str):
83+
cmd = [str(binary_path), "--version"]
84+
logging.info(f"Smoke test: Running {' '.join(cmd)}")
85+
proc = subprocess.run(cmd, stdout=subprocess.PIPE)
86+
output = proc.stdout.decode().strip()
87+
if output != __version__:
88+
raise ValueError(f"Expected {__version__}. Got {output}")
89+
logging.info("Success!")
90+
91+
92+
def generate_md5(binary: Path, output_file: Path):
93+
with open(output_file, "w+") as f:
94+
f.write(hashlib.md5(str(binary).encode()).hexdigest() + "\n")
95+
logging.info(f"Wrote md5 to {output_file}")
96+
97+
8398
def main():
8499
binary_name = "gdbgui_%s" % __version__
85100
spec_path = "gdbgui.spec"
86-
write_spec_with_gdbgui_version_in_name(spec_path, binary_name)
101+
distpath = (Path("executable") / platform_dir).resolve()
102+
extension = ".exe" if platform == "win32" else ""
103+
binary_path = Path(distpath) / f"{binary_name}{extension}"
87104

88-
subprocess.call(
105+
write_spec_with_gdbgui_version_in_name(spec_path, binary_name)
106+
subprocess.run(
89107
[
90108
"pyinstaller",
91109
spec_path,
92110
"--distpath",
93-
os.path.join("executable", platform_dir),
111+
distpath,
94112
"--key",
95113
"a5s1fe65aw41f54sa64v6b4ds98fhea98rhg4etj4et78ku4yu87mn",
96114
]
97115
)
116+
verify(binary_path, __version__)
117+
generate_md5(binary_path, distpath / f"{binary_name}.md5")
118+
logging.info(f"Saved executable to {binary_path}")
98119

99120

100121
if __name__ == "__main__":

noxfile.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import nox # type: ignore
22
from pathlib import Path
3-
3+
from sys import platform
44

55
nox.options.sessions = ["tests", "lint", "docs"]
66
python = ["3.6", "3.7", "3.8"]
@@ -93,11 +93,10 @@ def develop(session):
9393
session.log("To use, run: '%s'", command)
9494

9595

96-
@nox.session(python="3.7")
9796
def build(session):
9897
session.install("setuptools", "wheel", "twine")
9998
session.run("rm", "-rf", "dist", external=True)
100-
session.run("yarn", "build")
99+
session.run("yarn", "build", external=True)
101100
session.run("python", "setup.py", "--quiet", "sdist", "bdist_wheel")
102101
session.run("twine", "check", "dist/*")
103102

@@ -121,21 +120,30 @@ def publish_docs(session):
121120
session.run("mkdocs", "gh-deploy")
122121

123122

124-
@nox.session(python="3.7")
125-
def docker_executables(session):
123+
@nox.session()
124+
def build_executable_current_platform(session):
125+
session.run("yarn", "install", external=True)
126+
session.run("yarn", "build", external=True)
126127
session.install(".", "PyInstaller<3.7")
127-
# Windows
128-
session.run(
129-
"docker", "build", "-t", "gdbgui_windows", "docker/windows", external=True
130-
)
131-
session.run("docker", "run", "-v", '"`pwd`:/src/"', "gdbgui_windows", external=True)
128+
session.run("python", "make_executable.py")
132129

133-
# linux
134-
session.run("docker", "build", "-t", "gdbgui_linux", "docker/linux", external=True)
135-
session.run("docker", "run", "-v", '"`pwd`:/src/"', "gdbgui_linux", external=True)
136130

131+
@nox.session()
132+
def build_executable_mac(session):
133+
if not platform.startswith("darwin"):
134+
raise Exception(f"Unexpected platform {platform}")
135+
session.notify("build_executable_current_platform")
137136

138-
@nox.session(python="3.7")
139-
def build_executable_current_os(session):
140-
session.install(".", "PyInstaller<3.7")
141-
session.run("python", "make_executable.py")
137+
138+
@nox.session()
139+
def build_executable_linux(session):
140+
if not platform.startswith("linux"):
141+
raise Exception(f"Unexpected platform {platform}")
142+
session.notify("build_executable_current_platform")
143+
144+
145+
@nox.session()
146+
def build_executable_windows(session):
147+
if not platform.startswith("win32"):
148+
raise Exception(f"Unexpected platform {platform}")
149+
session.notify("build_executable_current_platform")

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
"version": "0.1.0",
44
"license": "GPL-3.0",
55
"scripts": {
6-
"start": "NODE_ENV=development webpack --mode development --watch --config webpack.config.js",
6+
"start": "cross-env NODE_ENV=development webpack --mode development --watch --config webpack.config.js",
77
"test": "jest",
8-
"build": "NODE_ENV=production webpack --mode production --config webpack.config.js",
8+
"build": "cross-env NODE_ENV=production webpack --mode production --config webpack.config.js",
99
"prettier": "prettier ./gdbgui/src/js/** --write"
1010
},
1111
"dependencies": {
12+
"cross-env": "^7.0.2",
1213
"prettier": "^1.12.0",
1314
"react": "^16.8",
1415
"react-dom": "^16.4",

yarn.lock

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,6 +2175,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
21752175
safe-buffer "^5.0.1"
21762176
sha.js "^2.4.8"
21772177

2178+
cross-env@^7.0.2:
2179+
version "7.0.2"
2180+
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.2.tgz#bd5ed31339a93a3418ac4f3ca9ca3403082ae5f9"
2181+
integrity sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw==
2182+
dependencies:
2183+
cross-spawn "^7.0.1"
2184+
21782185
cross-spawn@^5.0.1:
21792186
version "5.1.0"
21802187
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
@@ -2195,6 +2202,15 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5:
21952202
shebang-command "^1.2.0"
21962203
which "^1.2.9"
21972204

2205+
cross-spawn@^7.0.1:
2206+
version "7.0.3"
2207+
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
2208+
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
2209+
dependencies:
2210+
path-key "^3.1.0"
2211+
shebang-command "^2.0.0"
2212+
which "^2.0.1"
2213+
21982214
crypto-browserify@^3.11.0:
21992215
version "3.12.0"
22002216
resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec"
@@ -5469,6 +5485,11 @@ path-key@^2.0.0, path-key@^2.0.1:
54695485
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
54705486
integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=
54715487

5488+
path-key@^3.1.0:
5489+
version "3.1.1"
5490+
resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
5491+
integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
5492+
54725493
path-parse@^1.0.6:
54735494
version "1.0.6"
54745495
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
@@ -6239,11 +6260,23 @@ shebang-command@^1.2.0:
62396260
dependencies:
62406261
shebang-regex "^1.0.0"
62416262

6263+
shebang-command@^2.0.0:
6264+
version "2.0.0"
6265+
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
6266+
integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==
6267+
dependencies:
6268+
shebang-regex "^3.0.0"
6269+
62426270
shebang-regex@^1.0.0:
62436271
version "1.0.0"
62446272
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
62456273
integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=
62466274

6275+
shebang-regex@^3.0.0:
6276+
version "3.0.0"
6277+
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
6278+
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
6279+
62476280
shelljs@^0.8.0:
62486281
version "0.8.3"
62496282
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.3.tgz#a7f3319520ebf09ee81275b2368adb286659b097"
@@ -7248,6 +7281,13 @@ which@^1.2.14, which@^1.2.9, which@^1.3.0:
72487281
dependencies:
72497282
isexe "^2.0.0"
72507283

7284+
which@^2.0.1:
7285+
version "2.0.2"
7286+
resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
7287+
integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==
7288+
dependencies:
7289+
isexe "^2.0.0"
7290+
72517291
wide-align@^1.1.0:
72527292
version "1.1.3"
72537293
resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457"

0 commit comments

Comments
 (0)