@@ -250,40 +250,98 @@ if ! git diff-index --quiet HEAD --; then
250250 exit 1
251251fi
252252
253- # Version update
254- echo " "
255- echo " 🔧 Setting version to $VERSION ..."
256- run " npm version \" $VERSION \" --no-git-tag-version"
253+ # Check if package.json already has this version (from previous attempt)
254+ CURRENT_PACKAGE_VERSION=$( node -p " require('./package.json').version" )
255+ if [[ " $CURRENT_PACKAGE_VERSION " == " $VERSION " ]]; then
256+ echo " 📦 Version $VERSION already set in package.json"
257+ SKIP_VERSION_UPDATE=true
258+ else
259+ SKIP_VERSION_UPDATE=false
260+ fi
257261
258- # README update
259- echo " "
260- echo " 📝 Updating version in README.md... "
261- # Update version references in code examples using extended regex for precise semver matching
262- run " sed -i '' -E 's/@[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+\.[0-9]+)?(-[a-zA-Z0-9]+\.[0-9]+)*(-[a-zA-Z0-9]+)?/@' " $VERSION " '/g' README.md "
262+ if [[ " $SKIP_VERSION_UPDATE " == " false " ]] ; then
263+ # Version update
264+ echo " "
265+ echo " 🔧 Setting version to $VERSION ... "
266+ run " npm version \" $VERSION \" --no-git-tag-version "
263267
264- # Update URL-encoded version references in shield links
265- echo " 📝 Updating version in README.md shield links..."
266- run " sed -i '' -E 's/npm%3Axcodebuildmcp%40[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+\.[0-9]+)?(-[a-zA-Z0-9]+\.[0-9]+)*(-[a-zA-Z0-9]+)?/npm%3Axcodebuildmcp%40'" $VERSION " '/g' README.md"
268+ # README update
269+ echo " "
270+ echo " 📝 Updating version in README.md..."
271+ # Update version references in code examples using extended regex for precise semver matching
272+ run " sed -i '' -E 's/@[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+\.[0-9]+)?(-[a-zA-Z0-9]+\.[0-9]+)*(-[a-zA-Z0-9]+)?/@'" $VERSION " '/g' README.md"
267273
268- # Git operations
269- echo " "
270- echo " 📦 Committing version changes..."
271- run " git add package.json README.md"
272- run " git commit -m \" Release v$VERSION \" "
273- run " git tag \" v$VERSION \" "
274+ # Update URL-encoded version references in shield links
275+ echo " 📝 Updating version in README.md shield links..."
276+ run " sed -i '' -E 's/npm%3Axcodebuildmcp%40[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+\.[0-9]+)?(-[a-zA-Z0-9]+\.[0-9]+)*(-[a-zA-Z0-9]+)?/npm%3Axcodebuildmcp%40'" $VERSION " '/g' README.md"
277+
278+ # Git operations
279+ echo " "
280+ echo " 📦 Committing version changes..."
281+ run " git add package.json README.md"
282+ run " git commit -m \" Release v$VERSION \" "
283+ else
284+ echo " ⏭️ Skipping version update (already done)"
285+ fi
286+
287+ # Create or recreate tag at current HEAD
288+ echo " 🏷️ Creating tag v$VERSION ..."
289+ run " git tag -f \" v$VERSION \" "
274290
275291echo " "
276292echo " 🚀 Pushing to origin..."
277293run " git push origin $BRANCH --tags"
278294
295+ # Monitor the workflow and handle failures
279296echo " "
280- echo " 🎯 Tag pushed! GitHub will automatically:"
281- echo " - Detect the new tag and start the release workflow"
282- echo " - Bundle AXe artifacts"
283- echo " - Build the project"
284- echo " - Publish to NPM"
285- echo " - Create the GitHub release"
286- echo " "
287- echo " ✅ Release v$VERSION initiated!"
288- echo " 📝 Monitor the GitHub Actions workflow for completion"
289- echo " 📦 View workflow: https://github.com/cameroncooke/XcodeBuildMCP/actions"
297+ echo " ⏳ Monitoring GitHub Actions workflow..."
298+ echo " This may take a few minutes..."
299+
300+ # Wait for workflow to start
301+ sleep 5
302+
303+ # Get the workflow run ID for this tag
304+ RUN_ID=$( gh run list --workflow=release.yml --limit=1 --json databaseId --jq ' .[0].databaseId' )
305+
306+ if [[ -n " $RUN_ID " ]]; then
307+ echo " 📊 Workflow run ID: $RUN_ID "
308+ echo " 🔍 Watching workflow progress..."
309+ echo " (Press Ctrl+C to detach and monitor manually)"
310+ echo " "
311+
312+ # Watch the workflow with exit status
313+ if gh run watch " $RUN_ID " --exit-status; then
314+ echo " "
315+ echo " ✅ Release v$VERSION completed successfully!"
316+ echo " 📦 View on NPM: https://www.npmjs.com/package/xcodebuildmcp/v/$VERSION "
317+ echo " 🎉 View release: https://github.com/cameroncooke/XcodeBuildMCP/releases/tag/v$VERSION "
318+ else
319+ echo " "
320+ echo " ❌ CI workflow failed!"
321+ echo " "
322+ echo " 🧹 Cleaning up tags only (keeping version commit)..."
323+
324+ # Delete remote tag
325+ echo " - Deleting remote tag v$VERSION ..."
326+ git push origin :refs/tags/v$VERSION 2> /dev/null || true
327+
328+ # Delete local tag
329+ echo " - Deleting local tag v$VERSION ..."
330+ git tag -d v$VERSION
331+
332+ echo " "
333+ echo " ✅ Tag cleanup complete!"
334+ echo " "
335+ echo " ℹ️ The version commit remains in your history."
336+ echo " 📝 To retry after fixing issues:"
337+ echo " 1. Fix the CI issues"
338+ echo " 2. Commit your fixes"
339+ echo " 3. Run: ./scripts/release.sh $VERSION "
340+ echo " "
341+ echo " 🔍 To see what failed: gh run view $RUN_ID --log-failed"
342+ exit 1
343+ fi
344+ else
345+ echo " ⚠️ Could not find workflow run. Please check manually:"
346+ echo " https://github.com/cameroncooke/XcodeBuildMCP/actions"
347+ fi
0 commit comments