@@ -121,6 +121,7 @@ jobs:
121121 uses : ./.github/workflows/bump-version.yml
122122 with :
123123 version : ${{ needs.prepare.outputs.version }}
124+ # Always creates temp branch - will merge to main only if draft release succeeds
124125
125126 build-macos :
126127 needs : [prepare, bump-version]
@@ -134,7 +135,7 @@ jobs:
134135 platform : macos-latest
135136 build_variant : ${{ needs.prepare.outputs.build_variant }}
136137 custom_url : ${{ inputs.custom_url }}
137- git_ref : ${{ needs.bump-version.outputs.version_tag || github.ref }}
138+ git_ref : ${{ needs.bump-version.outputs.branch_name || github.ref }}
138139
139140 build-windows :
140141 needs : [prepare, bump-version]
@@ -148,7 +149,7 @@ jobs:
148149 platform : windows-latest
149150 build_variant : ${{ needs.prepare.outputs.build_variant }}
150151 custom_url : ${{ inputs.custom_url }}
151- git_ref : ${{ needs.bump-version.outputs.version_tag || github.ref }}
152+ git_ref : ${{ needs.bump-version.outputs.branch_name || github.ref }}
152153
153154 build-linux :
154155 needs : [prepare, bump-version]
@@ -162,7 +163,7 @@ jobs:
162163 platform : ubuntu-latest
163164 build_variant : ${{ needs.prepare.outputs.build_variant }}
164165 custom_url : ${{ inputs.custom_url }}
165- git_ref : ${{ needs.bump-version.outputs.version_tag || github.ref }}
166+ git_ref : ${{ needs.bump-version.outputs.branch_name || github.ref }}
166167 checkout_branch : ' ' # Use git_ref instead - will fall back to current branch
167168
168169 build-setapp :
@@ -175,7 +176,7 @@ jobs:
175176 uses : ./.github/workflows/build-setapp.yml
176177 secrets : inherit
177178 with :
178- git_ref : ${{ needs.bump-version.outputs.version_tag || github.ref }} # Use current branch instead of hardcoding
179+ git_ref : ${{ needs.bump-version.outputs.branch_name || github.ref }}
179180
180181 create-draft :
181182 needs : [prepare, build-macos, build-windows, build-linux]
@@ -192,8 +193,65 @@ jobs:
192193 version_tag : ${{ needs.prepare.outputs.version_tag }}
193194 artifact_names : ' macos-build,windows-build,linux-build'
194195
196+ merge-to-main :
197+ needs : [prepare, bump-version, create-draft]
198+ if : |
199+ always() &&
200+ needs.create-draft.result == 'success' &&
201+ needs.bump-version.result == 'success'
202+ runs-on : ubuntu-latest
203+
204+ steps :
205+ - name : Checkout repository
206+ uses : actions/checkout@v4
207+ with :
208+ ref : ${{ github.ref_name }}
209+ fetch-depth : 0
210+
211+ - name : Merge temporary branch to main
212+ run : |
213+ TEMP_BRANCH="${{ needs.bump-version.outputs.branch_name }}"
214+ TARGET_BRANCH="${{ github.ref_name }}"
215+
216+ echo "📦 Merging $TEMP_BRANCH → $TARGET_BRANCH"
217+
218+ git config user.name "github-actions[bot]"
219+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
220+
221+ # Fetch the temp branch
222+ git fetch origin "$TEMP_BRANCH"
223+
224+ # Merge temp branch (fast-forward, should be clean)
225+ git merge --ff-only "origin/$TEMP_BRANCH" -m "Merge version bump v${{ needs.prepare.outputs.version }}
226+
227+ Draft release created successfully.
228+ Temporary branch: $TEMP_BRANCH
229+
230+ 🤖 Generated by GitHub Actions
231+ Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
232+
233+ # Push to main
234+ git push origin "HEAD:$TARGET_BRANCH"
235+
236+ echo "✅ Merged $TEMP_BRANCH → $TARGET_BRANCH"
237+
238+ - name : Delete temporary branch
239+ run : |
240+ TEMP_BRANCH="${{ needs.bump-version.outputs.branch_name }}"
241+ echo "🗑️ Deleting temporary branch: $TEMP_BRANCH"
242+ git push origin --delete "$TEMP_BRANCH"
243+ echo "✅ Deleted: $TEMP_BRANCH"
244+
245+ - name : Summary
246+ run : |
247+ echo "### ✅ Version Merged to Main" >> $GITHUB_STEP_SUMMARY
248+ echo "" >> $GITHUB_STEP_SUMMARY
249+ echo "- **Version**: v${{ needs.prepare.outputs.version }}" >> $GITHUB_STEP_SUMMARY
250+ echo "- **Target Branch**: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
251+ echo "- **Temporary Branch**: ${{ needs.bump-version.outputs.branch_name }} (deleted)" >> $GITHUB_STEP_SUMMARY
252+
195253 summary :
196- needs : [prepare, build-macos, build-windows, build-linux, build-setapp, create-draft]
254+ needs : [prepare, build-macos, build-windows, build-linux, build-setapp, create-draft, merge-to-main ]
197255 if : always()
198256 runs-on : ubuntu-latest
199257 steps :
@@ -217,6 +275,12 @@ jobs:
217275 echo "" >> $GITHUB_STEP_SUMMARY
218276 if [ "${{ needs.create-draft.result }}" == "success" ]; then
219277 echo "**🎉 Draft Release**: [View Releases](https://github.com/${{ github.repository }}/releases)" >> $GITHUB_STEP_SUMMARY
278+ echo "**✅ Version**: Merged to ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
220279 else
221280 echo "**📥 Artifacts**: [Download from Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY
281+ if [ "${{ needs.bump-version.result }}" == "success" ]; then
282+ echo "**⚠️ Temporary Branch**: \`${{ needs.bump-version.outputs.branch_name }}\` (not merged to main)" >> $GITHUB_STEP_SUMMARY
283+ echo "" >> $GITHUB_STEP_SUMMARY
284+ echo "_Temp branch will remain until manually cleaned up_" >> $GITHUB_STEP_SUMMARY
285+ fi
222286 fi
0 commit comments