@@ -81,38 +81,44 @@ jobs:
8181 PROJECT_VERSION=$(sed -nE 's/.*MARKETING_VERSION = ([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?);.*/\1/p' MiddleDrag.xcodeproj/project.pbxproj | head -n 1)
8282
8383 if [ "$VERSION" != "$PROJECT_VERSION" ]; then
84- echo "Version mismatch ($PROJECT_VERSION vs $VERSION). Bumping..."
84+ echo "Version mismatch ($PROJECT_VERSION vs $VERSION). Bumping on releases branch ..."
8585 echo "kill-pipeline=true" >> $GITHUB_OUTPUT
8686
87- # Determine the branch to update
88- if [[ "$GITHUB_REF" == refs/heads/* ]]; then
89- BRANCH_NAME=${GITHUB_REF#refs/heads/}
90- else
91- BRANCH_NAME="main"
92- echo "Tag push detected, using $BRANCH_NAME"
93- fi
87+ # Create a detached release commit based on current main content
88+ git checkout --detach HEAD
9489
95- git fetch origin "$BRANCH_NAME"
96- git checkout -b "version-bump-$VERSION"
90+ # Bump version inline (replaces bump-version.sh for CI)
91+ sed -i '' -E "s/MARKETING_VERSION = [0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?/MARKETING_VERSION = $VERSION/g" \
92+ MiddleDrag.xcodeproj/project.pbxproj
9793
98- NOTES="${{ inputs.notes }}"
99- ./bump-version.sh "$VERSION" "$NOTES"
94+ COUNT=$(grep -c "MARKETING_VERSION = $VERSION" MiddleDrag.xcodeproj/project.pbxproj || echo "0")
95+ if [ "$COUNT" -ne 2 ]; then
96+ echo "Error: Expected exactly 2 MARKETING_VERSION updates, found $COUNT"
97+ exit 1
98+ fi
10099
101- # Rebase on latest main in case of new commits
102- git fetch origin "$BRANCH_NAME"
103- git rebase "origin/$BRANCH_NAME"
100+ git add MiddleDrag.xcodeproj/project.pbxproj
101+ git commit -m "Release v$VERSION"
104102
105- # Update main branch to point to new commit
106- git checkout "$BRANCH_NAME"
107- git reset --hard "version-bump-$VERSION"
103+ NEW_SHA=$(git rev-parse HEAD)
108104
109- # Re-create the tag to point to HEAD after rebase
110- git tag -f -a "v$VERSION" -m "$(git tag -l --format='%(contents)' "v$VERSION" 2>/dev/null || echo "Release v$VERSION")"
105+ # Point the releases branch at this commit
106+ git branch -f releases HEAD
107+ git push origin releases --force
111108
112- git push origin "$BRANCH_NAME" --force-with-lease
109+ # Re-create the tag to point to the release commit
110+ NOTES="${{ inputs.notes }}"
111+ TAG_MSG=$(git tag -l --format='%(contents)' "v$VERSION" 2>/dev/null || echo "")
112+ if [ -n "$NOTES" ]; then
113+ TAG_MSG="$NOTES"
114+ elif [ -z "$TAG_MSG" ]; then
115+ TAG_MSG="Release v$VERSION"
116+ fi
117+ git tag -f -a "v$VERSION" -m "$TAG_MSG"
113118 git push origin "v$VERSION" --force
114119
115- echo "NEW_SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
120+ echo "NEW_SHA=$NEW_SHA" >> $GITHUB_OUTPUT
121+ echo "✓ Release commit created on 'releases' branch (main untouched)"
116122 else
117123 echo "Version matches. Proceeding..."
118124 echo "NEW_SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
0 commit comments