@@ -138,26 +138,46 @@ jobs:
138138 run : |
139139 echo "📥 Checking for existing 'latest' release assets..."
140140
141- # Check if latest release exists
142- if gh release view latest >/dev/null 2>&1; then
143- echo "✅ Found existing 'latest' release"
144-
145- # Download existing assets to preserve them
146- mkdir -p existing_assets
147- gh release download latest --dir existing_assets 2>/dev/null || echo "No assets to download"
148-
149- # Move existing assets to artifacts directory
150- for existing_zip in existing_assets/*.zip; do
151- if [ -f "$existing_zip" ]; then
152- FILENAME=$(basename "$existing_zip")
153- echo "📦 Preserving existing: $FILENAME"
154- cp "$existing_zip" "artifacts/"
155- fi
156- done
157-
158- rm -rf existing_assets
141+ # Get changed files
142+ CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "")
143+
144+ # Determine if we should preserve existing assets
145+ PRESERVE_ASSETS=true
146+ if echo "$CHANGED_FILES" | grep -q "^\.github/workflows/create-sample-releases\.yml$"; then
147+ echo "🔧 Workflow file changed - skipping asset preservation (full rebuild)"
148+ PRESERVE_ASSETS=false
149+ elif [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.force_rebuild }}" = "true" ]; then
150+ echo "🔄 Force rebuild requested - skipping asset preservation (full rebuild)"
151+ PRESERVE_ASSETS=false
152+ elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
153+ echo "🔄 Manual trigger - skipping asset preservation (full rebuild)"
154+ PRESERVE_ASSETS=false
155+ fi
156+
157+ if [ "$PRESERVE_ASSETS" = "true" ]; then
158+ # Check if latest release exists
159+ if gh release view latest >/dev/null 2>&1; then
160+ echo "✅ Found existing 'latest' release"
161+
162+ # Download existing assets to preserve them
163+ mkdir -p existing_assets
164+ gh release download latest --dir existing_assets 2>/dev/null || echo "No assets to download"
165+
166+ # Move existing assets to artifacts directory
167+ for existing_zip in existing_assets/*.zip; do
168+ if [ -f "$existing_zip" ]; then
169+ FILENAME=$(basename "$existing_zip")
170+ echo "📦 Preserving existing: $FILENAME"
171+ cp "$existing_zip" "artifacts/"
172+ fi
173+ done
174+
175+ rm -rf existing_assets
176+ else
177+ echo "ℹ️ No existing 'latest' release found"
178+ fi
159179 else
160- echo "ℹ️ No existing 'latest' release found "
180+ echo "🧹 Skipping asset preservation - will rebuild all from scratch "
161181 fi
162182
163183 - name : Build quickstart packages from configs
@@ -266,7 +286,8 @@ jobs:
266286 --exclude=".env" \
267287 --exclude=".env.local" \
268288 --exclude=".env.production" \
269- --exclude=".env.development"
289+ --exclude=".env.development" \
290+ --exclude="release-config.yml"
270291
271292 # Add custom exclusions from config if they exist
272293 if grep -q "^exclude_patterns:" release-config.yml; then
0 commit comments