@@ -142,64 +142,35 @@ jobs:
142142 - name : 🏷️ Check for changes requiring versioning
143143 id : check-changes
144144 run : |
145- # Check if there are any changes that require versioning
146145 echo "🔍 Checking for changes requiring versioning..."
147146
148- # Try different strategies to detect changes
149- CHANGED_PACKAGES=0
147+ # Simple approach: check against origin/develop (like in PR workflow)
148+ # This works for both first releases and merges
149+ CHANGED_PACKAGES=$(melos list --since=origin/develop --json 2>/dev/null | jq -r '.[].name' | wc -l || echo "0")
150150
151- # Strategy 1: Check against last tag (for normal releases)
152- LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
153- if [ -n "$LAST_TAG" ]; then
154- echo "📌 Last tag found: $LAST_TAG"
155- CHANGED_PACKAGES=$(melos list --since="$LAST_TAG" --json 2>/dev/null | jq -r '.[].name' | wc -l || echo "0")
156- echo "📦 Found $CHANGED_PACKAGES packages with changes since $LAST_TAG"
157- fi
158-
159- # Strategy 2: If no changes found or no tags, check against develop branch merge base
151+ # If no changes found, it might be because we're on develop or first commit
160152 if [ "$CHANGED_PACKAGES" -eq 0 ]; then
161- echo "🔄 No changes found with tags, trying merge-base with develop..."
162- MERGE_BASE=$(git merge-base HEAD origin/develop 2>/dev/null || echo "")
163- if [ -n "$MERGE_BASE" ] && [ "$MERGE_BASE" != "$(git rev-parse HEAD)" ]; then
164- echo "🔗 Merge base with develop: $MERGE_BASE"
165- CHANGED_PACKAGES=$(melos list --since="$MERGE_BASE" --json 2>/dev/null | jq -r '.[].name' | wc -l || echo "0")
166- echo "📦 Found $CHANGED_PACKAGES packages with changes since merge base"
167- fi
168- fi
153+ echo "🔄 No changes since origin/develop, checking if this is a first release..."
169154
170- # Strategy 3: If still no changes, check if this is first release (no previous packages published)
171- if [ "$CHANGED_PACKAGES" -eq 0 ]; then
172- echo "🆕 Checking if this is a first release..."
173- # Count all packages (for first release, we want to publish everything)
174- ALL_PACKAGES=$(melos list --json 2>/dev/null | jq -r '.[].name' | wc -l || echo "0")
175-
176- # Check if any packages exist - if yes, this might be first release
177- if [ "$ALL_PACKAGES" -gt 0 ]; then
178- echo "📦 Found $ALL_PACKAGES total packages"
179- # Check if we have any git tags at all
180- TAG_COUNT=$(git tag -l | wc -l || echo "0")
181- if [ "$TAG_COUNT" -eq 0 ]; then
182- echo "🎉 No previous tags found - treating as first release"
183- CHANGED_PACKAGES=$ALL_PACKAGES
184- else
185- echo "🔍 Tags exist but no changes detected - checking HEAD~1 as fallback"
186- CHANGED_PACKAGES=$(melos list --since=HEAD~1 --json 2>/dev/null | jq -r '.[].name' | wc -l || echo "0")
187- fi
155+ # Check if we have any package tags
156+ PACKAGE_TAGS=$(git tag -l "*@*" | wc -l || echo "0")
157+ if [ "$PACKAGE_TAGS" -eq 0 ]; then
158+ echo "🎉 No package tags found - treating as first release"
159+ CHANGED_PACKAGES=$(melos list --json 2>/dev/null | jq -r '.[].name' | wc -l || echo "0")
188160 fi
189161 fi
190162
191163 echo "changed_packages=$CHANGED_PACKAGES" >> $GITHUB_OUTPUT
192- echo "✅ Final result: $CHANGED_PACKAGES packages with changes"
164+ echo "📦 Found $CHANGED_PACKAGES packages with changes"
193165
194- # Debug: List the changed packages if any
166+ # List changed packages for debugging
195167 if [ "$CHANGED_PACKAGES" -gt 0 ]; then
196168 echo "📋 Changed packages:"
197- if [ -n "$LAST_TAG" ]; then
198- melos list --since="$LAST_TAG" --long 2>/dev/null || echo "Unable to list changed packages"
199- elif [ -n "$MERGE_BASE" ] && [ "$MERGE_BASE" != "$(git rev-parse HEAD)" ]; then
200- melos list --since="$MERGE_BASE" --long 2>/dev/null || echo "Unable to list changed packages"
201- else
169+ if [ "$PACKAGE_TAGS" -eq 0 ]; then
170+ echo "First release - all packages:"
202171 melos list --long 2>/dev/null || echo "Unable to list packages"
172+ else
173+ melos list --since=origin/develop --long 2>/dev/null || echo "Unable to list changed packages"
203174 fi
204175 fi
205176
@@ -210,8 +181,19 @@ jobs:
210181 git config --global user.name "github-actions[bot]"
211182 git config --global user.email "github-actions[bot]@users.noreply.github.com"
212183
213- # Version packages based on conventional commits
214- melos version --yes --all
184+ # Version only changed packages based on conventional commits
185+ echo "🔄 Versioning packages..."
186+
187+ # Check if we have package tags (not first release)
188+ PACKAGE_TAGS=$(git tag -l "*@*" | wc -l || echo "0")
189+ if [ "$PACKAGE_TAGS" -eq 0 ]; then
190+ echo "🎉 First release - versioning all packages"
191+ melos version --yes --all
192+ else
193+ echo "📦 Versioning changed packages only"
194+ # Version only packages that have changes since origin/develop
195+ melos version --yes
196+ fi
215197
216198 - name : 📝 Generate changelogs
217199 if : steps.check-changes.outputs.changed_packages > 0
0 commit comments