1616 schedule :
1717 # Run every day at 2 AM UTC to publish nightly builds
1818 - cron : ' 0 2 * * *'
19- push :
20- branches : [ main ]
2119
2220jobs :
2321 publish-marketplace :
@@ -47,13 +45,19 @@ jobs:
4745 # Release event - publish to stable channel
4846 VERSION="${GITHUB_REF#refs/tags/}"
4947 CHANNEL="stable"
50- elif [ "${{ github.event_name }}" == "schedule" ] || [ "${{ github.event_name }}" == "push" ]; then
51- # Scheduled run or push to main - publish to nightly channel
52- # Get current version from gradle.properties and append timestamp
53- BASE_VERSION=$(grep 'projectVersion=' gradle.properties | cut -d'=' -f2)
54- TIMESTAMP=$(date +%Y%m%d-%H%M%S)
55- VERSION="${BASE_VERSION}-nightly.${TIMESTAMP}"
56- CHANNEL="nightly"
48+ elif [ "${{ github.event_name }}" == "schedule" ]; then
49+ # Scheduled run - check if we should publish nightly
50+ if [ "${{ steps.changes_check.outputs.has_changes }}" == "true" ]; then
51+ # Get current version from gradle.properties and append timestamp
52+ BASE_VERSION=$(grep 'projectVersion=' gradle.properties | cut -d'=' -f2)
53+ TIMESTAMP=$(date +%Y%m%d-%H%M%S)
54+ VERSION="${BASE_VERSION}-nightly.${TIMESTAMP}"
55+ CHANNEL="nightly"
56+ else
57+ # No changes, set dummy values (workflow will exit early)
58+ VERSION="no-changes"
59+ CHANNEL="none"
60+ fi
5761 else
5862 echo "Unknown trigger: ${{ github.event_name }}"
5963 exit 1
@@ -62,13 +66,38 @@ jobs:
6266 echo "CHANNEL=$CHANNEL" >> $GITHUB_OUTPUT
6367 echo "Publishing version $VERSION to $CHANNEL channel"
6468
65- - name : Build or download based on trigger
66- if : github.event_name == 'schedule' || github.event_name == 'push'
69+ - name : Check for changes since last nightly
70+ if : github.event_name == 'schedule'
71+ id : changes_check
72+ run : |
73+ # Get the date from yesterday
74+ YESTERDAY=$(date -d 'yesterday' +%Y-%m-%d)
75+ echo "Checking for changes since: $YESTERDAY"
76+
77+ # Get the last nightly build commit hash (you might want to store this in a file or use a tag)
78+ # For now, we'll check if there are any commits in the last 24 hours
79+ COMMIT_COUNT=$(git log --since="$YESTERDAY" --oneline | wc -l)
80+
81+ if [ "$COMMIT_COUNT" -gt 0 ]; then
82+ echo "✅ Found $COMMIT_COUNT commits since $YESTERDAY - proceeding with nightly build"
83+ echo "has_changes=true" >> $GITHUB_OUTPUT
84+ else
85+ echo "ℹ️ No commits since $YESTERDAY - skipping nightly build"
86+ echo "has_changes=false" >> $GITHUB_OUTPUT
87+ fi
88+
89+ - name : Build nightly version
90+ if : github.event_name == 'schedule' && steps.changes_check.outputs.has_changes == 'true'
6791 run : |
68- # For nightly builds, we need to build from source
6992 echo "Building nightly version from source..."
7093 ./gradlew buildPlugin -Pgpr.username=${{ github.actor }} -Pgpr.token=${{ secrets.GITHUB_TOKEN }}
7194
95+ - name : Skip nightly build
96+ if : github.event_name == 'schedule' && steps.changes_check.outputs.has_changes == 'false'
97+ run : |
98+ echo "ℹ️ Skipping nightly build - no changes detected since yesterday"
99+ echo "This is expected behavior to avoid unnecessary builds"
100+
72101 - name : Download from release
73102 if : github.event_name == 'release'
74103 run : |
@@ -102,9 +131,10 @@ jobs:
102131 echo "✅ ZIP file verified: build/distributions/intellij-dependency-analytics-${{ steps.version_info.outputs.VERSION }}.zip"
103132
104133 - name : Publish to JetBrains Marketplace
134+ if : steps.version_info.outputs.CHANNEL != 'none'
105135 run : >
106136 ./gradlew publishPlugin
107- -PjetBrainsToken =${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }}
137+ -Ptoken =${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }}
108138 -PprojectVersion=${{ steps.version_info.outputs.VERSION }}
109139 -PjetBrainsChannel=${{ steps.version_info.outputs.CHANNEL }}
110140 -Pgpr.username=${{ github.actor }}
0 commit comments