-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for generating binaries with pyinstaller (#731)
- Loading branch information
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Build binary | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- windows-latest | ||
- macos-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements/requirements.txt | ||
pip install -r requirements/requirements_dev.txt | ||
pip install pyinstaller | ||
- name: Build binary | ||
run: | | ||
invoke build-binary | ||
- name: Test the binary | ||
run: | ||
invoke test-binary | ||
|
||
- name: Prepare binary for upload | ||
run: | ||
invoke prepare-binary | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- mode: python -*- | ||
|
||
block_cipher = None | ||
|
||
a = Analysis(['bin/aws-gate'], | ||
pathex=['.'], | ||
hiddenimports=[], | ||
hookspath=None, | ||
runtime_hooks=None, | ||
cipher=block_cipher) | ||
|
||
pyz = PYZ(a.pure, | ||
cipher=block_cipher) | ||
|
||
exe = EXE(pyz, | ||
a.scripts, | ||
a.binaries, | ||
a.zipfiles, | ||
a.datas, | ||
name='aws-gate', | ||
debug=False, | ||
strip=None, | ||
upx=True, | ||
console=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import hashlib | ||
import os | ||
import platform | ||
|
||
from invoke import task | ||
|
||
|
||
@task | ||
def build_binary(ctx): | ||
ctx.run("pyinstaller ./aws-gate.spec") | ||
|
||
|
||
@task | ||
def test_binary(ctx): | ||
ctx.run("./dist/aws-gate --version") | ||
ctx.run("./dist/aws-gate --help") | ||
|
||
|
||
@task | ||
def prepare_binary(ctx): # pylint: disable=unused-argument | ||
binary_name = "aws-gate" | ||
binary_path = f"./dist/{binary_name}" | ||
platform_suffix = f"{platform.system()}_{platform.machine()}" | ||
platform_binary_name = f"{binary_name}-{platform_suffix}" | ||
platform_binary_path = f"{binary_path}-{platform_suffix}" | ||
|
||
os.rename(binary_path, platform_binary_path) | ||
|
||
with open(f"{platform_binary_path}-sha256sum.txt", "w") as h: | ||
with open(f"{platform_binary_path}", "rb") as f: | ||
hash = hashlib.sha256(f.read()).hexdigest() | ||
h.write(f"{hash} {platform_binary_name}\n") | ||
|
||
|
||
@task | ||
def clean_binary(ctx): | ||
ctx.run("rm -vrf ./dist") |