Skip to content

Commit bf81d31

Browse files
Try java wrapper 2.1.8 (AST-000)
1 parent 528ca78 commit bf81d31

1 file changed

Lines changed: 34 additions & 78 deletions

File tree

.github/workflows/update-cli.yml

Lines changed: 34 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Update checkmarx Java wrapper
22
on:
33
workflow_dispatch:
4+
inputs:
5+
tag:
6+
description: 'Next release tag'
7+
required: true
48
schedule:
59
- cron: '0 0 * * *'
610

@@ -23,96 +27,48 @@ jobs:
2327
- name: Get Latest Checkmarx Java wrapper version
2428
id: ast-cli-java-wrapper
2529
run: |
26-
echo "Fetching latest release tag from Maven repository..."
27-
28-
# Correctly assign variables
29-
release_tag=$(curl -s "https://repo1.maven.org/maven2/com/checkmarx/ast/ast-cli-java-wrapper/maven-metadata.xml" | grep -oPm1 "(?<=<latest>)[^<]+")
30-
current_tag=$(cat ast-cli-java-wrapper.version)
31-
32-
# Debugging output
33-
echo "Current tag: $current_tag"
34-
echo "Latest release tag: $release_tag"
35-
36-
# Correctly append to environment variables
37-
echo "release_tag=$release_tag" >> $GITHUB_ENV
38-
echo "current_tag=$current_tag" >> $GITHUB_ENV
39-
30+
echo ::set-output name=release_tag::${{ inputs.tag }})
31+
echo ::set-output name=current_tag::$(<ast-cli-java-wrapper.version)
4032
- name: Update Checkmarx Java wrapper version
41-
if: env.current_tag != env.release_tag
33+
if: steps.ast-cli-java-wrapper.outputs.current_tag != steps.ast-cli-java-wrapper.outputs.release_tag
4234
run: |
43-
echo "Updating Checkmarx Java wrapper version..."
44-
echo "Current version: $current_tag"
45-
echo "New version: $release_tag"
46-
4735
# Update current release
48-
echo "$release_tag" > ast-cli-java-wrapper.version
49-
current_version="ast-cli-java-wrapper-$current_tag.jar"
50-
new_version="ast-cli-java-wrapper-$release_tag.jar"
51-
52-
echo "Updating references in project files..."
53-
echo "Verifying if current version exists in files before replacement:"
54-
grep -n "$current_version" checkmarx-ast-eclipse-plugin/build.properties || echo "Not found in build.properties"
55-
grep -n "$current_version" checkmarx-ast-eclipse-plugin/.classpath || echo "Not found in .classpath"
56-
grep -n "$current_version" checkmarx-ast-eclipse-plugin/META-INF/MANIFEST.MF || echo "Not found in MANIFEST.MF"
57-
58-
echo "Updating references in project files..."
59-
sed -i "s|$current_version|$new_version|g" checkmarx-ast-eclipse-plugin/build.properties
60-
sed -i "s|$current_version|$new_version|g" checkmarx-ast-eclipse-plugin/.classpath
61-
sed -i "s|$current_version|$new_version|g" checkmarx-ast-eclipse-plugin/META-INF/MANIFEST.MF
62-
63-
echo "Verifying if the files were modified:"
64-
git diff -- checkmarx-ast-eclipse-plugin/build.properties
65-
git diff -- checkmarx-ast-eclipse-plugin/.classpath
66-
git diff -- checkmarx-ast-eclipse-plugin/META-INF/MANIFEST.MF
67-
68-
echo "If no changes are shown above, the replacement did not occur."
69-
# Remove old JAR and download the new one
36+
echo ${{ steps.ast-cli-java-wrapper.outputs.release_tag }} > ast-cli-java-wrapper.version
37+
current_version=ast-cli-java-wrapper-${{ steps.ast-cli-java-wrapper.outputs.current_tag }}.jar
38+
new_version=ast-cli-java-wrapper-${{ steps.ast-cli-java-wrapper.outputs.release_tag }}.jar
39+
sed -i "s/$current_version/$new_version/g" checkmarx-ast-eclipse-plugin/build.properties
40+
sed -i "s/$current_version/$new_version/g" checkmarx-ast-eclipse-plugin/.classpath
41+
sed -i "s/$current_version/$new_version/g" checkmarx-ast-eclipse-plugin/META-INF/MANIFEST.MF
7042
cd checkmarx-ast-eclipse-plugin/lib/
71-
echo "Removing old JAR file: $current_version"
72-
rm -f "$current_version"
73-
74-
echo "Downloading new JAR file: $new_version"
75-
curl -fLO "https://repo1.maven.org/maven2/com/checkmarx/ast/ast-cli-java-wrapper/$release_tag/$new_version"
76-
77-
# Verify if the file exists
78-
echo "Checking if the new file exists..."
79-
ls -al
80-
if [ ! -f "$new_version" ]; then
81-
echo "Error: The new JAR file was not downloaded correctly."
82-
exit 1
43+
rm -rf "$current_version"
44+
curl "https://repo1.maven.org/maven2/com/checkmarx/ast/ast-cli-java-wrapper/${{ steps.ast-cli-java-wrapper.outputs.release_tag }}/${new_version}" --output $new_version
45+
46+
# Track the new JAR file with LFS
47+
FILE_PATH="checkmarx-ast-eclipse-plugin/lib/$new_version" # Correct path
48+
# Create the directory if it doesn't exist (important!)
49+
mkdir -p "checkmarx-ast-eclipse-plugin/lib"
50+
mv $new_version $FILE_PATH
51+
# Ensure the file exists after download
52+
if [ ! -f "$FILE_PATH" ]; then
53+
echo "Error: File $FILE_PATH not found after download."
54+
exit 1 # Fail the workflow
8355
fi
84-
85-
cd ../../ # Move back to repo root
86-
87-
# Track file in LFS before staging
88-
echo "Tracking file in Git LFS..."
89-
git lfs track "checkmarx-ast-eclipse-plugin/lib/$new_version"
56+
git lfs track "$FILE_PATH"
9057
git add .gitattributes
91-
git add "checkmarx-ast-eclipse-plugin/lib/$new_version"
92-
93-
# Ensure LFS files are handled correctly
94-
echo "Committing changes..."
95-
git commit -m "Update ast-cli-java-wrapper to $release_tag"
96-
97-
echo "Pushing LFS-tracked files..."
98-
git lfs push --all origin
99-
100-
echo "Pushing commit to repository..."
58+
git add "$FILE_PATH"
59+
git commit -m "Update ast-cli-java-wrapper to ${{ steps.ast-cli-java-wrapper.outputs.release_tag }}"
10160
git push origin HEAD:${{ github.ref }}
102-
103-
104-
10561
10662
- name: Create Pull Request
107-
if: env.current_tag != env.release_tag
108-
uses: peter-evans/create-pull-request@v6.1.0
63+
if: steps.ast-cli-java-wrapper.outputs.current_tag != steps.ast-cli-java-wrapper.outputs.release_tag
64+
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c #v6.1.0
10965
with:
11066
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
111-
commit-message: Update ast-cli-java-wrapper to ${{ env.release_tag }}
112-
title: Update ast-cli-java-wrapper with ${{ env.release_tag }}
67+
commit-message: Update ast-cli-java-wrapper to ${{ steps.ast-cli-java-wrapper.outputs.release_tag }}
68+
title: Update ast-cli-java-wrapper with ${{ steps.ast-cli-java-wrapper.outputs.release_tag }}
11369
body: |
114-
Updates [ast-cli-java-wrapper][1] to ${{ env.release_tag }}
70+
Updates [ast-cli-java-wrapper][1] to ${{ steps.ast-cli-java-wrapper.outputs.release_tag }}
11571
Auto-generated by [create-pull-request][2]
11672
[1]: https://github.com/CheckmarxDev/ast-cli-java-wrapper
11773
labels: cxone
118-
branch: dependency/update_java_wrapper
74+
branch: dependency/update_java_wrapper

0 commit comments

Comments
 (0)