|
1 | | -name: Update checkmarx ast cli |
| 1 | +name: Update Checkmarx AST CLI |
| 2 | + |
2 | 3 | on: |
3 | 4 | workflow_dispatch: |
| 5 | + inputs: |
| 6 | + new_cli_version: |
| 7 | + description: 'New CLI version (optional)' |
| 8 | + required: false |
4 | 9 | schedule: |
5 | 10 | - cron: '0 0 * * *' |
6 | 11 |
|
7 | 12 | jobs: |
8 | 13 | update-checkmarx-cli: |
9 | 14 | runs-on: ubuntu-latest |
| 15 | + |
10 | 16 | steps: |
11 | 17 | - uses: actions/checkout@v4 |
12 | | - with: |
13 | | - lfs: true |
14 | | - |
15 | | - - name: Install Git LFS |
16 | | - run: | |
17 | | - sudo apt-get update |
18 | | - sudo apt-get install git-lfs |
19 | | - git lfs install |
20 | | -
|
21 | | - - name: Configure Git user |
22 | | - run: | |
23 | | - git config --global user.name github-actions |
24 | | - git config --global user.email github-actions@github.com |
25 | 18 |
|
| 19 | + # Fetch the latest Checkmarx AST CLI version |
26 | 20 | - name: Get Latest Checkmarx API version |
27 | 21 | id: checkmarx-ast-cli |
28 | 22 | run: | |
29 | | - echo ::set-output name=release_tag::$(curl -sL https://api.github.com/repos/Checkmarx/ast-cli/releases/latest | jq -r ".tag_name") |
30 | | - echo ::set-output name=current_tag::$(<checkmarx-ast-cli.version) |
| 23 | + if [ "${{ github.event.inputs.new_cli_version }}" ]; then |
| 24 | + LATEST_VERSION=${{ github.event.inputs.new_cli_version }} |
| 25 | + else |
| 26 | + LATEST_VERSION=$(curl -sL https://api.github.com/repos/Checkmarx/ast-cli/releases/latest | jq -r ".tag_name") |
| 27 | + fi |
| 28 | + CURRENT_VERSION=$(<checkmarx-ast-cli.version) |
| 29 | + echo ::set-output name=release_tag::$LATEST_VERSION |
| 30 | + echo ::set-output name=current_tag::$CURRENT_VERSION |
31 | 31 |
|
32 | | - - name: Update Checkmarx cli version |
| 32 | + # Update the version file if the latest version differs |
| 33 | + - name: Update Checkmarx CLI version in version file |
33 | 34 | if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag |
34 | 35 | env: |
35 | 36 | RELEASE_TAG: ${{ steps.checkmarx-ast-cli.outputs.release_tag }} |
36 | 37 | run: | |
37 | | - # Update current release |
38 | 38 | echo ${{ steps.checkmarx-ast-cli.outputs.release_tag }} > checkmarx-ast-cli.version |
39 | 39 |
|
40 | | - - name: Download latest cli and update branch |
41 | | - if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag |
42 | | - run: | |
43 | | - # Update binaries |
44 | | - chmod +x ./.github/scripts/update_cli.sh |
45 | | - ./.github/scripts/update_cli.sh ${{ steps.checkmarx-ast-cli.outputs.release_tag }} |
46 | | -
|
47 | | - - name: Track large files with Git LFS |
| 40 | + # Update the TypeScript file's cliDefaultVersion field |
| 41 | + - name: Update cliDefaultVersion in CxInstaller.ts |
48 | 42 | if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag |
| 43 | + env: |
| 44 | + NEW_CLI_VERSION: ${{ steps.checkmarx-ast-cli.outputs.release_tag }} |
49 | 45 | run: | |
50 | | - git lfs track "src/main/wrapper/resources/cx-linux" |
51 | | - git lfs track "src/main/wrapper/resources/cx.exe" |
52 | | - git lfs track "src/main/wrapper/resources/cx-mac" |
53 | | - git add .gitattributes |
54 | | - git add src/main/wrapper/resources/cx-linux src/main/wrapper/resources/cx.exe src/main/wrapper/resources/cx-mac |
55 | | - git commit -m "Track Checkmarx CLI binaries with Git LFS" |
| 46 | + FILE_PATH="src/main/osinstaller/CxInstaller.ts" |
| 47 | + # Ensure that 'cliDefaultVersion' is updated correctly |
| 48 | + sed -i "s/\(cliDefaultVersion = '\)[^']*\(';\)/\1${NEW_CLI_VERSION}\2/" $FILE_PATH |
56 | 49 |
|
| 50 | + # Create a Pull Request with the version changes |
57 | 51 | - name: Create Pull Request |
58 | 52 | if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag |
59 | 53 | uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c #v6 |
|
0 commit comments