Skip to content
Merged
Changes from all commits
Commits
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
96 changes: 70 additions & 26 deletions .github/workflows/publish-marketplace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
jobs:
publish-marketplace:
runs-on: ubuntu-latest
if: github.repository == 'redhat-developer/intellij-dependency-analytics'
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -33,6 +34,41 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Validate required secrets
env:
JETBRAINS_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ -z "$JETBRAINS_TOKEN" ]; then
echo "Error: JETBRAINS_MARKETPLACE_TOKEN secret is not set"
exit 1
fi
if [ -z "$GITHUB_TOKEN" ]; then
echo "Error: GITHUB_TOKEN secret is not set"
exit 1
fi
echo "✅ Required secrets are available"

- name: Check for changes since last nightly
if: github.event_name == 'schedule'
id: changes_check
run: |
# Get the date from yesterday
YESTERDAY=$(date -d 'yesterday' +%Y-%m-%d)
echo "Checking for changes since: $YESTERDAY"

# Get the last nightly build commit hash (you might want to store this in a file or use a tag)
# For now, we'll check if there are any commits in the last 24 hours
COMMIT_COUNT=$(git log --since="$YESTERDAY" --oneline | wc -l)

if [ "$COMMIT_COUNT" -gt 0 ]; then
echo "✅ Found $COMMIT_COUNT commits since $YESTERDAY - proceeding with nightly build"
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "ℹ️ No commits since $YESTERDAY - skipping nightly build"
echo "has_changes=false" >> $GITHUB_OUTPUT
fi

- name: Determine version and channel
id: version_info
run: |
Expand Down Expand Up @@ -74,31 +110,17 @@ jobs:
echo "CHANNEL=$CHANNEL" >> $GITHUB_OUTPUT
echo "Publishing version $VERSION to $CHANNEL channel"

- name: Check for changes since last nightly
if: github.event_name == 'schedule'
id: changes_check
run: |
# Get the date from yesterday
YESTERDAY=$(date -d 'yesterday' +%Y-%m-%d)
echo "Checking for changes since: $YESTERDAY"

# Get the last nightly build commit hash (you might want to store this in a file or use a tag)
# For now, we'll check if there are any commits in the last 24 hours
COMMIT_COUNT=$(git log --since="$YESTERDAY" --oneline | wc -l)

if [ "$COMMIT_COUNT" -gt 0 ]; then
echo "✅ Found $COMMIT_COUNT commits since $YESTERDAY - proceeding with nightly build"
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "ℹ️ No commits since $YESTERDAY - skipping nightly build"
echo "has_changes=false" >> $GITHUB_OUTPUT
fi

- name: Build nightly version
if: (github.event_name == 'schedule' && steps.changes_check.outputs.has_changes == 'true') || github.event_name == 'workflow_dispatch'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Building nightly version from source..."
./gradlew buildPlugin -Pgpr.username=rhdevelopers-ci -Pgpr.token=${{ secrets.GITHUB_TOKEN }} -PprojectVersion=${{ steps.version_info.outputs.VERSION }}
if ! ./gradlew buildPlugin -Pgpr.username=rhdevelopers-ci -Pgpr.token="$GITHUB_TOKEN" -PprojectVersion=${{ steps.version_info.outputs.VERSION }}; then
echo "Error: Gradle build failed"
exit 1
fi
echo "✅ Build completed successfully"

- name: Skip nightly build
if: github.event_name == 'schedule' && steps.changes_check.outputs.has_changes == 'false'
Expand All @@ -114,17 +136,39 @@ jobs:
ZIP_URL="https://github.com/${{ github.repository }}/releases/download/${RELEASE_VERSION}/Dependency-Analytics-${RELEASE_VERSION}.zip"
echo "Downloading from: $ZIP_URL"
mkdir -p build/distributions
curl -L -o "build/distributions/intellij-dependency-analytics-${RELEASE_VERSION}.zip" "$ZIP_URL"

if ! curl -L -f -o "build/distributions/intellij-dependency-analytics-${RELEASE_VERSION}.zip" "$ZIP_URL"; then
echo "Error: Failed to download ZIP file from release"
echo "URL: $ZIP_URL"
exit 1
fi
echo "✅ Downloaded ZIP file successfully"

- name: Verify ZIP file exists
run: |
ls -la build/distributions/
# For stable releases, expect the exact filename
if [ ! -f "build/distributions/intellij-dependency-analytics-${{ steps.version_info.outputs.VERSION }}.zip" ]; then
echo "Error: ZIP file not found!"
ZIP_FILE="build/distributions/intellij-dependency-analytics-${{ steps.version_info.outputs.VERSION }}.zip"

if [ ! -f "$ZIP_FILE" ]; then
echo "Error: ZIP file not found: $ZIP_FILE"
echo "Available files:"
ls -la build/distributions/ || echo "No files found in build/distributions/"
exit 1
fi
echo "✅ ZIP file verified: build/distributions/intellij-dependency-analytics-${{ steps.version_info.outputs.VERSION }}.zip"

# Verify the ZIP file is not empty and is a valid ZIP
if [ ! -s "$ZIP_FILE" ]; then
echo "Error: ZIP file is empty: $ZIP_FILE"
exit 1
fi

if ! file "$ZIP_FILE" | grep -q "Zip archive"; then
echo "Error: File is not a valid ZIP archive: $ZIP_FILE"
file "$ZIP_FILE"
exit 1
fi

echo "✅ ZIP file verified: $ZIP_FILE"

- name: Publish to JetBrains Marketplace
if: steps.version_info.outputs.CHANNEL != 'none'
Expand Down
Loading