Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notify job for release.yml (AST-0000) #306

Merged
merged 19 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
0d423a8
Enhance release workflow to extract and output CLI version
BenAlvo1 Jan 28, 2025
23c6675
Add output for GH_RELEASE_TAG_NAME and clean up CLI_VERSION debug echo
BenAlvo1 Jan 28, 2025
e655af6
Refactor release workflow to use GITHUB_OUTPUT for setting TAG_NAME a…
BenAlvo1 Jan 28, 2025
b7f434b
Update release workflow to set TAG_NAME and CLI_VERSION using set-output
BenAlvo1 Jan 28, 2025
87300af
Add error handling for unset CLI_VERSION in release workflow
BenAlvo1 Jan 28, 2025
f7008b1
Add script to extract CLI version from JAR and update release workflow
BenAlvo1 Jan 28, 2025
fbc8c25
changed from cx-mac to cx-linux
BenAlvo1 Jan 28, 2025
394ba5e
added script location
BenAlvo1 Jan 28, 2025
e4ada8b
added script location
BenAlvo1 Jan 28, 2025
0003ee9
added script location
BenAlvo1 Jan 28, 2025
0a5e3ea
added script location
BenAlvo1 Jan 28, 2025
e09715d
add CLI version extraction to release workflow
BenAlvo1 Jan 28, 2025
afbc959
add CLI version extraction to release workflow
BenAlvo1 Jan 28, 2025
7366ef9
Delete step into noty jib condition for debug purpose
BenAlvo1 Jan 28, 2025
4f576d6
Enhance CLI version extraction script to require binary name as param…
BenAlvo1 Jan 28, 2025
b49369f
Check release
BenAlvo1 Jan 28, 2025
cdeb4b6
Delete step into noty job condition for debug purpose
BenAlvo1 Jan 28, 2025
ebb07f0
Refactor release workflow to consolidate output steps for tag name an…
BenAlvo1 Jan 28, 2025
e9a6567
revert delete step into noty jib condition for debug purpose
BenAlvo1 Jan 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/scripts/extract_cli_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets think about moving this script to the new workflow repo and add it as an action there - extract-cli-version that will get the repo type and will know how to search for it in each kind of repo.
this is for our next steps.


# Check if a parameter is provided
if [ -z "$1" ]; then
echo "Error: No binary name provided. Usage: $0 <binary_name>"
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."
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Loading