-
Notifications
You must be signed in to change notification settings - Fork 1
286 lines (248 loc) · 10.5 KB
/
build-orchestrator.yml
File metadata and controls
286 lines (248 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
name: Build Orchestrator
on:
workflow_dispatch:
inputs:
version:
description: 'Version (YY.MM.DD - leave empty for auto-generation)'
required: false
type: string
default: ''
custom_url:
description: 'Custom App URL (optional - disables auto-update, version bump, draft)'
required: false
type: string
default: ''
build_macos:
description: '🍎 macOS (x64 + ARM64)'
required: true
type: boolean
default: true
build_windows:
description: '🪟 Windows (x64)'
required: true
type: boolean
default: true
build_linux:
description: '🐧 Linux (AppImage)'
required: true
type: boolean
default: true
build_setapp:
description: '📦 Setapp (Universal macOS)'
required: true
type: boolean
default: true
build_variant:
description: 'Build variant (ignored if custom URL provided)'
required: true
type: choice
options:
- production
- beta
default: production
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
version_tag: ${{ steps.version.outputs.tag }}
should_bump_version: ${{ steps.logic.outputs.should_bump }}
should_create_draft: ${{ steps.logic.outputs.should_draft }}
build_variant: ${{ steps.logic.outputs.variant }}
steps:
- name: Generate or validate version
id: version
run: |
if [ -z "${{ inputs.version }}" ]; then
VERSION=$(date -u +'%y.%-m.%-d')
echo "📅 Auto-generated: v$VERSION"
else
VERSION="${{ inputs.version }}"
if [[ ! "$VERSION" =~ ^[0-9]{2}\.[0-9]{1,2}\.[0-9]{1,2}(-beta\.[0-9]+)?$ ]]; then
echo "❌ Invalid version format"
exit 1
fi
echo "✅ Using: v$VERSION"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
- name: Determine workflow logic
id: logic
run: |
SHOULD_BUMP="true"
SHOULD_DRAFT="false"
VARIANT="${{ inputs.build_variant }}"
# Custom URL overrides
if [ -n "${{ inputs.custom_url }}" ]; then
echo "::notice title=Custom URL Mode::Auto-update disabled, version bump skipped, draft release skipped"
SHOULD_BUMP="false"
SHOULD_DRAFT="false"
VARIANT="custom"
# Verify only standard platforms selected
if [ "${{ inputs.build_setapp }}" == "true" ]; then
echo "::error title=Invalid Configuration::Setapp builds not allowed with custom URL"
exit 1
fi
fi
# Draft release only for production + all platforms
if [ "$VARIANT" == "production" ] && \
[ "${{ inputs.build_macos }}" == "true" ] && \
[ "${{ inputs.build_windows }}" == "true" ] && \
[ "${{ inputs.build_linux }}" == "true" ] && \
[ "${{ inputs.build_setapp }}" == "true" ]; then
SHOULD_DRAFT="true"
fi
# Beta builds don't get draft releases
if [ "$VARIANT" == "beta" ]; then
SHOULD_DRAFT="false"
fi
echo "should_bump=$SHOULD_BUMP" >> $GITHUB_OUTPUT
echo "should_draft=$SHOULD_DRAFT" >> $GITHUB_OUTPUT
echo "variant=$VARIANT" >> $GITHUB_OUTPUT
bump-version:
needs: prepare
if: needs.prepare.outputs.should_bump_version == 'true'
uses: ./.github/workflows/bump-version.yml
with:
version: ${{ needs.prepare.outputs.version }}
# Always creates temp branch - will merge to main only if draft release succeeds
build-macos:
needs: [prepare, bump-version]
if: |
always() &&
inputs.build_macos == true &&
(needs.bump-version.result == 'success' || needs.bump-version.result == 'skipped')
uses: ./.github/workflows/release_desktop_app.yml
secrets: inherit
with:
platform: macos-latest
build_variant: ${{ needs.prepare.outputs.build_variant }}
custom_url: ${{ inputs.custom_url }}
git_ref: ${{ needs.bump-version.outputs.branch_name || github.ref }}
build-windows:
needs: [prepare, bump-version]
if: |
always() &&
inputs.build_windows == true &&
(needs.bump-version.result == 'success' || needs.bump-version.result == 'skipped')
uses: ./.github/workflows/release_desktop_app.yml
secrets: inherit
with:
platform: windows-latest
build_variant: ${{ needs.prepare.outputs.build_variant }}
custom_url: ${{ inputs.custom_url }}
git_ref: ${{ needs.bump-version.outputs.branch_name || github.ref }}
build-linux:
needs: [prepare, bump-version]
if: |
always() &&
inputs.build_linux == true &&
(needs.bump-version.result == 'success' || needs.bump-version.result == 'skipped')
uses: ./.github/workflows/release_desktop_app.yml
secrets: inherit
with:
platform: ubuntu-latest
build_variant: ${{ needs.prepare.outputs.build_variant }}
custom_url: ${{ inputs.custom_url }}
git_ref: ${{ needs.bump-version.outputs.branch_name || github.ref }}
checkout_branch: '' # Use git_ref instead - will fall back to current branch
build-setapp:
needs: [prepare, bump-version]
if: |
always() &&
inputs.build_setapp == true &&
inputs.custom_url == '' &&
(needs.bump-version.result == 'success' || needs.bump-version.result == 'skipped')
uses: ./.github/workflows/build-setapp.yml
secrets: inherit
with:
git_ref: ${{ needs.bump-version.outputs.branch_name || github.ref }}
create-draft:
needs: [prepare, build-macos, build-windows, build-linux]
if: |
always() &&
needs.prepare.outputs.should_create_draft == 'true' &&
(needs.build-macos.result == 'success' || needs.build-macos.result == 'skipped') &&
(needs.build-windows.result == 'success' || needs.build-windows.result == 'skipped') &&
(needs.build-linux.result == 'success' || needs.build-linux.result == 'skipped')
uses: ./.github/workflows/create-draft-release.yml
secrets: inherit
with:
version: ${{ needs.prepare.outputs.version }}
version_tag: ${{ needs.prepare.outputs.version_tag }}
artifact_names: 'macos-build,windows-build,linux-build'
merge-to-main:
needs: [prepare, bump-version, create-draft]
if: |
always() &&
needs.create-draft.result == 'success' &&
needs.bump-version.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
fetch-depth: 0
- name: Merge temporary branch to main
run: |
TEMP_BRANCH="${{ needs.bump-version.outputs.branch_name }}"
TARGET_BRANCH="${{ github.ref_name }}"
echo "📦 Merging $TEMP_BRANCH → $TARGET_BRANCH"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Fetch the temp branch
git fetch origin "$TEMP_BRANCH"
# Merge temp branch (fast-forward, should be clean)
git merge --ff-only "origin/$TEMP_BRANCH" -m "Merge version bump v${{ needs.prepare.outputs.version }}
Draft release created successfully.
Temporary branch: $TEMP_BRANCH
🤖 Generated by GitHub Actions
Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# Push to main
git push origin "HEAD:$TARGET_BRANCH"
echo "✅ Merged $TEMP_BRANCH → $TARGET_BRANCH"
- name: Delete temporary branch
run: |
TEMP_BRANCH="${{ needs.bump-version.outputs.branch_name }}"
echo "🗑️ Deleting temporary branch: $TEMP_BRANCH"
git push origin --delete "$TEMP_BRANCH"
echo "✅ Deleted: $TEMP_BRANCH"
- name: Summary
run: |
echo "### ✅ Version Merged to Main" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: v${{ needs.prepare.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Target Branch**: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "- **Temporary Branch**: ${{ needs.bump-version.outputs.branch_name }} (deleted)" >> $GITHUB_STEP_SUMMARY
summary:
needs: [prepare, build-macos, build-windows, build-linux, build-setapp, create-draft, merge-to-main]
if: always()
runs-on: ubuntu-latest
steps:
- name: Generate summary
run: |
echo "# 📦 Build Complete: v${{ needs.prepare.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Variant**: ${{ needs.prepare.outputs.build_variant }}" >> $GITHUB_STEP_SUMMARY
if [ -n "${{ inputs.custom_url }}" ]; then
echo "**Custom URL**: ${{ inputs.custom_url }}" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Platforms Built**:" >> $GITHUB_STEP_SUMMARY
echo "- macOS: ${{ needs.build-macos.result == 'success' && '✅' || '⬜' }}" >> $GITHUB_STEP_SUMMARY
echo "- Windows: ${{ needs.build-windows.result == 'success' && '✅' || '⬜' }}" >> $GITHUB_STEP_SUMMARY
echo "- Linux: ${{ needs.build-linux.result == 'success' && '✅' || '⬜' }}" >> $GITHUB_STEP_SUMMARY
echo "- Setapp: ${{ needs.build-setapp.result == 'success' && '✅' || '⬜' }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.create-draft.result }}" == "success" ]; then
echo "**🎉 Draft Release**: [View Releases](https://github.com/${{ github.repository }}/releases)" >> $GITHUB_STEP_SUMMARY
echo "**✅ Version**: Merged to ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
else
echo "**📥 Artifacts**: [Download from Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.bump-version.result }}" == "success" ]; then
echo "**⚠️ Temporary Branch**: \`${{ needs.bump-version.outputs.branch_name }}\` (not merged to main)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "_Temp branch will remain until manually cleaned up_" >> $GITHUB_STEP_SUMMARY
fi
fi