Skip to content

Commit 7ad53b2

Browse files
committed
Update workflow for versioning and introduce version.txt
1 parent 0c5e239 commit 7ad53b2

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

.github/workflows/deploy-pages.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
cp index.html dist/
3636
[ -f favicon.ico ] && cp favicon.ico dist/
3737
[ -f company_logo.png ] && cp company_logo.png dist/
38+
[ -f version.txt ] && cp version.txt dist/
3839
shopt -s nullglob
3940
for file in ttn_decoder-*.js; do
4041
cp "$file" dist/

.github/workflows/sync-version.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,11 @@ jobs:
3535
fi
3636
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
3737
38-
- name: Update version in index.html
38+
- name: Update version.txt
3939
run: |
4040
set -euo pipefail
4141
VERSION='${{ steps.prep.outputs.version }}'
42-
if ! grep -q "App version:" index.html; then
43-
echo "Could not locate App version label in index.html" >&2
44-
exit 1
45-
fi
46-
sed -i -E "s|(App version: )v?[0-9A-Za-z._-]+|\1$VERSION|" index.html
42+
echo "$VERSION" > version.txt
4743
4844
- name: Commit changes
4945
id: commit

index.html

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ <h1 class="brand-header">
197197
<img src="./company_logo.png" alt="Smart Parks logo" class="brand-logo">
198198
<span>Smart Parks - Log File Decoder</span>
199199
</h1>
200-
<div id="appVersion" class="muted" style="margin: -2px 0 12px 0;">App version: v1.12</div>
200+
<div id="appVersion" class="muted" style="margin: -2px 0 12px 0;">App version: (loading...)</div>
201201
<div id="errorBanner"></div>
202202

203203
<!-- === DECODER SECTION === -->
@@ -441,9 +441,26 @@ <h1 class="brand-header">
441441

442442
<script>
443443
const versionLabel = document.getElementById("appVersion");
444-
const APP_VERSION = versionLabel
445-
? versionLabel.textContent.replace(/^App version:\s*/i, "").trim()
446-
: "";
444+
let APP_VERSION = "";
445+
446+
async function loadAppVersion(){
447+
if(!versionLabel) return;
448+
try{
449+
const resp = await fetch('version.txt', { cache: 'no-store' });
450+
if(!resp.ok) throw new Error(`version.txt responded with ${resp.status}`);
451+
const txt = (await resp.text()).trim();
452+
if(txt){
453+
APP_VERSION = txt;
454+
versionLabel.textContent = "App version: " + APP_VERSION;
455+
} else {
456+
versionLabel.textContent = "App version: (unknown)";
457+
}
458+
} catch(err){
459+
console.error('Failed to load version.txt', err);
460+
versionLabel.textContent = "App version: (unknown)";
461+
}
462+
}
463+
loadAppVersion();
447464

448465
// ---------- Error banner ----------
449466
window.onerror = function (msg, src, line, col, err) {
@@ -466,11 +483,6 @@ <h1 class="brand-header">
466483
const customDecoderInput = document.getElementById("customDecoder");
467484
const decoderSelect = document.getElementById("decoderSelect");
468485

469-
// Version label
470-
if (versionLabel && APP_VERSION) {
471-
versionLabel.textContent = "App version: " + APP_VERSION;
472-
}
473-
474486
function loadDecoder(callback){
475487
clearError();
476488
const existing = document.getElementById("decoderScript");

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v1.9

0 commit comments

Comments
 (0)