Skip to content

cli-version-update #201

cli-version-update

cli-version-update #201

Workflow file for this run

name: Update Checkmarx AST CLI
on:
workflow_dispatch:
inputs:
new_cli_version:
description: 'New CLI version (optional)'
required: false
repository_dispatch:
types: [cli-version-update]
jobs:
update-checkmarx-cli:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Fetch the latest Checkmarx AST CLI version
- name: Get Latest Checkmarx API version
id: checkmarx-ast-cli
run: |
if [ "${{ github.event.inputs.new_cli_version }}" ]; then
LATEST_VERSION=${{ github.event.inputs.new_cli_version }}
else
LATEST_VERSION=$(curl -sL https://api.github.com/repos/Checkmarx/ast-cli/releases/latest | jq -r ".tag_name")
fi
CURRENT_VERSION=$(<checkmarx-ast-cli.version)
echo ::set-output name=release_tag::$LATEST_VERSION
echo ::set-output name=current_tag::$CURRENT_VERSION
# Update the version file if the latest version differs
- name: Update Checkmarx CLI version in version file
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
env:
RELEASE_TAG: ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
run: |
echo ${{ steps.checkmarx-ast-cli.outputs.release_tag }} > checkmarx-ast-cli.version
# Update the TypeScript file's cliDefaultVersion field
- name: Update cliDefaultVersion in CxInstaller.ts
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
env:
NEW_CLI_VERSION: ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
run: |
FILE_PATH="src/main/osinstaller/CxInstaller.ts"
# Ensure that 'cliDefaultVersion' is updated correctly
sed -i "s/\(cliDefaultVersion = '\)[^']*\(';\)/\1${NEW_CLI_VERSION}\2/" $FILE_PATH
# Create a Pull Request with the version changes
- name: Create Pull Request
id: cretae_pull_request
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c #v6
with:
token: ${{ secrets.AUTOMATION_TOKEN }}
commit-message: Update checkmarx-ast-cli to ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
title: Update checkmarx-ast-cli binaries with ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
body: |
Updates [checkmarx-ast-cli][1] to ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
Auto-generated by [create-pull-request][2]
[1]: https://github.com/Checkmarx/checkmarx-ast-cli
labels: cxone
branch: feature/update_cli_${{ steps.checkmarx-ast-cli.outputs.release_tag }}