From 894e34f82c65cb485a622df4346ecec292618c9a Mon Sep 17 00:00:00 2001 From: Terrance DeJesus <99630311+terrancedejesus@users.noreply.github.com> Date: Wed, 12 Apr 2023 13:48:58 -0400 Subject: [PATCH] [Bug] Add `new-package` argument to `bump-pkg-versions` CLI (#2703) * initial changes to release fleet workflow and CLI * changed the default value of package version for 8.8 * changed how true/false is passed into CLI command * reverted changes to packages.yml --- .github/workflows/release-fleet.yml | 21 +++++++++++++++++++-- detection_rules/devtools.py | 6 +++++- detection_rules/etc/packages.yml | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-fleet.yml b/.github/workflows/release-fleet.yml index f435f06af..68bee1828 100644 --- a/.github/workflows/release-fleet.yml +++ b/.github/workflows/release-fleet.yml @@ -11,11 +11,26 @@ on: required: true default: 'main' draft: - description: 'Create a PR as draft (y/n)' + type: choice + description: 'Create a PR as draft' required: false + options: + - "y" + - "n" package_maturity: - description: 'Package Maturity (ga/beta)' + type: choice + description: 'Package Maturity' required: true + options: + - "ga" + - "beta" + new_package: + type: choice + description: 'New Package' + required: true + options: + - "true" + - "false" commit_hash: description: 'Commit hash' required: true @@ -95,10 +110,12 @@ jobs: - name: Bump prebuilt rules package version env: PACKAGE_MATURITY: "${{github.event.inputs.package_maturity}}" + NEW_PACKAGE: "${{github.event.inputs.new_package}}" run: | cd detection-rules python -m detection_rules dev bump-pkg-versions \ --patch-release \ + --new-package $NEW_PACKAGE \ --maturity $PACKAGE_MATURITY - name: Store release tag diff --git a/detection_rules/devtools.py b/detection_rules/devtools.py index c4ad5d352..c135ccbeb 100644 --- a/detection_rules/devtools.py +++ b/detection_rules/devtools.py @@ -161,9 +161,10 @@ def build_integration_docs(ctx: click.Context, registry_version: str, pre: str, @click.option("--major-release", is_flag=True, help="bump the major version") @click.option("--minor-release", is_flag=True, help="bump the minor version") @click.option("--patch-release", is_flag=True, help="bump the patch version") +@click.option("--new-package", type=click.Choice(['true', 'false']), help="indicates new package") @click.option("--maturity", type=click.Choice(['beta', 'ga'], case_sensitive=False), required=True, help="beta or production versions") -def bump_versions(major_release: bool, minor_release: bool, patch_release: bool, maturity: str): +def bump_versions(major_release: bool, minor_release: bool, patch_release: bool, new_package: str, maturity: str): """Bump the versions""" pkg_data = load_etc_dump('packages.yml')['package'] @@ -197,6 +198,9 @@ def bump_versions(major_release: bool, minor_release: bool, patch_release: bool, pkg_data["registry_data"]["version"] = str(latest_patch_release_ver.bump_patch()) pkg_data["registry_data"]["release"] = maturity else: + # passing in true or false from GH actions; not using eval() for security purposes + if new_package == "true": + latest_patch_release_ver = latest_patch_release_ver.bump_patch() pkg_data["registry_data"]["version"] = str(latest_patch_release_ver.bump_prerelease("beta")) pkg_data["registry_data"]["release"] = maturity diff --git a/detection_rules/etc/packages.yml b/detection_rules/etc/packages.yml index 0e5a7fefe..c03c603dd 100644 --- a/detection_rules/etc/packages.yml +++ b/detection_rules/etc/packages.yml @@ -23,5 +23,5 @@ package: release: ga title: Prebuilt Security Detection Rules type: integration - version: 8.8.0-beta.1 + version: 8.8.0-beta.0 release: true