diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..2670454f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,70 @@ +name: "Build gdbgui executables" + +on: [push, pull_request] + +jobs: + ubuntu_executable: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.8" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install nox + - name: Compile linux gdbgui executable + run: | + nox --non-interactive --session build_executable_linux + - name: Upload linux executable + if: github.ref == 'refs/heads/master' + uses: actions/upload-artifact@v1 + with: + name: gdbgui_linux + path: ./executable/linux + + mac_executable: + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.8" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install nox + - name: Compile mac gdbgui executable + run: | + nox --non-interactive --session build_executable_mac + - name: Upload mac executable + if: github.ref == 'refs/heads/master' + uses: actions/upload-artifact@v1 + with: + name: gdbgui_mac + path: ./executable/mac + + windows_executable: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.8" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install nox + - name: Compile windows gdbgui executable + run: | + nox --non-interactive --session build_executable_windows + - name: Upload windows executable + if: github.ref == 'refs/heads/master' + uses: actions/upload-artifact@v1 + with: + name: gdbgui_windows + path: ./executable/windows diff --git a/docs/contributing.md b/docs/contributing.md index 7dfd82dc..91533184 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -121,4 +121,3 @@ To build macOS executable, run the following on a mac: nox -s build_executable_current_os ``` -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. diff --git a/docs/installation.md b/docs/installation.md index 04e63366..72ae967a 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -69,11 +69,7 @@ pip uninstall gdbgui ## Method 3: Download and Run Binary Executable -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). - -!!! Note - - 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. +Download and run the binary executable for your system from [GitHub Releases](https://github.com/cs01/gdbgui/releases). ## System Dependencies for Python Package diff --git a/make_executable.py b/make_executable.py index 0c120515..75977173 100644 --- a/make_executable.py +++ b/make_executable.py @@ -1,21 +1,23 @@ #!/usr/bin/env python - """ +Build an executable of gdbgui for the current platform """ import subprocess from sys import platform from gdbgui import __version__ -import os - +import hashlib +from pathlib import Path +import logging +logging.basicConfig(level=logging.INFO) if platform.startswith("linux"): platform_dir = "linux" elif platform.startswith("darwin"): platform_dir = "mac" -elif platform.startswith("win32"): +elif platform == "win32": platform_dir = "windows" else: raise Exception("Unknown platform") @@ -23,8 +25,7 @@ def write_spec_with_gdbgui_version_in_name(spec_path, binary_name): - spec = ( - """# -*- mode: python -*- + spec = f"""# -*- mode: python -*- # create executable with: pyinstaller gdbgui.spec # run executable with: dist/gdbgui @@ -65,7 +66,7 @@ def write_spec_with_gdbgui_version_in_name(spec_path, binary_name): a.binaries, a.zipfiles, a.datas, - name="%s", + name="{binary_name}", debug=False, strip=False, upx=False, @@ -73,28 +74,48 @@ def write_spec_with_gdbgui_version_in_name(spec_path, binary_name): console=True) """ - % binary_name - ) with open(spec_path, "w+") as f: f.write(spec) +def verify(binary_path: str, version: str): + cmd = [str(binary_path), "--version"] + logging.info(f"Smoke test: Running {' '.join(cmd)}") + proc = subprocess.run(cmd, stdout=subprocess.PIPE) + output = proc.stdout.decode().strip() + if output != __version__: + raise ValueError(f"Expected {__version__}. Got {output}") + logging.info("Success!") + + +def generate_md5(binary: Path, output_file: Path): + with open(output_file, "w+") as f: + f.write(hashlib.md5(str(binary).encode()).hexdigest() + "\n") + logging.info(f"Wrote md5 to {output_file}") + + def main(): binary_name = "gdbgui_%s" % __version__ spec_path = "gdbgui.spec" - write_spec_with_gdbgui_version_in_name(spec_path, binary_name) + distpath = (Path("executable") / platform_dir).resolve() + extension = ".exe" if platform == "win32" else "" + binary_path = Path(distpath) / f"{binary_name}{extension}" - subprocess.call( + write_spec_with_gdbgui_version_in_name(spec_path, binary_name) + subprocess.run( [ "pyinstaller", spec_path, "--distpath", - os.path.join("executable", platform_dir), + distpath, "--key", "a5s1fe65aw41f54sa64v6b4ds98fhea98rhg4etj4et78ku4yu87mn", ] ) + verify(binary_path, __version__) + generate_md5(binary_path, distpath / f"{binary_name}.md5") + logging.info(f"Saved executable to {binary_path}") if __name__ == "__main__": diff --git a/noxfile.py b/noxfile.py index 09e69b63..6317dfc4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,6 +1,6 @@ import nox # type: ignore from pathlib import Path - +from sys import platform nox.options.sessions = ["tests", "lint", "docs"] python = ["3.6", "3.7", "3.8"] @@ -93,11 +93,10 @@ def develop(session): session.log("To use, run: '%s'", command) -@nox.session(python="3.7") def build(session): session.install("setuptools", "wheel", "twine") session.run("rm", "-rf", "dist", external=True) - session.run("yarn", "build") + session.run("yarn", "build", external=True) session.run("python", "setup.py", "--quiet", "sdist", "bdist_wheel") session.run("twine", "check", "dist/*") @@ -121,21 +120,30 @@ def publish_docs(session): session.run("mkdocs", "gh-deploy") -@nox.session(python="3.7") -def docker_executables(session): +@nox.session() +def build_executable_current_platform(session): + session.run("yarn", "install", external=True) + session.run("yarn", "build", external=True) session.install(".", "PyInstaller<3.7") - # Windows - session.run( - "docker", "build", "-t", "gdbgui_windows", "docker/windows", external=True - ) - session.run("docker", "run", "-v", '"`pwd`:/src/"', "gdbgui_windows", external=True) + session.run("python", "make_executable.py") - # linux - session.run("docker", "build", "-t", "gdbgui_linux", "docker/linux", external=True) - session.run("docker", "run", "-v", '"`pwd`:/src/"', "gdbgui_linux", external=True) +@nox.session() +def build_executable_mac(session): + if not platform.startswith("darwin"): + raise Exception(f"Unexpected platform {platform}") + session.notify("build_executable_current_platform") -@nox.session(python="3.7") -def build_executable_current_os(session): - session.install(".", "PyInstaller<3.7") - session.run("python", "make_executable.py") + +@nox.session() +def build_executable_linux(session): + if not platform.startswith("linux"): + raise Exception(f"Unexpected platform {platform}") + session.notify("build_executable_current_platform") + + +@nox.session() +def build_executable_windows(session): + if not platform.startswith("win32"): + raise Exception(f"Unexpected platform {platform}") + session.notify("build_executable_current_platform") diff --git a/package.json b/package.json index db71a0b6..b813cc87 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,13 @@ "version": "0.1.0", "license": "GPL-3.0", "scripts": { - "start": "NODE_ENV=development webpack --mode development --watch --config webpack.config.js", + "start": "cross-env NODE_ENV=development webpack --mode development --watch --config webpack.config.js", "test": "jest", - "build": "NODE_ENV=production webpack --mode production --config webpack.config.js", + "build": "cross-env NODE_ENV=production webpack --mode production --config webpack.config.js", "prettier": "prettier ./gdbgui/src/js/** --write" }, "dependencies": { + "cross-env": "^7.0.2", "prettier": "^1.12.0", "react": "^16.8", "react-dom": "^16.4", diff --git a/yarn.lock b/yarn.lock index 89cf4699..8f3201bd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2175,6 +2175,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: safe-buffer "^5.0.1" sha.js "^2.4.8" +cross-env@^7.0.2: + version "7.0.2" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.2.tgz#bd5ed31339a93a3418ac4f3ca9ca3403082ae5f9" + integrity sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw== + dependencies: + cross-spawn "^7.0.1" + cross-spawn@^5.0.1: version "5.1.0" 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: shebang-command "^1.2.0" which "^1.2.9" +cross-spawn@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + crypto-browserify@^3.11.0: version "3.12.0" 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: resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= +path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== + path-parse@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" @@ -6239,11 +6260,23 @@ shebang-command@^1.2.0: dependencies: shebang-regex "^1.0.0" +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + shebang-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== + shelljs@^0.8.0: version "0.8.3" 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: dependencies: isexe "^2.0.0" +which@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + wide-align@^1.1.0: version "1.1.3" resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457"