From 0d423a8a5bbe711218691547c2c0089654dd5a05 Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Tue, 28 Jan 2025 15:10:19 +0200 Subject: [PATCH] Enhance release workflow to extract and output CLI version --- .github/workflows/release.yml | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b5eaa1e1..afd9172e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -102,6 +102,9 @@ jobs: if: inputs.rchannels release: runs-on: ubuntu-latest + outputs: + TAG_NAME: ${{ steps.set_tag_name.outputs.TAG_NAME }} + CLI_VERSION: ${{ steps.extract_cli_version.outputs.CLI_VERSION }} steps: # Check out current repository - name: Fetch Sources @@ -131,6 +134,46 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./gradlew buildPlugin --info + + - name: Extract CLI version + id: extract_cli_version + run: | + # Find the correct JAR file in Gradle cache (excluding javadoc JARs) + JAR_PATH=$(find ~/.gradle -type f -name "ast-cli-java-wrapper-*.jar" ! -name "*-javadoc.jar" | head -n 1) + + if [ -z "$JAR_PATH" ]; then + echo "Error: ast-cli-java-wrapper JAR not found in Gradle dependencies." + exit 1 + fi + + echo "Found JAR at: $JAR_PATH" + + # Create a temporary directory to extract the CLI + TEMP_DIR=$(mktemp -d) + unzip -j "$JAR_PATH" "cx-linux" -d "$TEMP_DIR" + + if [ ! -f "$TEMP_DIR/cx-linux" ]; then + echo "Error: cx-linux not found inside the JAR." + ls -la + exit 1 + fi + + chmod +x "$TEMP_DIR/cx-linux" + + # Extract the CLI version + CLI_VERSION=$("$TEMP_DIR/cx-linux" version | grep -Eo '^[0-9]+\.[0-9]+\.[0-9]+') + + echo "CLI version being packed is $CLI_VERSION" + + # Export CLI version as an environment variable + echo "CLI_VERSION=$CLI_VERSION" >> $GITHUB_ENV + echo "::set-output name=CLI_VERSION::$CLI_VERSION" + + # Echo the CLI version for debugging purposes + echo "CLI version: $CLI_VERSION" + + + # Create the release or prerelease - name: Create Release or Prerelease uses: softprops/action-gh-release@v1 @@ -150,3 +193,16 @@ jobs: else ./gradlew publishPlugin -Prchannels=${{ inputs.rchannels }} fi + + notify: + if: ${{ (inputs.rchannels != '' && inputs.rchannels != null) || inputs.rchannels == 'test-notify' }} + needs: release + uses: Checkmarx/plugins-release-workflow/.github/workflows/release-notify.yml@main + with: + product_name: JetBrains Plugin + release_version: ${{ needs.release.outputs.TAG_NAME }} + cli_release_version: ${{ needs.release.outputs.CLI_VERSION }} + release_author: "Phoenix Team" + release_url: https://github.com/Checkmarx/ast-jetbrains-plugin/releases/tag/${{ needs.release.outputs.TAG_NAME }} + jira_product_name: JetBrains + secrets: inherit \ No newline at end of file