Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7f01736
Add Pyinstaller and spec for it; remove legacy and unused dep
MarshalX May 17, 2023
0dbc78e
add ability to get the version at the process of bundle creation
MarshalX May 17, 2023
82f8854
Build executable version of CLI for Linux
MarshalX May 17, 2023
4cd6f88
upload executable as artifacts
MarshalX May 17, 2023
1a4da58
add macos
MarshalX May 17, 2023
86b076d
update path
MarshalX May 17, 2023
fb565f3
add windows
MarshalX May 17, 2023
c625fd9
fix win test
MarshalX May 17, 2023
3a322fb
fix win test 2
MarshalX May 17, 2023
c75b91b
update win path
MarshalX May 17, 2023
804196f
update win path 2
MarshalX May 17, 2023
d88065a
update win path 3
MarshalX May 17, 2023
21160ac
run on all runners
MarshalX May 17, 2023
71788f3
fix startsWith
MarshalX May 17, 2023
421d88e
fix startsWith 2
MarshalX May 17, 2023
c5afe75
attempt to build universal binary for macos
MarshalX May 17, 2023
7c39e82
bump python version to 3.11
MarshalX May 17, 2023
954a318
rework installation of Poetry
MarshalX May 17, 2023
671fca9
trigger
MarshalX May 17, 2023
131de4e
rollback python to 3.7; disable fast fail
MarshalX May 17, 2023
f57ebcc
build macos binary for the same arch as the current one
MarshalX May 17, 2023
868306a
use bash for all OS
MarshalX May 17, 2023
7c6f0ed
attempt to use lower OS version as possible
MarshalX May 17, 2023
af391e0
Merge branch 'main' into CM-22808-Build-CLI-executable
MarshalX May 17, 2023
b7e872a
don't depend on Git for resolve CLI version in bundles anymore
MarshalX May 17, 2023
4d357a9
trigger on main branch only
MarshalX May 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/build_executable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build executable version of CLI

on:
push:
branches:
# - main
- "CM-22808-Build-CLI-executable"

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: '3.7'

- name: Setup Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: poetry install

- name: Build executable
run: poetry run pyinstaller pyinstaller.spec

- name: Test executable
if: ${{ !startsWith(matrix.os, 'windows') }}
run: ./dist/cycode --version

- name: Test executable on Windows
if: ${{ startsWith(matrix.os, 'windows') }}
run: Invoke-expression -command ".\dist\cycode.exe --version"

- uses: actions/upload-artifact@v3
with:
name: cycode-cli-${{ matrix.os }}
path: dist
2 changes: 1 addition & 1 deletion cycode/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.0' # placeholder. Will be filled automatically on poetry build from Git Tag
__version__ = '0.0.0' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
147 changes: 133 additions & 14 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions pyinstaller.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# -*- mode: python ; coding: utf-8 -*-
# Run `poetry run pyinstaller pyinstaller.spec` to generate the binary.


block_cipher = None

INIT_FILE_PATH = os.path.join('cycode', '__init__.py')

# save the prev content of __init__ file
with open(INIT_FILE_PATH, 'r', encoding='UTF-8') as file:
prev_content = file.read()

new_content = """
import dunamai as _dunamai
__version__ = _dunamai.get_version('cycode', first_choice=_dunamai.Version.from_git).serialize(
metadata=False, bump=True, style=_dunamai.Style.Pep440
)
"""

# write the code to get version from Git Tag in runtime
# the code will be compiled once during creation of the bundle
# the value of __version__ will be frozen
with open(INIT_FILE_PATH, 'w', encoding='UTF-8') as file:
file.write(new_content)

a = Analysis(
['cycode/cli/main.py'],
pathex=[],
binaries=[],
datas=[('cycode/cli/config.yaml', 'cycode/cli'), ('cycode/cyclient/config.yaml', 'cycode/cyclient')],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=['tests'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='cycode',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch='universal2',
codesign_identity=None,
entitlements_file=None,
)

# rollback the prev content of the __init__ file
with open(INIT_FILE_PATH, 'w', encoding='UTF-8') as file:
file.write(prev_content)
11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cycode"
version = "0.0.0" # placeholder. Will be filled automatically on poetry build from Git Tag
version = "0.0.0" # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
description = "Perform secrets/iac scans for your sources using Cycode's engine"
keywords=["secret-scan", "cycode", "devops", "token", "secret", "security", "cycode", "code"]
authors = ["Cycode <support@cycode.com>"]
Expand All @@ -26,12 +26,11 @@ classifiers = [
cycode = "cycode.cli.main:main_cli"

[tool.poetry.dependencies]
python = "^3.7"
python = ">=3.7,<3.12"
click = ">=8.1.0,<8.2.0"
colorama = ">=0.4.3,<0.5.0"
pyyaml = ">=6.0,<7.0"
marshmallow = ">=3.8.0,<3.9.0"
typing = ">=3.7.4.3,<3.8.0.0"
pathspec = ">=0.8.0,<0.9.0"
gitpython = ">=3.1.30,<3.2.0"
arrow = ">=0.17.0,<0.18.0"
Expand All @@ -47,8 +46,12 @@ pytest-mock = ">=3.10.0,<3.11.0"
coverage = ">=7.2.3,<7.3.0"
responses = ">=0.23.1,<0.24.0"

# poetry self add "poetry-dynamic-versioning[plugin]"
[tool.poetry.group.executable.dependencies]
pyinstaller = ">=5.11.0,<5.12.0"
dunamai = ">=1.16.1,<1.17.0"

[tool.poetry-dynamic-versioning]
# poetry self add "poetry-dynamic-versioning[plugin]"
enable = true
strict = true
bump = true
Expand Down