This repository was archived by the owner on Mar 16, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 254
561 lines (467 loc) · 23.8 KB
/
bi-monthly_release.yml
File metadata and controls
561 lines (467 loc) · 23.8 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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
name: bi-monthly release
on:
schedule:
- cron: '0 0 1 2,4,6,8,10,12 *' # Runs at 00:00 on the 1st of every second month
workflow_dispatch:
jobs:
release:
runs-on: windows-latest
permissions:
contents: write
defaults:
run:
shell: pwsh
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for commits in the last 60 days
run: |
git fetch origin master
COMMITS=$(git rev-list --count --since="60 days ago" origin/master)
echo "Commits in last 60 days: $COMMITS"
if [ "$COMMITS" -lt 3 ]; then
echo "$COMMITS commits in the last 60 days. Skipping release."
exit 0
fi
shell: bash
- name: Build OSCR Release
run: |
#Requires -Version 5.1
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
function Get-FileWithProgress {
param (
[Parameter(Mandatory = $true)][string]$Url,
[Parameter(Mandatory = $true)][string]$Destination
)
Add-Type -AssemblyName System.Net.Http
Write-Host "Downloading: $Url"
$client = New-Object System.Net.Http.HttpClient
$response = $client.GetAsync($Url, [System.Net.Http.HttpCompletionOption]::ResponseHeadersRead).Result
$total = $response.Content.Headers.ContentLength
$stream = $response.Content.ReadAsStreamAsync().Result
$fileStream = [System.IO.File]::OpenWrite($Destination)
$buffer = New-Object byte[] 8192
$read = 0
$totalRead = 0
$lastPercent = -1
do {
$read = $stream.Read($buffer, 0, $buffer.Length)
if ($read -gt 0) {
$fileStream.Write($buffer, 0, $read)
$totalRead += $read
if ($total) {
$percent = [math]::Floor(($totalRead / $total) * 100)
if ($percent -ne $lastPercent) {
Write-Progress -Activity "Downloading" -Status "$percent% complete" -PercentComplete $percent
$lastPercent = $percent
}
}
}
} while ($read -gt 0)
$fileStream.Close()
$stream.Close()
Write-Progress -Activity "Downloading" -Completed
Write-Host "Download complete: $Destination"
}
function Expand-Zip {
param (
[string]$ZipPath,
[string]$OutPath
)
Expand-Archive -Path $ZipPath -DestinationPath $OutPath -Force
}
$root = Join-Path (Get-Location) "oscr_release"
if (Test-Path $root) {
Remove-Item $root -Recurse -Force
}
New-Item -ItemType Directory -Path $root | Out-Null
Set-Location $root
# Check if Arduino IDE folder exists to skip Steps 1-3
if (Test-Path "$root\Arduino IDE") {
Write-Host "Arduino IDE folder already exists. Skipping Steps 1, 2, 3."
} else {
### Step 1: Arduino IDE ###
Write-Host "Step 1: Downloading Arduino IDE..." -ForegroundColor Green
$ideZip = Join-Path $root "arduino-1.8.19-windows.zip"
Get-FileWithProgress -Url "https://downloads.arduino.cc/arduino-1.8.19-windows.zip" -Destination $ideZip
Write-Host "Verifying SHA256..."
$expectedHash = "C704A821089EAB2588F1DEAE775916219B1517FEBD1DD574FF29958DCA873945"
$hash = (Get-FileHash $ideZip -Algorithm SHA256).Hash
if ($hash -ne $expectedHash) {
Write-Error "Checksum mismatch! Aborting."
exit 1
} else {
Write-Host "Checksum OK."
}
Write-Host "Extracting Arduino IDE..."
Expand-Zip -ZipPath $ideZip -OutPath $root
Remove-Item $ideZip
Rename-Item -Path "$root\arduino-1.8.19" -NewName "Arduino IDE"
### Step 2: Update AVR-GCC compiler ###
Write-Host "Step 2: Downloading latest AVR-GCC compiler..." -ForegroundColor Green
$avrGccZip = Join-Path $root "avr-gcc-15.2.0-x64-windows.zip"
Get-FileWithProgress -Url "https://github.com/ZakKemble/avr-gcc-build/releases/download/v15.2.0-1/avr-gcc-15.2.0-x64-windows.zip" -Destination $avrGccZip
Write-Host "Verifying AVR-GCC SHA256..."
$expectedAvrHash = "3bcfdbdbff6e3576ef0bef9e119b16f7012657d30f002d6d9d4848a7efd4f8b7"
$avrHash = (Get-FileHash $avrGccZip -Algorithm SHA256).Hash
if ($avrHash -ne $expectedAvrHash) {
Write-Error "AVR-GCC checksum mismatch! Aborting."
exit 1
} else {
Write-Host "AVR-GCC checksum OK."
}
# Extract new AVR-GCC
Write-Host "Extracting AVR-GCC..."
Expand-Zip -ZipPath $avrGccZip -OutPath "$root\temp_avr"
Remove-Item $avrGccZip
# Replace old AVR folder with new one
$toolsPath = "$root\Arduino IDE\hardware\tools"
$oldAvrPath = "$toolsPath\avr"
$backupAvrPath = "$root\avr_backup"
if (Test-Path $oldAvrPath) {
Write-Host "Backing up old AVR compiler..."
# Remove existing backup if it exists
if (Test-Path $backupAvrPath) {
Remove-Item $backupAvrPath -Recurse -Force
}
Move-Item $oldAvrPath $backupAvrPath
}
# Move new AVR-GCC to tools folder
Write-Host "Installing new AVR-GCC compiler..."
Move-Item "$root\temp_avr\avr-gcc-15.2.0-x64-windows" "$toolsPath\avr"
# Copy essential files from old AVR installation if backup exists
if (Test-Path $backupAvrPath) {
Write-Host "Copying essential files from old AVR installation..."
# Copy avrdude.exe if it exists
$oldAvrdude = "$backupAvrPath\bin\avrdude.exe"
$newAvrdudeDir = "$toolsPath\avr\bin"
if (Test-Path $oldAvrdude) {
Copy-Item $oldAvrdude $newAvrdudeDir -Force
Write-Host "Copied avrdude.exe"
}
# Copy old libusb0.dll
$oldLibusb = "$backupAvrPath\bin\libusb0.dll"
if (Test-Path $oldLibusb) {
Copy-Item $oldLibusb $newAvrdudeDir -Force
Write-Host "Copied libusb0.dll"
}
# Delete new avrdude.conf
Remove-Item "$toolsPath\avr\bin\avrdude.conf"
# Copy builtin_tools_versions.txt if it exists
$oldVersions = "$backupAvrPath\builtin_tools_versions.txt"
$newAvrDir = "$toolsPath\avr"
if (Test-Path $oldVersions) {
Copy-Item $oldVersions $newAvrDir -Force
Write-Host "Copied builtin_tools_versions.txt"
}
# Copy etc folder if it exists
$oldEtc = "$backupAvrPath\etc"
$newAvrDir = "$toolsPath\avr"
if (Test-Path $oldEtc) {
Copy-Item $oldEtc $newAvrDir -Recurse -Force
Write-Host "Copied etc folder"
}
}
# Clean up temporary files
Remove-Item "$root\temp_avr" -Recurse -Force
Remove-Item "$root\avr_backup" -Recurse -Force
### Step 3: Update AVRDUDE ###
if ($true) {
# New avrdude has timeout error, add option to skip
Write-Host "Skipping Step 3: Updating AVRDUDE..." -ForegroundColor Green
} else {
Write-Host "Step 3: Updating AVRDUDE..." -ForegroundColor Green
$avrdudeZip = Join-Path $root "avrdude-v8.1-windows-x64.zip"
$avrdudeBinPath = "$root\Arduino IDE\hardware\tools\avr\bin"
$avrdudeEtcPath = "$root\Arduino IDE\hardware\tools\avr\etc"
$avrdudeExePath = Join-Path $avrdudeBinPath "avrdude.exe"
$avrdudeConfPath = Join-Path $avrdudeEtcPath "avrdude.conf"
Write-Host "Downloading AVRDUDE..."
Get-FileWithProgress -Url "https://github.com/avrdudes/avrdude/releases/download/v8.1/avrdude-v8.1-windows-x64.zip" -Destination $avrdudeZip
Write-Host "Verifying AVRDUDE SHA256..."
$expectedAvrdudeHash = "e4d571d81fee3387d51bfdedd0b6565e4c201e974101cac2caec7adfd6201da3"
$avrdudeHash = (Get-FileHash $avrdudeZip -Algorithm SHA256).Hash
if ($avrdudeHash -ne $expectedAvrdudeHash) {
Write-Error "AVRDUDE checksum mismatch! Aborting."
exit 1
} else {
Write-Host "AVRDUDE checksum OK."
}
Write-Host "Extracting AVRDUDE..."
$tempAvrdudeDir = "$root\temp_avrdude"
Expand-Zip -ZipPath $avrdudeZip -OutPath $tempAvrdudeDir
Remove-Item $avrdudeZip
# Ensure target directories exist
if (-not (Test-Path $avrdudeBinPath)) {
New-Item -ItemType Directory -Path $avrdudeBinPath -Force
}
if (-not (Test-Path $avrdudeEtcPath)) {
New-Item -ItemType Directory -Path $avrdudeEtcPath -Force
}
# Find the extracted avrdude files and copy them
$extractedAvrdudeExe = Get-ChildItem -Path $tempAvrdudeDir -Name "avrdude.exe" -Recurse | Select-Object -First 1
$extractedAvrdudeConf = Get-ChildItem -Path $tempAvrdudeDir -Name "avrdude.conf" -Recurse | Select-Object -First 1
if ($extractedAvrdudeExe) {
$fullAvrdudeExePath = Join-Path $tempAvrdudeDir $extractedAvrdudeExe
Write-Host "Installing avrdude.exe to $avrdudeBinPath"
Copy-Item $fullAvrdudeExePath $avrdudeExePath -Force
} else {
Write-Error "Could not find avrdude.exe in extracted files!"
}
if ($extractedAvrdudeConf) {
$fullAvrdudeConfPath = Join-Path $tempAvrdudeDir $extractedAvrdudeConf
Write-Host "Installing avrdude.conf to $avrdudeEtcPath"
Copy-Item $fullAvrdudeConfPath $avrdudeConfPath -Force
} else {
Write-Error "Could not find avrdude.conf in extracted files!"
}
# Clean up temporary files
Remove-Item $tempAvrdudeDir -Recurse -Force
Write-Host "AVRDUDE v8.1 installation complete!"
}
}
# Step 4: Arduino CLI Setup
Write-Host "Step 4: Setting up Arduino CLI..." -ForegroundColor Green
# Make sure libraries folder exists
New-Item -ItemType Directory -Path "$root\Arduino IDE\portable\sketchbook\libraries" -Force | Out-Null
$arduinoCliZip = Join-Path $root "arduino-cli_1.3.1_Windows_64bit.zip"
$arduinoCliExe = Join-Path $root "Arduino IDE\arduino-cli.exe"
# Download arduino-cli if not already present
if (-not (Test-Path $arduinoCliExe)) {
Write-Host "Downloading Arduino CLI..."
Get-FileWithProgress -Url "https://github.com/arduino/arduino-cli/releases/download/v1.3.1/arduino-cli_1.3.1_Windows_64bit.zip" -Destination $arduinoCliZip
Write-Host "Verifying Arduino CLI SHA256..."
$expectedCliHash = "cfece6f356fdc9ca003cc3f0a488470030719c8e0e7bfce5e42ac9410d87441f"
$cliHash = (Get-FileHash $arduinoCliZip -Algorithm SHA256).Hash
if ($cliHash -ne $expectedCliHash) {
Write-Error "Arduino CLI checksum mismatch! Aborting."
exit 1
} else {
Write-Host "Arduino CLI checksum OK."
}
Write-Host "Extracting Arduino CLI..."
Expand-Zip -ZipPath $arduinoCliZip -OutPath "$root\temp_cli"
Remove-Item $arduinoCliZip
# Move arduino-cli.exe to Arduino IDE directory
Move-Item "$root\temp_cli\arduino-cli.exe" $arduinoCliExe
Remove-Item "$root\temp_cli" -Recurse -Force
} else {
Write-Host "Arduino CLI already exists, skipping download."
}
# Configure Arduino CLI for portable mode
Write-Host "Configuring Arduino CLI for portable mode..."
Set-Location "$root\Arduino IDE"
# Initialize configuration
& ".\arduino-cli.exe" config init
# Set portable sketchbook directory
& ".\arduino-cli.exe" config set directories.user "portable\sketchbook"
# Update package index
Write-Host "Updating Arduino CLI package index..."
& ".\arduino-cli.exe" core update-index
# Step 5: Install Required Libraries
Write-Host "Step 5: Installing required libraries..." -ForegroundColor Green
$libraries = @(
"SdFat",
"Adafruit BusIO",
"U8g2",
"Adafruit NeoPixel",
"RotaryEncoder",
"Etherkit Si5351",
"RTClib",
"FreqCount"
)
foreach ($lib in $libraries) {
Write-Host "Installing library: $lib"
try {
& ".\arduino-cli.exe" lib install $lib
Write-Host "Successfully installed: $lib"
} catch {
Write-Warning "Failed to install library: $lib - $($_.Exception.Message)"
}
}
# Update all libraries
Write-Host "Updating library index..."
& ".\arduino-cli.exe" lib update-index
Write-Host "Upgrading all libraries..."
& ".\arduino-cli.exe" lib upgrade
Write-Host "Arduino CLI setup and library installation complete!"
# Return to original directory
Set-Location $root
### Step 6: OSCR Sketch ###
Write-Host "Step 6: Downloading OSCR sketch..." -ForegroundColor Green
$sketchZip = Join-Path $root "master.zip"
Get-FileWithProgress -Url "https://github.com/sanni/cartreader/archive/refs/heads/master.zip" -Destination $sketchZip
Expand-Zip -ZipPath $sketchZip -OutPath $root
Remove-Item $sketchZip
$sketchRoot = Join-Path $root "cartreader-master"
# Delete existing Cart_Reader folder if it exists before moving the new one
$cartReaderDest = "$root\Arduino IDE\portable\sketchbook\Cart_Reader"
if (Test-Path $cartReaderDest) {
Write-Host "Existing Cart_Reader folder found. Removing..."
Remove-Item $cartReaderDest -Recurse -Force
}
# Delete existing SD Card folder if it exists before moving
$sdCardDest = "$root\SD Card"
if (Test-Path $sdCardDest) {
Write-Host "Existing SD Card folder found. Removing..."
Remove-Item $sdCardDest -Recurse -Force
}
Move-Item "$sketchRoot\Cart_Reader" $cartReaderDest
Move-Item "$sketchRoot\sd" $sdCardDest
Move-Item "$sketchRoot\LICENSE" "$root\LICENSE.txt" -Force
Move-Item "$sketchRoot\tools\oscr_tool\launch_oscr_tool.bat" "$root" -Force
Move-Item "$sketchRoot\tools\oscr_tool\oscr_tool.ps1" "$root" -Force
Remove-Item "$sdCardDest\README.md","$cartReaderDest\README.md","$cartReaderDest\LICENSE.txt" -ErrorAction SilentlyContinue
Remove-Item "$sketchRoot" -Recurse -Force
### Step 7: CH341 Drivers ###
Write-Host "Step 7: Downloading CH341 driver..." -ForegroundColor Green
# Delete existing CH341 Drivers folder if it exists before moving
$CH341Dest = "$root\CH341 Drivers"
if (Test-Path $CH341Dest) {
Write-Host "Existing CH341 Drivers folder found. Removing..."
Remove-Item $CH341Dest -Recurse -Force
}
$drvZip = Join-Path $root "drivers.zip"
Get-FileWithProgress -Url "https://www.wch-ic.com/download/file?id=5" -Destination $drvZip
Write-Host "Verifying SHA256..."
$expectedHash = "a7b08baaaf9b0e8548ffbab2a91fab8c75595f8d63a42a490fbf3fd1e747e21c"
$hash = (Get-FileHash $drvZip -Algorithm SHA256).Hash
if ($hash -ne $expectedHash) {
Write-Error "Checksum mismatch! Aborting."
exit 1
} else {
Write-Host "Checksum OK."
}
Expand-Zip -ZipPath $drvZip -OutPath "$root\drivers"
Move-Item "$root\drivers\CH341SER" "$root\CH341 Drivers" -Force
Remove-Item "$root\drivers" -Recurse -Force
Remove-Item $drvZip -Force
### Step 8: Optimize U8g2 ###
Write-Host "Step 8: Optimizing U8g2 for size..." -ForegroundColor Green
$u8g2Header = "$root\Arduino IDE\portable\sketchbook\libraries\U8g2\src\clib\u8g2.h"
(Get-Content $u8g2Header) `
-replace '#define U8G2_16BIT', '//#define U8G2_16BIT' `
-replace '#define U8G2_WITH_HVLINE_SPEED_OPTIMIZATION', '//#define U8G2_WITH_HVLINE_SPEED_OPTIMIZATION' `
-replace '#define U8G2_WITH_INTERSECTION', '//#define U8G2_WITH_INTERSECTION' `
-replace '#define U8G2_WITH_CLIP_WINDOW_SUPPORT', '//#define U8G2_WITH_CLIP_WINDOW_SUPPORT' `
-replace '#define U8G2_WITH_FONT_ROTATION', '//#define U8G2_WITH_FONT_ROTATION' `
-replace '#define U8G2_WITH_UNICODE', '//#define U8G2_WITH_UNICODE' |
Set-Content -Encoding ASCII $u8g2Header
### Step 9: Optimize Compiler ###
Write-Host "Step 9: Optimizing compiler..." -ForegroundColor Green
$platformLocalPath = Join-Path $root 'Arduino IDE\hardware\arduino\avr\platform.local.txt'
# Ensure target directory exists
$platformDir = Split-Path $platformLocalPath -Parent
if (-not (Test-Path $platformDir)) {
New-Item -Path $platformDir -ItemType Directory -Force | Out-Null
}
# Desired content as array (preserves indentation)
$platformLocalContent = @(
'compiler.c.extra_flags=-mcall-prologues'
'compiler.cpp.extra_flags=-mcall-prologues'
'compiler.S.extra_flags='
'compiler.ar.extra_flags='
'compiler.objcopy.eep.extra_flags='
'compiler.elf2hex.extra_flags='
'compiler.c.elf.extra_flags=-Wl,--relax'
)
# Create / overwrite file with UTF-8 encoding
$platformLocalContent | Set-Content -Path $platformLocalPath -Encoding UTF8 -Force
### Step 10: README ###
Write-Host "Step 10: Creating README.txt..."
@"
1) Install CH341 Drivers by running SETUP.exe in the "CH341 Drivers" folder
2) Launch arduino.exe found in the "Arduino IDE" directory
3) In the Arduino IDE go File -> Sketchbook -> Cart_Reader
4) Then Tools -> Board and select "Arduino/Genuino Mega or Mega 2560"
5) Followed by Tools -> Port and select your Arduino
6) In Config.h define your HW version by removing // in front of "#define HWX" where X is your hardware version
7) Next Sketch -> Upload
8) Verify that the upload didn't give you any errors
9) Copy the content of the "SD Card" folder to the root of your SD card
10) Mark the *.txt files as hidden
More info: https://github.com/sanni/cartreader/wiki
"@ | Set-Content -Encoding UTF8 -Path "$root\README.txt"
### Step 11: Extracting version from OSCR.cpp ###
Write-Host "Step 11: Extracting version from OSCR.cpp..."
$pattern = 'FSTRING_VERSION\[\] = "(.*)";'
$cppPath = Join-Path $root "Arduino IDE\portable\sketchbook\Cart_Reader\OSCR.cpp"
$line = Select-String -Path $cppPath -Pattern $pattern | Select-Object -First 1
if (-not $line) {
throw "Version string not found in OSCR.cpp"
}
$version = [regex]::Match($line.Line, $pattern).Groups[1].Value
Write-Host "Extracted version: $version"
# Write version to GitHub Actions environment
$githubEnv = $env:GITHUB_ENV
if (-not $githubEnv) {
throw "`$GITHUB_ENV is not set. Are you running this inside GitHub Actions?"
}
Add-Content -Path $githubEnv -Value "OSCR_VERSION=$version"
### Step 12: Create zip ###
Write-Host "Step 12: Create zip..."
# Go up one directory
Set-Location (Split-Path $root -Parent)
# Define release folder name
$releaseFolder = "${version}_Portable"
# Remove old folder if it exists
if (Test-Path $releaseFolder) {
Remove-Item $releaseFolder -Recurse -Force
}
# Rename oscr_release to versioned folder
Rename-Item -Path "oscr_release" -NewName $releaseFolder
# Create zip archive
Compress-Archive -Path $releaseFolder -DestinationPath "$releaseFolder.zip"
# Create 7zip archive
& "C:\Program Files\7-Zip\7z.exe" a "$releaseFolder.7z" "$releaseFolder"
# Clean up folder after zipping
if (Test-Path $releaseFolder) {
Remove-Item $releaseFolder -Recurse -Force
}
Write-Host "DONE. Portable Arduino IDE for OSCR is ready."
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.OSCR_VERSION }}
name: ${{ env.OSCR_VERSION }}
body: Automated bi-monthly OSCR release
files: |
${{ env.OSCR_VERSION }}_Portable.zip
${{ env.OSCR_VERSION }}_Portable.7z
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sparse checkout OSCR.cpp
run: |
git init bump-temp
cd bump-temp
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git config core.sparseCheckout true
echo Cart_Reader/OSCR.cpp > .git/info/sparse-checkout
git pull origin master
shell: bash
- name: Bump version in OSCR.cpp and push
run: |
cd bump-temp/Cart_Reader
# Extract current version numbers
OLD_VERSION=$(grep 'FSTRING_VERSION' OSCR.cpp | sed -E 's/.*"V([0-9]+)\.([0-9]+)".*/\1 \2/')
MAJOR=$(echo $OLD_VERSION | cut -d' ' -f1)
MINOR=$(echo $OLD_VERSION | cut -d' ' -f2)
# Increment version according to your scheme
if [ "$MINOR" -lt 9 ]; then
MINOR=$((MINOR + 1))
else
MINOR=0
MAJOR=$((MAJOR + 1))
fi
NEW_VERSION="V${MAJOR}.${MINOR}"
# Replace version in OSCR.cpp
sed -i -E "s/(FSTRING_VERSION\\[\\] = \")V[0-9]+\\.[0-9]+(\";)/\1${NEW_VERSION}\2/" OSCR.cpp
# Commit & push changes
cd ..
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add Cart_Reader/OSCR.cpp
git commit -m "Bump version to ${NEW_VERSION} after bi-monthly release"
git push origin HEAD:master
shell: bash