diff --git a/.github/scripts/extract_cli_version.sh b/.github/scripts/extract_cli_version.sh new file mode 100755 index 00000000..d1eeabac --- /dev/null +++ b/.github/scripts/extract_cli_version.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Check if a parameter is provided +if [ -z "$1" ]; then + echo "Error: No binary name provided. Usage: $0 " + exit 1 +fi + +BINARY_NAME=$1 + +echo "Starting CLI version extraction for binary: $BINARY_NAME..." + +# 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) +echo "Using temporary directory: $TEMP_DIR" + +unzip -j "$JAR_PATH" "$BINARY_NAME" -d "$TEMP_DIR" +if [ $? -ne 0 ]; then + echo "Error: Failed to unzip $BINARY_NAME from the JAR." + exit 1 +fi + +if [ ! -f "$TEMP_DIR/$BINARY_NAME" ]; then + echo "Error: $BINARY_NAME not found inside the JAR." + ls -la "$TEMP_DIR" + exit 1 +fi + +chmod +x "$TEMP_DIR/$BINARY_NAME" + +# Extract the CLI version +CLI_VERSION=$("$TEMP_DIR/$BINARY_NAME" version | grep -Eo '^[0-9]+\.[0-9]+\.[0-9]+') + +if [ -z "$CLI_VERSION" ]; then + echo "Error: CLI_VERSION is not set or is empty." + exit 1 +fi + +echo "CLI version being packed is $CLI_VERSION" + +# Export CLI version as an environment variable +echo "CLI_VERSION=$CLI_VERSION" >> $GITHUB_ENV + +echo "CLI version extraction for $BINARY_NAME completed successfully." diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b5eaa1e1..9212d47c 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_outputs.outputs.TAG_NAME }} + CLI_VERSION: ${{ steps.set_outputs.outputs.CLI_VERSION }} steps: # Check out current repository - name: Fetch Sources @@ -126,11 +129,18 @@ jobs: echo "GH_RELEASE_TAG_NAME=${{ env.RELEASE_VERSION }}-${{ inputs.rchannels }}" >> $GITHUB_ENV fi echo "Release name - ${{ env.GH_RELEASE_TAG_NAME }}" + # Build plugin - name: Build env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./gradlew buildPlugin --info + + - name: Extract CLI version + run: | + chmod +x ./.github/scripts/extract_cli_version.sh + ./.github/scripts/extract_cli_version.sh cx-linux + # Create the release or prerelease - name: Create Release or Prerelease uses: softprops/action-gh-release@v1 @@ -140,6 +150,13 @@ jobs: files: build/distributions/* generate_release_notes: true prerelease: ${{ inputs.rchannels != '' && inputs.rchannels != null }} + + - name: Echo CLI version and tag name to outputs + id: set_outputs + run: | + echo "::set-output name=TAG_NAME::${{ env.GH_RELEASE_TAG_NAME }}" + echo "::set-output name=CLI_VERSION::${{ env.CLI_VERSION }}" + # Publish the plugin in marketplace - name: Publish Plugin env: @@ -150,3 +167,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