-
Notifications
You must be signed in to change notification settings - Fork 1
484 lines (406 loc) Β· 20.6 KB
/
release.yml
File metadata and controls
484 lines (406 loc) Β· 20.6 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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
name: Auto-Build-Firmware
run-name: Building Firmware...
on:
push:
branches: [ main, master ] # Only active on main branch for nightly builds
pull_request:
branches: [ main, master ]
release:
types: [published]
workflow_dispatch: # Allow manual triggering
jobs:
build-firmware:
name: Build Multi-Target Firmware
runs-on: windows-2022
permissions:
contents: write
actions: read
strategy:
matrix:
target: [SimGETRO_Public, SimGETRO_EarlyHardware]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Clean build artifacts
run: |
make clean_all
- name: Build firmware for ${{ matrix.target }}
run: |
make TARGET=${{ matrix.target }} all -j4
- name: Create output directory and copy firmware files
run: |
mkdir "output-${{ matrix.target }}"
Copy-Item "./build/${{ matrix.target }}/SimGEKI.bin" -Destination "./output-${{ matrix.target }}/SimGEKI-${{ matrix.target }}.bin" -Force
Copy-Item "./build/${{ matrix.target }}/SimGEKI.hex" -Destination "./output-${{ matrix.target }}/SimGEKI-${{ matrix.target }}.hex" -Force
shell: pwsh
- name: Upload firmware to artifacts (bin)
uses: actions/upload-artifact@v4
with:
name: SimGEKI-${{ matrix.target }}_firmware_bin
path: ./output-${{ matrix.target }}/SimGEKI-${{ matrix.target }}.bin
retention-days: 90
- name: Upload firmware to artifacts (hex)
uses: actions/upload-artifact@v4
with:
name: SimGEKI-${{ matrix.target }}_firmware_hex
path: ./output-${{ matrix.target }}/SimGEKI-${{ matrix.target }}.hex
retention-days: 90
- name: Upload files to release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'nightly-builds')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
./output-${{ matrix.target }}/SimGEKI-${{ matrix.target }}.bin
./output-${{ matrix.target }}/SimGEKI-${{ matrix.target }}.hex
# Upload release builds to gh-pages standard folder
upload-release-to-gh-pages:
name: Upload Release to gh-pages
runs-on: windows-2022
permissions:
contents: write
actions: read
needs: build-firmware
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'nightly-builds')
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./release-artifacts
- name: Setup gh-pages branch
run: |
# Configure git user
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
# Checkout existing gh-pages branch
Write-Host "Checking out gh-pages branch..."
git fetch origin gh-pages
git checkout gh-pages
shell: pwsh
- name: Prepare standard release files
run: |
# Create standard directory if it doesn't exist
if (-not (Test-Path "./standard")) {
New-Item -ItemType Directory -Path "./standard" -Force
}
# Copy all firmware files to standard directory with detailed logging
Write-Host "Copying firmware files to standard directory..."
$releaseFiles = Get-ChildItem -Path "./release-artifacts" -Recurse -Include "*.bin", "*.hex"
if ($releaseFiles.Count -eq 0) {
Write-Host "No firmware files found in release-artifacts directory!"
Get-ChildItem -Path "./release-artifacts" -Recurse | ForEach-Object { Write-Host "Found: $($_.FullName)" }
exit 1
}
$releaseFiles | ForEach-Object {
$destPath = "./standard/$($_.Name)"
Write-Host "Copying $($_.FullName) to $destPath"
Copy-Item $_.FullName -Destination $destPath -Force
if (Test-Path $destPath) {
Write-Host "β Successfully copied $($_.Name)"
} else {
Write-Host "β Failed to copy $($_.Name)"
}
}
# Verify files were copied
Write-Host "Verifying files in standard directory:"
$copiedFiles = Get-ChildItem -Path "./standard" -Recurse -Include "*.bin", "*.hex"
$copiedFiles | ForEach-Object { Write-Host " β $($_.Name)" }
# Create index file for easy browsing
$date = Get-Date -Format 'yyyy-MM-dd HH:mm:ss UTC'
$indexContent = "# SimGEKI Standard Release Firmware Files`n`n"
$indexContent += "Last updated: $date`n"
$indexContent += "Release tag: ${{ github.ref_name }}`n`n"
$indexContent += "## Available Files:`n`n"
$copiedFiles | ForEach-Object {
$indexContent += "- [$($_.Name)](./$($_.Name))`n"
}
$indexContent += "`n## Direct Access URLs:`n`n"
$indexContent += "Base URL: ``https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/standard/```n`n"
$copiedFiles | ForEach-Object {
$indexContent += "- [$($_.Name)](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/standard/$($_.Name))`n"
}
$indexContent | Out-File -FilePath "./standard/README.md" -Encoding UTF8
# Clean up ALL files except firmware files and READMEs
Write-Host "Cleaning up all non-firmware files from gh-pages..."
Get-ChildItem -Path "." -Recurse | Where-Object {
-not $_.PSIsContainer -and
$_.Name -notmatch "\.(bin|hex|md)$"
} | Remove-Item -Force -ErrorAction SilentlyContinue
# Also remove empty directories except standard and nightly
Get-ChildItem -Path "." -Recurse -Directory | Where-Object {
$_.Name -ne "standard" -and
$_.Name -ne "nightly" -and
(Get-ChildItem $_.FullName -Force | Measure-Object).Count -eq 0
} | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
shell: pwsh
- name: Commit and push to gh-pages
run: |
git add standard/
# Check if there are changes to commit
$changes = git diff --staged --name-only
if ($changes) {
git commit -m "π¦ Update standard release files - ${{ github.ref_name }}
Release: ${{ github.ref_name }}
Commit: ${{ github.sha }}
Date: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss UTC')"
git push origin gh-pages
Write-Host "Successfully pushed standard release files to gh-pages"
} else {
Write-Host "No changes to commit for standard release"
}
shell: pwsh
# Nightly builds job - collect all artifacts and update nightly branch
update-nightly-builds:
name: Update Nightly Branch
runs-on: windows-2022
permissions:
contents: write
actions: read
needs: build-firmware
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && github.event_name == 'push'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./nightly-artifacts
- name: Prepare nightly release files
run: |
mkdir "nightly-release"
# Copy all 'bin' & 'hex' files into 'nightly-release' directory
Get-ChildItem -Path "./nightly-artifacts" -Recurse -Include "*.bin", "*.hex" | ForEach-Object {
Copy-Item $_.FullName -Destination "./nightly-release/" -Force
}
# Show file list for debugging
Write-Host "Files prepared for nightly release:"
Get-ChildItem -Path "./nightly-release/"
shell: pwsh
- name: Create/Update nightly branch and commit files
run: |
# Configure git user
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
# Clean up any existing nightly references to avoid conflicts
Write-Host "Cleaning up existing nightly references..."
try { git branch -D nightly } catch { Write-Host "Local nightly branch not found" }
try { git tag -d nightly } catch { Write-Host "Local nightly tag not found" }
try { git push origin --delete nightly } catch { Write-Host "Remote nightly branch/tag not found" }
# Create or switch to nightly branch from current commit
Write-Host "Creating fresh nightly branch..."
git checkout -b nightly
# Copy firmware files to the root for easy access
Write-Host "Copying firmware files to nightly branch..."
Copy-Item "./nightly-release/*" -Destination "./" -Force
# Add firmware files to git
git add *.bin *.hex
# Check if there are changes to commit
$changes = git diff --staged --name-only
if ($changes) {
Write-Host "Committing firmware files..."
git commit -m "π Nightly Build - Auto-updated
π
Build Date: ${{ github.event.head_commit.timestamp }}
π¨ Commit: ${{ github.sha }}
π€ Author: ${{ github.event.head_commit.author.name }}
π¬ Message: ${{ github.event.head_commit.message }}
Available firmware variants:
- SimGEKI-SimGETRO_Public.bin/hex - Public release version
- SimGEKI-SimGETRO_EarlyHardware.bin/hex - Early hardware version"
# Push the nightly branch explicitly specifying it's a branch
Write-Host "Pushing nightly branch to remote..."
git push origin refs/heads/nightly:refs/heads/nightly --force
} else {
Write-Host "No changes to commit"
}
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete existing nightly release and tag
continue-on-error: true
run: |
# δ½Ώη¨ GitHub CLI ε ι€η°ζη nightly releaseοΌε¦ζεε¨οΌ
Write-Host "Attempting to delete existing nightly release..."
try {
gh release delete nightly --yes
Write-Host "Existing nightly release deleted"
} catch {
Write-Host "No existing nightly release found or already deleted"
}
# ε ι€θΏη¨ nightly tagοΌε¦ζεε¨οΌ
Write-Host "Attempting to delete remote nightly tag..."
try {
git push origin --delete refs/tags/nightly
Write-Host "Remote nightly tag deleted"
} catch {
Write-Host "Remote nightly tag not found"
}
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create new nightly release with updated info
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly
target_commitish: nightly
name: "SimGEKI Firmware Nightly Builds (Updated ${{ github.event.head_commit.timestamp }})"
body: |
# π SimGEKI Nightly Builds - Auto Updated!
## βΉοΈ What is this?
Nightly Builds are the latest development versions of the SimGEKI firmware, automatically built with every commit to the main branch. This means you always have access to the most recent changes and features, but please note that these builds are not guaranteed to be stable.
## π How to use?
Download the firmware files from the assets below and flash them to your SimGEKI device. Make sure to check the compatibility with your hardware version.
π **Flash Instructions**: [Update Firmware Guide](https://sim.bysb.net/#/simgeki2/configs/update-firmware/)
## π Latest Build Information
π
**Build Time**: ${{ github.event.head_commit.timestamp }}
π¨ **Source Commit**: [`${{ github.sha }}`](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
π€ **Author**: ${{ github.event.head_commit.author.name }}
π¬ **Commit Message**:
```
${{ github.event.head_commit.message }}
```
## π¦ Available Firmware Variants
| Variant | Description | Download |
|---------|-------------|----------|
| **SimGETRO_Public** | Public release version | [π₯ BIN](https://github.com/${{ github.repository }}/releases/download/nightly/SimGEKI-SimGETRO_Public.bin) / [π₯ HEX](https://github.com/${{ github.repository }}/releases/download/nightly/SimGEKI-SimGETRO_Public.hex) |
| **SimGETRO_EarlyHardware** | Early hardware version | [π₯ BIN](https://github.com/${{ github.repository }}/releases/download/nightly/SimGEKI-SimGETRO_EarlyHardware.bin) / [π₯ HEX](https://github.com/${{ github.repository }}/releases/download/nightly/SimGEKI-SimGETRO_EarlyHardware.hex) |
## β οΈ Important Notes
- π **Auto-Updated**: This release is automatically updated with every commit to the main branch
- π§ͺ **Development Build**: These builds may be unstable and are intended for testing
- π
**Last Updated**: ${{ github.event.head_commit.timestamp }}
- π **Repository**: [SimDevices-Project/SimGEKI](https://github.com/${{ github.repository }})
---
π‘ **Tip**: For stable releases, check the [official releases](https://github.com/${{ github.repository }}/releases) page.
prerelease: true
files: |
./nightly-release/*
- name: Upload nightly builds to gh-pages
run: |
# Configure git user first
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
# Check if gh-pages branch exists remotely
Write-Host "Checking out gh-pages branch for nightly upload..."
git fetch origin gh-pages
git checkout gh-pages
Write-Host "Current working directory after checkout: $(Get-Location)"
shell: pwsh
- name: Download artifacts for gh-pages upload
uses: actions/download-artifact@v4
with:
path: ./nightly-artifacts-ghpages
- name: Prepare and upload nightly files to gh-pages
run: |
# Prepare nightly files from artifacts
Write-Host "Preparing nightly files from artifacts..."
if (-not (Test-Path "./nightly-release-ghpages")) {
New-Item -ItemType Directory -Path "./nightly-release-ghpages" -Force
}
# Copy all 'bin' & 'hex' files from artifacts
$artifactFiles = Get-ChildItem -Path "./nightly-artifacts-ghpages" -Recurse -Include "*.bin", "*.hex"
Write-Host "Artifact files found:"
$artifactFiles | ForEach-Object { Write-Host " - $($_.Name)" }
if ($artifactFiles.Count -eq 0) {
Write-Host "No firmware files found in artifacts!"
Get-ChildItem -Path "./nightly-artifacts-ghpages" -Recurse | ForEach-Object { Write-Host "Found: $($_.FullName)" }
exit 1
}
$artifactFiles | ForEach-Object {
Copy-Item $_.FullName -Destination "./nightly-release-ghpages/" -Force
Write-Host "Copied $($_.Name) to nightly-release-ghpages/"
}
# Create nightly directory if it doesn't exist
Write-Host "Creating nightly directory..."
if (-not (Test-Path "./nightly")) {
New-Item -ItemType Directory -Path "./nightly" -Force
Write-Host "Created nightly directory"
} else {
Write-Host "Nightly directory already exists"
}
# Copy all firmware files to nightly directory with detailed logging
Write-Host "Copying firmware files to nightly directory..."
$nightlyFiles = Get-ChildItem -Path "./nightly-release-ghpages" -Recurse -Include "*.bin", "*.hex"
$nightlyFiles | ForEach-Object {
$destPath = "./nightly/$($_.Name)"
Write-Host "Copying $($_.FullName) to $destPath"
Copy-Item $_.FullName -Destination $destPath -Force
if (Test-Path $destPath) {
Write-Host "β Successfully copied $($_.Name)"
} else {
Write-Host "β Failed to copy $($_.Name)"
}
}
# Verify files were copied
Write-Host "Verifying files in nightly directory:"
$copiedFiles = Get-ChildItem -Path "./nightly" -Recurse -Include "*.bin", "*.hex"
if ($copiedFiles.Count -eq 0) {
Write-Host "ERROR: No files found in nightly directory after copy!"
Write-Host "Directory contents:"
Get-ChildItem -Path "./nightly" | ForEach-Object { Write-Host " - $($_.Name)" }
exit 1
} else {
$copiedFiles | ForEach-Object { Write-Host " β $($_.Name)" }
}
# Create index file for easy browsing
Write-Host "Creating README.md for nightly directory..."
$date = Get-Date -Format 'yyyy-MM-dd HH:mm:ss UTC'
$indexContent = "# SimGEKI Nightly Build Firmware Files`n`n"
$indexContent += "Last updated: $date`n"
$indexContent += "Build commit: ${{ github.sha }}`n"
$indexContent += "Build author: ${{ github.event.head_commit.author.name }}`n`n"
$indexContent += "## Available Files:`n`n"
$copiedFiles | ForEach-Object {
$indexContent += "- [$($_.Name)](./$($_.Name))`n"
}
$indexContent += "`n## Direct Access URLs:`n`n"
$indexContent += "Base URL: ``https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/nightly/```n`n"
$copiedFiles | ForEach-Object {
$indexContent += "- [$($_.Name)](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/nightly/$($_.Name))`n"
}
$indexContent | Out-File -FilePath "./nightly/README.md" -Encoding UTF8
Write-Host "Created README.md in nightly directory"
# Clean up ALL files except firmware files and READMEs
Write-Host "Cleaning up all non-firmware files from gh-pages..."
Get-ChildItem -Path "." -Recurse | Where-Object {
-not $_.PSIsContainer -and
$_.Name -notmatch "\.(bin|hex|md)$"
} | Remove-Item -Force -ErrorAction SilentlyContinue
# Also remove empty directories except standard and nightly
Get-ChildItem -Path "." -Recurse -Directory | Where-Object {
$_.Name -ne "standard" -and
$_.Name -ne "nightly" -and
(Get-ChildItem $_.FullName -Force | Measure-Object).Count -eq 0
} | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
# Add and commit changes
Write-Host "Adding files to git..."
git add nightly/
$changes = git diff --staged --name-only
if ($changes) {
Write-Host "Files to be committed:"
$changes | ForEach-Object { Write-Host " - $_" }
git commit -m "π Update nightly firmware files
Build Date: $date
Commit: ${{ github.sha }}
Author: ${{ github.event.head_commit.author.name }}
Files updated:
$(($copiedFiles | ForEach-Object { "- $($_.Name)" }) -join "`n")"
Write-Host "Pushing to gh-pages..."
git push origin gh-pages
Write-Host "β Successfully pushed nightly files to gh-pages"
} else {
Write-Host "No changes to commit for nightly files"
}
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}