Skip to content
This repository was archived by the owner on Mar 16, 2026. It is now read-only.

Commit 088a7c5

Browse files
authored
Update monthly_release.yml
1 parent 2ab3320 commit 088a7c5

File tree

1 file changed

+57
-14
lines changed

1 file changed

+57
-14
lines changed

.github/workflows/monthly_release.yml

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ jobs:
185185
echo.
186186
echo set /p close="Press any key to close this window"
187187
) > UPDATE.bat
188+
189+
echo Extracting version from OSCR.cpp
190+
powershell -Command "$pattern = 'FSTRING_VERSION\[\] = \"(.*)\";'; $line = Select-String -Path 'Arduino IDE\portable\sketchbook\Cart_Reader\OSCR.cpp' -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; Set-Content -Path version.txt -Value $version"
191+
192+
for /f "delims=" %%v in (version.txt) do set "OSCR_VERSION=%%v"
193+
echo OSCR_VERSION=%OSCR_VERSION%>> %GITHUB_ENV%
194+
del version.txt
188195
189196
echo Optimize U8g2 for size
190197
cd "Arduino IDE\portable\sketchbook\libraries\U8g2_Arduino-master\src\clib\"
@@ -202,24 +209,60 @@ jobs:
202209
cd..
203210
cd..
204211
205-
echo Create oscr_release.zip
212+
echo Create VXX.X_Portable.zip
206213
cd..
207-
powershell compress-archive -Path oscr_release -DestinationPath oscr_release.zip
208-
IF EXIST oscr_release rmdir oscr_release /s /q
209-
210-
- name: Get current date
211-
id: date
212-
shell: pwsh
213-
run: |
214-
$date = Get-Date -Format yyyyMMdd
215-
echo "date=$date" >> $env:GITHUB_OUTPUT
216-
214+
IF EXIST %OSCR_VERSION%_Portable rmdir %OSCR_VERSION%_Portable /s /q
215+
ren oscr_release %OSCR_VERSION%_Portable
216+
powershell compress-archive -Path %OSCR_VERSION%_Portable -DestinationPath %OSCR_VERSION%_Portable.zip
217+
IF EXIST %OSCR_VERSION%_Portable rmdir %OSCR_VERSION%_Portable /s /q
218+
217219
- name: Publish GitHub Release
218220
uses: softprops/action-gh-release@v2
219221
with:
220-
tag_name: ${{ steps.date.outputs.date }}
221-
name: ${{ steps.date.outputs.date }}
222+
tag_name: ${{ env.OSCR_VERSION }}
223+
name: ${{ env.OSCR_VERSION }}
222224
body: Automated monthly OSCR release
223-
files: oscr_release.zip
225+
files: ${{ env.OSCR_VERSION }}_Portable.zip
224226
env:
225227
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
228+
229+
- name: Sparse checkout OSCR.cpp
230+
run: |
231+
git init bump-temp
232+
cd bump-temp
233+
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
234+
git config core.sparseCheckout true
235+
echo Cart_Reader/OSCR.cpp > .git/info/sparse-checkout
236+
git pull origin master
237+
shell: bash
238+
239+
- name: Bump version in OSCR.cpp and push
240+
run: |
241+
cd bump-temp/Cart_Reader
242+
243+
# Extract current version numbers
244+
OLD_VERSION=$(grep 'FSTRING_VERSION' OSCR.cpp | sed -E 's/.*"V([0-9]+)\.([0-9]+)".*/\1 \2/')
245+
MAJOR=$(echo $OLD_VERSION | cut -d' ' -f1)
246+
MINOR=$(echo $OLD_VERSION | cut -d' ' -f2)
247+
248+
# Increment version according to your scheme
249+
if [ "$MINOR" -lt 9 ]; then
250+
MINOR=$((MINOR + 1))
251+
else
252+
MINOR=0
253+
MAJOR=$((MAJOR + 1))
254+
fi
255+
256+
NEW_VERSION="V${MAJOR}.${MINOR}"
257+
258+
# Replace version in OSCR.cpp
259+
sed -i -E "s/(FSTRING_VERSION\\[\\] = \")V[0-9]+\\.[0-9]+(\";)/\1${NEW_VERSION}\2/" OSCR.cpp
260+
261+
# Commit & push changes
262+
cd ..
263+
git config user.name "github-actions"
264+
git config user.email "github-actions@github.com"
265+
git add Cart_Reader/OSCR.cpp
266+
git commit -m "Bump version to ${NEW_VERSION} after monthly release"
267+
git push origin HEAD:master
268+
shell: bash

0 commit comments

Comments
 (0)