diff --git a/scripts/build_container.sh b/scripts/build_container.sh index bb6768c..84175a6 100755 --- a/scripts/build_container.sh +++ b/scripts/build_container.sh @@ -1,9 +1,16 @@ #!/bin/sh VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "'") -BYPASS_PYPI_BUILD=$1 +ENABLE_PYPI_BUILD=$1 +STABLE_VERSION=$2 echo $VERSION +if [ -z $ENABLE_PYPI_BUILD ] || [ -z $STABLE_VERSION ]; then + echo "$0 pypi-build=enable stable=true" + echo "\tpypi-build: Build and publish a new version of the package to pypi" + echo "\tstable: Only build and publish a new version for the stable docker tag if it has been tested and going on the changelog" + exit +fi -if [ -z $BYPASS_PYPI_BUILD ] || [ $BYPASS_PYPI_BUILD -eq 0 ]; then +if [ $ENABLE_PYPI_BUILD = "pypi-build=enable" ]; then python -m build --wheel --sdist twine upload dist/*$VERSION* sleep 240 @@ -12,4 +19,9 @@ fi docker build --no-cache --build-arg CLI_VERSION=$VERSION --platform linux/amd64,linux/arm64 -t socketdev/cli:$VERSION . \ && docker build --no-cache --build-arg CLI_VERSION=$VERSION --platform linux/amd64,linux/arm64 -t socketdev/cli:latest . \ && docker push socketdev/cli:$VERSION \ -&& docker push socketdev/cli:latest \ No newline at end of file +&& docker push socketdev/cli:latest + +if [ $STABLE_VERSION = "stable=true" ]; then + docker build --no-cache --build-arg CLI_VERSION=$VERSION --platform linux/amd64,linux/arm64 -t socketdev/cli:stable . \ + && docker push socketdev/cli:stable +fi diff --git a/socketsecurity/__init__.py b/socketsecurity/__init__.py index e239fae..1c66b7b 100644 --- a/socketsecurity/__init__.py +++ b/socketsecurity/__init__.py @@ -1,2 +1,2 @@ __author__ = 'socket.dev' -__version__ = '1.0.15' +__version__ = '1.0.17' diff --git a/socketsecurity/core/__init__.py b/socketsecurity/core/__init__.py index f24480f..fa8aed3 100644 --- a/socketsecurity/core/__init__.py +++ b/socketsecurity/core/__init__.py @@ -532,10 +532,14 @@ def create_new_diff( :return: """ if no_change: - return Diff() + diff = Diff() + diff.id = "no_diff_id" + return diff files = Core.find_files(path, new_files) if files is None or len(files) == 0: - return Diff() + diff = Diff() + diff.id = "no_diff_id" + return diff try: head_full_scan_id = Core.get_head_scan_for_repo(params.repo) if head_full_scan_id is None or head_full_scan_id == "": diff --git a/socketsecurity/core/gitlab.py b/socketsecurity/core/gitlab.py index 23acf24..1d85887 100644 --- a/socketsecurity/core/gitlab.py +++ b/socketsecurity/core/gitlab.py @@ -97,7 +97,7 @@ def __init__(self): @staticmethod def check_event_type() -> str: - if ci_pipeline_source.lower() == "push" or ci_pipeline_source.lower() == 'merge_request_event': + if ci_pipeline_source.lower() in ["web", 'merge_request_event', "push"]: if ci_merge_request_iid is None or ci_merge_request_iid == "" or str(ci_merge_request_iid) == "0": event_type = "main" else: @@ -106,7 +106,7 @@ def check_event_type() -> str: event_type = "comment" else: log.error(f"Unknown event type {ci_pipeline_source}") - sys.exit(1) + sys.exit(0) return event_type @staticmethod