feat: Update-Prüfung beim Start und Versions-Endpunkt

- App prüft version.json beim Start (nur exportierte Desktop-Builds)
- Dialog, Download mit SHA-256-Prüfung, Installation je Plattform
- manueller Menüpunkt, übersprungene Version in user://update.cfg
- Endpunkt unter rinkplanner.programmschmiede.de/version.json
- tools/publish_version.sh und Doku in docs/updates.md
- Version 0.2.0
This commit is contained in:
torsten 2026-11-11 18:26:11 +01:00
parent b75953e97f
commit 54e1c5dc34
23 changed files with 1378 additions and 12 deletions

View file

@ -31,6 +31,12 @@
- Beim Windows-Build ausschließlich `rinkplanner-setup.exe` (Installer)
hochladen. Die lokale `rinkplanner.exe` ist nur Zwischenartefakt und wird
nicht verteilt.
- Update-Endpunkt: `https://rinkplanner.programmschmiede.de/version.json`
(statisches JSON), erzeugt und hochgeladen mit
`./tools/publish_version.sh` (`--windows`, `--notes`, `--no-upload`,
`--check`). Die Version steht in `rinkplanner/project.godot`
(`config/version`) und gespiegelt in `rinkplanner/export_presets.cfg`.
Details, Installationsabläufe und Release-Checkliste: `docs/updates.md`.
## Windows-Installer

View file

@ -14,3 +14,4 @@ Planner for Figure Skating free skate
- **Kür-Sync (Dropbox):** [`docs/sync.md`](docs/sync.md)
- **Cloud-Sync einrichten:** [`docs/cloud-setup.md`](docs/cloud-setup.md)
- **Kür-Hub:** [`docs/hub.md`](docs/hub.md)
- **Updates und Versions-Endpunkt:** [`docs/updates.md`](docs/updates.md)

View file

@ -58,7 +58,7 @@ Das Skript lädt Wine (Kron4ek-Build) und `rcedit` nach
`~/.local/share/rinkplanner-toolchain`, legt einen Wrapper an und trägt ihn
als `export/windows/rcedit` in die Godot-Editor-Settings ein. Die Werte
selbst stehen im Preset unter `application/*` (Icon `app_icon.png`,
Version `0.1.0.0`).
Version `0.2.0.0`).
### Windows-Installer
@ -148,7 +148,7 @@ Prüfen (Paketname, Version, SDK-Stufen, ABI, Landscape, Signatur):
dem Godot-Template. Das Manifest referenziert nur `@mipmap/icon`; die Warnung
ist folgenlos.
- Paket: `de.rinkplanner.app`, Label „Rinkplanner“, Version 0.1.0
- Paket: `de.rinkplanner.app`, Label „Rinkplanner“, Version 0.2.0
- App-Icon aus der Silhouetten-Vorlage, erzeugt mit
`tools/make_app_icons.py` (Launcher-Icons unter
`rinkplanner/assets/icons/android/`); aktuell die **invertierte**
@ -249,6 +249,16 @@ auf `tools/sync_assets.sh --sync` ab. Für einen reinen Starttest ohne
ist eine Authenticode-Signatur nötig.
- **macOS:** siehe Hinweise oben (Codesign/Notarization).
## Updates und Versions-Endpunkt
Die App prüft beim Start und über `Datei → Nach Updates suchen…` auf neue
Versionen. Der Endpunkt ist ein statisches JSON unter
`https://rinkplanner.programmschmiede.de/version.json`, veröffentlicht mit
`./tools/publish_version.sh`.
Details (Versionsquelle, JSON-Schema, Installationsabläufe je Plattform,
Fehlersuche und Release-Checkliste): [`docs/updates.md`](updates.md).
## Kontosync
Der manuelle Sync über Dropbox lädt die neuesten

225
docs/updates.md Normal file
View file

@ -0,0 +1,225 @@
# Updates und Versions-Endpunkt
Stand: 2026-11-11, veröffentlichte Version **0.2.0** (nur macOS).
Die App prüft beim Start und über `Datei → Nach Updates suchen…`, ob eine
neuere Version veröffentlicht ist. Der Endpunkt ist ein statisches JSON auf
der Rinkplanner-Subdomain. Es gibt keinen PHP-Dienst und keine Datenbank.
## Beteiligte Dateien
| Datei | Aufgabe |
| :--- | :--- |
| `rinkplanner/src/core/update/update_info.gd` | Versionsvergleich, JSON-Prüfung, Plattformwahl, gemerkte übersprungene Version |
| `rinkplanner/src/core/update/update_client.gd` | Blockierender HTTPS-Check und Download mit SHA-256-Prüfung |
| `rinkplanner/src/core/update/update_job.gd` | Thread-Aufgabe für Check/Download |
| `rinkplanner/src/whiteboard/ctrl/whiteboard_controller.gd` | Startprüfung, Dialog, menüpunkt, Installation |
| `rinkplanner/scenes/whiteboard/whiteboard.tscn` | `UpdateDialog` mit `UpdateText` |
| `rinkplanner/tests/run_update_tests.gd` | Headless-Tests (kein Netzwerk) |
| `rinkplanner/tests/manual/check_update.gd` | Manueller Check gegen den Live-Endpunkt |
| `tools/publish_version.sh` | Erzeugt `version.json`, bildet Prüfsummen, lädt hoch |
| `docs/updates.md` | Diese Datei |
## Versionsquelle
Die Laufzeitversion steht in `rinkplanner/project.godot`:
```ini
config/version="0.2.0"
```
Beim Versionssprung **alle** Stellen anpassen:
1. `rinkplanner/project.godot`: `config/version`
2. `rinkplanner/export_presets.cfg`:
- Windows: `application/file_version` und `application/product_version`
(viersegmentig, z. B. `0.2.0.0`)
- macOS: `application/short_version` und `application/version`
- Android: `version/name`, außerdem `version/code` erhöhen
3. `tools/windows_installer.nsi` und `tools/export_windows_installer.sh`:
nur Fallback-Werte, falls das Preset nicht gelesen werden kann
`UpdateInfo.current_version()` liest `application/config/version` zur Laufzeit.
Die Tests prüfen, dass der Wert gesetzt und numerisch ist, aber nicht eine
bestimmte Versionsnummer.
## Endpunkt
```
https://rinkplanner.programmschmiede.de/version.json
```
Ablage auf dem Webspace: FTP-Login-Root → Verzeichnis
`rinkplanner.programmschmiede.de/` (Docroot der Subdomain). Die Datei wird
als `application/json` ausgeliefert; es gibt keine Cache-Control-Header.
`version.json` ist die einzige Quelle für die App – die HTML-Seite ist davon
unabhängig.
Schema:
```json
{
"version": "0.2.0",
"released": "2026-11-11",
"notes": "Neu: …",
"downloads": {
"macos": {
"url": "https://programmschmiede.de/rinkplanner/download/rinkplanner-setup.dmg",
"sha256": "…",
"size": 71302221
},
"windows": {
"url": "https://programmschmiede.de/rinkplanner/download/rinkplanner-setup.exe",
"sha256": "…",
"size": 0
}
}
}
```
- `version` ist Pflicht und muss numerisch beginnen (`v`-Präfix und Suffixe
werden ignoriert).
- `downloads` ist Pflicht und darf nicht leer sein; Schlüssel sind `macos`,
`windows`, `linux` (klein geschrieben).
- `url` muss mit `https://` beginnen, sonst wird der Eintrag verworfen.
- `sha256` und `size` sind optional; fehlt `sha256`, wird der Download nicht
verifiziert. Für Releases immer setzen (macht `publish_version.sh`).
- `notes` darf ein String oder eine Liste von Zeilen sein.
- `released` wird als `JJJJ-MM-TT` erwartet und im Dialog als `TT.MM.JJJJ`
angezeigt.
## Veröffentlichen
Voraussetzungen: Installer sind gebaut, `docs/credentials.txt` enthält die
FTP-Zugänge, der Build entspricht der Version in `project.godot`.
```bash
./tools/export_macos_installer.sh
./tools/publish_version.sh --notes "Neu: …"
```
Optionen:
| Option | Wirkung |
| :--- | :--- |
| `--windows` | Nimmt `build/windows/rinkplanner-setup.exe` mit auf. Vorher neu bauen; die Version lässt sich nicht zuverlässig aus der EXE lesen. |
| `--notes "Text"` | Neuerungen für den Update-Dialog. |
| `--no-upload` | Schreibt nur `build/version.json`. |
| `--check` | Gibt den live ausgelieferten Endpunkt aus. |
Das Skript:
1. liest die Version aus `project.godot`,
2. bildet SHA-256 und Größe der vorhandenen Installer,
3. schreibt `build/version.json`,
4. lädt sie per FTP nach `rinkplanner.programmschmiede.de/version.json`,
5. vergleicht die live abgerufene Datei mit der lokalen und bricht bei
Abweichung mit Exit-Code 2 ab (Cache/Hosting prüfen).
Es werden nur Plattformen veröffentlicht, die ausdrücklich vorliegen. Ein
fehlender Eintrag bedeutet: Für diese Plattform gibt es keinen automatischen
Update-Hinweis.
Live prüfen:
```bash
./tools/publish_version.sh --check
curl -fsSL https://rinkplanner.programmschmiede.de/version.json
/Applications/Godot.app/Contents/MacOS/Godot --headless \
--path rinkplanner --script res://tests/manual/check_update.gd
```
Der letzte Befehl nutzt denselben `UpdateClient` wie die App und zeigt
installierte Version, veröffentlichte Version, Plattform und Download-Eintrag.
## Verhalten in der App
- **Automatisch:** nur in exportierten Desktop-Builds
(`OS.has_feature("template")`, nicht Web, Plattform macOS/Windows/Linux).
Editor, Android und die Headless-Tests prüfen nicht automatisch.
- **Manuell:** `Datei → Nach Updates suchen…` funktioniert überall und zeigt
auch „bereits aktuell“ oder Fehler an.
- **Ablauf:** Hintergrund-Thread → Dialog bei neuerer Version → Download nach
`user://updates/` → SHA-256-Prüfung → Installation.
- **Fehler beim automatischen Check** werden nur als Warning geloggt, damit
ein Offline-Start nicht stört. Manuelle Fehler erscheinen im Dialog.
- **„Später“** speichert die übersprungene Version in `user://update.cfg`.
Beim nächsten Start wird dieselbe Version nicht erneut automatisch
gemeldet; manuell schon.
- **Downloadordner:** `user://updates/` (macOS:
`~/Library/Application Support/Godot/app_userdata/Rinkplanner/updates`).
Nach erfolgreicher macOS-Installation wird die DMG gelöscht.
- **Größenlimit:** 512 MB als Schutz vor kaputten Endpunkten.
### Installation je Plattform
- **macOS:** DMG mit `hdiutil attach -nobrowse -readonly` einhängen, die
`.app` im Image per `ditto` über das laufende Bundle kopieren, aushängen,
neue Instanz mit `open -n` starten und die alte beenden. Das Ziel ist das
Bundle, aus dem die App gerade läuft (`OS.get_executable_path()`), nicht
zwangsweise `/Applications`. Schlägt Einhängen oder Kopieren fehl (Rechte,
Translocation, Editor-Lauf), öffnet sich das DMG im Finder mit dem Hinweis,
die App manuell zu ersetzen.
- **Windows:** Der heruntergeladene `rinkplanner-setup.exe` wird gestartet,
die App beendet sich nach ca. einer Sekunde, damit der Installer die
laufende EXE ersetzen kann. Der Installer ist per-user und unsigniert.
- **Linux:** Es gibt noch keinen Installer; die Datei wird im Dateimanager
geöffnet.
## Sicherheit
- Endpunkt und Download nur über HTTPS mit Zertifikatsprüfung
(`TLSOptions.client()`).
- SHA-256 aus dem Endpunkt schützt gegen unvollständige oder vertauschte
Downloads, nicht gegen einen kompromittierten Server. Die Installation
startet erst nach ausdrücklicher Bestätigung.
- Keine Tokens oder Zugangsdaten im Endpunkt. `docs/credentials.txt` bleibt
gitignored.
- macOS-Builds sind ad-hoc signiert und nicht notarisiert. Der Download über
Godot setzt kein Quarantäne-Attribut; falls Gatekeeper dennoch blockiert:
`xattr -cr /Applications/Rinkplanner.app`.
## Tests
```bash
./tools/test.sh # enthält run_update_tests.gd
```
`run_update_tests.gd` deckt ab: Versionsvergleich (auch 0.10 > 0.9), Präfixe
und Suffixe, Plattformzuordnung, JSON-Validierung, HTTPS-Pflicht,
Datumsformat, gemerkte Version und die Dialog-/Menü-Verdrahtung. Es findet
kein Netzwerkzugriff statt.
## Fehlersuche
| Symptom | Ursache/Prüfung |
| :--- | :--- |
| Kein Hinweis in der App | Automatischer Check nur im exportierten Desktop-Build; `--check` am Endpunkt; Version wirklich erhöht? |
| „ungültige Antwort“ | `downloads` fehlt/leer, `version` nicht numerisch oder JSON kaputt. |
| Download startet nicht | `url` ohne `https://`, HTTP-Status ≠ 200, Datei zu groß. |
| „Prüfsumme stimmt nicht“ | Endpunkt und hochgeladener Installer passen nicht zusammen; `publish_version.sh` erneut laufen lassen. |
| Endpunkt liefert Altes | `--check`; ggf. Hosting-Cache; FTP-Ziel `rinkplanner.programmschmiede.de/version.json` prüfen. |
| Windows bekommt keinen Hinweis | Windows-Build fehlt im Endpunkt; mit `--windows` veröffentlichen. |
## Aktueller Stand und Übergang
- **0.2.0** ist für macOS veröffentlicht (DMG und Endpunkt).
- **Windows** ist noch nicht im Endpunkt, weil der vorhandene Installer noch
0.1.0 ist. Nach einem Windows-Build 0.2.0:
`./tools/publish_version.sh --windows --notes "…"`.
- **Übergang von 0.1.0:** Die Version 0.1.0 enthält die Update-Prüfung noch
nicht. Wer sie installiert hat, muss 0.2.0 einmal manuell installieren;
danach greifen die Hinweise automatisch.
- Android ist bewusst nicht Teil der automatischen Prüfung.
## Checkliste für das nächste Release
1. Version an allen Stellen erhöhen (siehe oben).
2. `./tools/sync_assets.sh --check` (Assets vorhanden?).
3. `./tools/test.sh`.
4. Installer bauen (`export_macos_installer.sh`, ggf.
`export_windows_installer.sh`).
5. Installer nach `programmschmiede.de/rinkplanner/download/` hochladen.
6. `./tools/publish_version.sh --notes "…"` (und `--windows`, falls gebaut).
7. `./tools/publish_version.sh --check` und
`tests/manual/check_update.gd` gegen den Live-Endpunkt laufen lassen.

View file

@ -66,8 +66,8 @@ application/modify_resources=true
application/icon="res://assets/icons/app_icon.png"
application/console_wrapper_icon=""
application/icon_interpolation=4
application/file_version="0.1.0.0"
application/product_version="0.1.0.0"
application/file_version="0.2.0.0"
application/product_version="0.2.0.0"
application/company_name=""
application/product_name="Rinkplanner"
application/file_description="2D-Whiteboard für Eiskunstlauf"
@ -118,8 +118,8 @@ application/icon_interpolation=4
application/bundle_identifier="de.rinkplanner.app"
application/signature=""
application/app_category="Education"
application/short_version=""
application/version=""
application/short_version="0.2.0"
application/version="0.2.0"
application/copyright=""
application/copyright_localized={}
application/min_macos_version_x86_64="11.00"
@ -243,8 +243,8 @@ keystore/debug_password=""
keystore/release=""
keystore/release_user=""
keystore/release_password=""
version/code=1
version/name="0.1.0"
version/code=2
version/name="0.2.0"
package/unique_name="de.rinkplanner.app"
package/name="Rinkplanner"
package/signed=true

View file

@ -15,6 +15,7 @@ compatibility/default_parent_skeleton_in_mesh_instance_3d=true
[application]
config/name="Rinkplanner"
config/version="0.2.0"
run/main_scene="res://scenes/whiteboard/whiteboard.tscn"
config/features=PackedStringArray("4.7", "Forward Plus")
config/icon="res://assets/icons/app_icon.png"

View file

@ -1952,6 +1952,22 @@ unique_name_in_owner = true
layout_mode = 2
text = "Rechte an Kür und Musik bestätigt"
[node name="UpdateDialog" type="ConfirmationDialog" parent="."]
unique_name_in_owner = true
title = "Update verfügbar"
size = Vector2i(640, 420)
ok_button_text = "Jetzt aktualisieren"
cancel_button_text = "Später"
[node name="UpdateText" type="Label" parent="UpdateDialog"]
unique_name_in_owner = true
offset_left = 16.0
offset_top = 12.0
offset_right = 624.0
offset_bottom = 350.0
text = ""
autowrap_mode = 2
[node name="HubConflictDialog" type="ConfirmationDialog" parent="."]
unique_name_in_owner = true
title = "Kür bereits vorhanden"

View file

@ -10,7 +10,7 @@ extends RefCounted
const DEFAULT_TIMEOUT_MSEC := 30000
const TRANSFER_TIMEOUT_MSEC := 300000
const POLL_DELAY_MSEC := 5
const USER_AGENT := "Rinkplanner/0.1 (Godot)"
const USER_AGENT := "Rinkplanner (Godot)"
var last_error: String = ""

View file

@ -0,0 +1,115 @@
class_name UpdateClient
extends RefCounted
## Blocking update client. Like [HubClient] it runs on a worker thread; the
## controller polls the thread and updates the UI on the main thread.
##
## The payload is validated with [UpdateInfo]. Downloads are only accepted from
## HTTPS URLs and, when the endpoint provides a SHA-256, verified before the
## installer is started.
const REQUEST_TIMEOUT_MSEC := 20000
const DOWNLOAD_TIMEOUT_MSEC := 600000
## The installers are ~70 MB today; this is only a guard against a broken
## endpoint filling the disk.
const MAX_DOWNLOAD_BYTES := 512 * 1024 * 1024
const DOWNLOAD_DIR := "user://updates"
var last_error: String = ""
var _http := CloudHttp.new()
## Fetches and validates the endpoint document.
func check(endpoint: String) -> Dictionary:
last_error = ""
if not endpoint.begins_with("https://"):
last_error = "Die Update-Adresse muss HTTPS verwenden."
return {}
var response := _http.request(
HTTPClient.METHOD_GET,
endpoint,
PackedStringArray(["Accept: application/json"]),
PackedByteArray(),
REQUEST_TIMEOUT_MSEC
)
if response.is_empty():
last_error = _http.last_error
return {}
var status := int(response.get("status", 0))
if status != 200:
last_error = "Der Update-Server antwortet mit HTTP %d." % status
return {}
var data: Variant = CloudHttp.json_parse(response.get("body", PackedByteArray()))
var info := UpdateInfo.parse_payload(data)
if info.is_empty():
last_error = "Der Update-Server hat eine ungültige Antwort geliefert."
return {}
return info
## Downloads one installer to user://updates and verifies its SHA-256.
func download(url: String, expected_sha: String, file_name: String) -> Dictionary:
last_error = ""
if not url.begins_with("https://"):
last_error = "Die Download-Adresse muss HTTPS verwenden."
return {}
var target_name := _safe_file_name(file_name)
var response := _http.request(
HTTPClient.METHOD_GET,
url,
PackedStringArray(["Accept: application/octet-stream"]),
PackedByteArray(),
DOWNLOAD_TIMEOUT_MSEC
)
if response.is_empty():
last_error = _http.last_error
return {}
var status := int(response.get("status", 0))
if status != 200:
last_error = "Der Update-Download antwortet mit HTTP %d." % status
return {}
var payload: PackedByteArray = response.get("body", PackedByteArray())
if payload.is_empty():
last_error = "Der Update-Download hat keine Daten geliefert."
return {}
if payload.size() > MAX_DOWNLOAD_BYTES:
last_error = "Die Update-Datei ist unerwartet groß."
return {}
var target := DOWNLOAD_DIR.path_join(target_name)
var directory_error := DirAccess.make_dir_recursive_absolute(DOWNLOAD_DIR)
if directory_error != OK and not DirAccess.dir_exists_absolute(DOWNLOAD_DIR):
last_error = "Der Update-Ordner ist nicht beschreibbar."
return {}
var file := FileAccess.open(target, FileAccess.WRITE)
if file == null:
last_error = "Die Update-Datei konnte nicht gespeichert werden."
return {}
file.store_buffer(payload)
file.close()
if not expected_sha.is_empty():
var actual := FileAccess.get_sha256(target).to_lower()
if actual != expected_sha.to_lower():
_remove(target)
last_error = "Die Prüfsumme der Update-Datei stimmt nicht."
return {}
return {"path": target, "bytes": payload.size()}
static func _safe_file_name(value: String) -> String:
var name := value.strip_edges()
var query := name.find("?")
if query >= 0:
name = name.substr(0, query)
for character: String in ["/", "\\", ":", "*", "?", "\"", "<", ">", "|"]:
name = name.replace(character, "")
if name.is_empty() or name == "." or name == "..":
name = "rinkplanner-update"
return name
static func _remove(path: String) -> void:
if FileAccess.file_exists(path):
DirAccess.remove_absolute(ProjectSettings.globalize_path(path))

View file

@ -0,0 +1 @@
uid://ba4nt20p6hrer

View file

@ -0,0 +1,167 @@
class_name UpdateInfo
extends RefCounted
## Pure helpers for the update check: version comparison, endpoint payload
## validation, platform selection and the skipped-version state.
##
## The endpoint is a static JSON document served over HTTPS. Example:
## {
## "version": "0.2.0",
## "released": "2026-11-11",
## "notes": "Kurze Beschreibung der Neuerungen.",
## "downloads": {
## "macos": {"url": "...", "sha256": "...", "size": 71286441},
## "windows": {"url": "...", "sha256": "...", "size": 35000000}
## }
## }
const DEFAULT_ENDPOINT := "https://rinkplanner.programmschmiede.de/version.json"
const STATE_PATH := "user://update.cfg"
const VERSION_SETTING := "application/config/version"
## Version of the running build. The value comes from project.godot and is
## mirrored into the export presets for the platform metadata.
static func current_version() -> String:
return str(ProjectSettings.get_setting(VERSION_SETTING, "0.0.0")).strip_edges()
## Numeric version segments. Pre-release suffixes and leading "v" are ignored,
## so "v0.2.0-beta" compares like "0.2.0".
static func parse_version(text: String) -> PackedInt32Array:
var cleaned := text.strip_edges()
if cleaned.begins_with("v") or cleaned.begins_with("V"):
cleaned = cleaned.substr(1)
var parts := PackedInt32Array()
for token: String in cleaned.split("."):
var digits := ""
for index: int in range(token.length()):
var code := token.unicode_at(index)
if code < 48 or code > 57:
break
digits += token.substr(index, 1)
if digits.is_empty():
break
parts.append(int(digits))
while parts.size() > 1 and parts[parts.size() - 1] == 0:
parts.remove_at(parts.size() - 1)
return parts
## Returns -1, 0 or 1 like a comparator.
static func compare_versions(left: String, right: String) -> int:
var a := parse_version(left)
var b := parse_version(right)
var count := maxi(a.size(), b.size())
for index: int in range(count):
var value_a := a[index] if index < a.size() else 0
var value_b := b[index] if index < b.size() else 0
if value_a < value_b:
return -1
if value_a > value_b:
return 1
return 0
static func is_newer(candidate: String, current: String) -> bool:
return compare_versions(candidate, current) > 0
## Platform key used in the endpoint's "downloads" object.
static func platform_key(os_name: String = "") -> String:
var name := os_name if not os_name.is_empty() else OS.get_name()
match name:
"macOS", "OSX", "MacOS":
return "macos"
"Windows":
return "windows"
"Linux":
return "linux"
"Android":
return "android"
_:
return name.to_lower()
## Validates the endpoint response. Returns an empty dictionary when the
## payload is not usable, so callers can show a single error message.
static func parse_payload(data: Variant) -> Dictionary:
if not data is Dictionary:
return {}
var dict: Dictionary = data
var version := str(dict.get("version", "")).strip_edges()
if parse_version(version).is_empty():
return {}
var downloads: Variant = dict.get("downloads", {})
if not downloads is Dictionary or (downloads as Dictionary).is_empty():
return {}
return {
"version": version,
"released": str(dict.get("released", "")).strip_edges(),
"notes": _notes_text(dict.get("notes", "")),
"downloads": downloads,
}
## Download entry for one platform. Requires HTTPS and a non-empty URL.
static func download_for(info: Dictionary, platform: String) -> Dictionary:
var downloads: Variant = info.get("downloads", {})
if not downloads is Dictionary:
return {}
var entry: Variant = (downloads as Dictionary).get(platform, null)
if not entry is Dictionary:
return {}
var dict: Dictionary = entry
var url := str(dict.get("url", "")).strip_edges()
if not url.begins_with("https://"):
return {}
return {
"url": url,
"sha256": str(dict.get("sha256", "")).strip_edges().to_lower(),
"size": int(dict.get("size", 0)),
}
## Turns "2026-11-11" into "11.11.2026"; other values stay unchanged.
static func format_date(value: String) -> String:
var text := value.strip_edges()
if text.length() != 10:
return text
if text.substr(4, 1) != "-" or text.substr(7, 1) != "-":
return text
var year := text.substr(0, 4)
var month := text.substr(5, 2)
var day := text.substr(8, 2)
if not year.is_valid_int() or not month.is_valid_int() or not day.is_valid_int():
return text
return "%s.%s.%s" % [day, month, year]
static func load_skipped_version() -> String:
var config := ConfigFile.new()
if config.load(STATE_PATH) != OK:
return ""
return str(config.get_value("update", "skipped_version", "")).strip_edges()
static func remember_skipped_version(version: String) -> void:
var config := ConfigFile.new()
config.load(STATE_PATH)
config.set_value("update", "skipped_version", version.strip_edges())
config.save(STATE_PATH)
static func clear_skipped_version() -> void:
if FileAccess.file_exists(STATE_PATH):
DirAccess.remove_absolute(ProjectSettings.globalize_path(STATE_PATH))
static func _notes_text(value: Variant) -> String:
if value is Array:
var lines := PackedStringArray()
for item: Variant in value:
var line := str(item).strip_edges()
if not line.is_empty():
lines.append(line)
return "\n".join(lines)
return str(value).strip_edges()

View file

@ -0,0 +1 @@
uid://0twlni2uxvlb

View file

@ -0,0 +1,46 @@
class_name UpdateJob
extends RefCounted
## One blocking update operation for a worker thread. Mirrors [HubJob]: the
## controller owns the thread and reads [member result]/[member error] after it
## has finished.
enum Task {
CHECK,
DOWNLOAD,
}
var task: Task = Task.CHECK
var payload: Dictionary = {}
var result: Dictionary = {}
var error: String = ""
var progress: String = ""
func run(config: Dictionary) -> void:
error = ""
result = {}
progress = ""
var client := UpdateClient.new()
match task:
Task.CHECK:
progress = "Suche nach Updates …"
result = client.check(
str(config.get("endpoint", UpdateInfo.DEFAULT_ENDPOINT))
)
Task.DOWNLOAD:
progress = "Lade Update …"
result = client.download(
str(payload.get("url", "")),
str(payload.get("sha256", "")),
str(payload.get("file_name", "rinkplanner-update"))
)
_:
error = "Unbekannte Update-Aktion."
if result.is_empty() and error.is_empty():
error = client.last_error
if error.is_empty():
error = "Der Update-Server hat keine Daten geliefert."
progress = ""

View file

@ -0,0 +1 @@
uid://41poctrntwic

View file

@ -28,6 +28,7 @@ enum FileAction {
SYNC_SETTINGS,
MANAGE_ROUTINES,
HUB_OPEN,
UPDATE_CHECK,
}
const DEFAULT_SPEED_MPS := 4.3
@ -120,10 +121,18 @@ const COMPACT_LAYOUT_WIDTH := 1390.0
## are normal (output latency, dropped frames); only larger drift is corrected.
const MUSIC_DRIFT_TOLERANCE_SECONDS := 0.35
const MAX_MUSIC_FILE_BYTES := 64 * 1024 * 1024
const UPDATE_FILE_NAMES := {
"macos": "rinkplanner-setup.dmg",
"windows": "rinkplanner-setup.exe",
"linux": "rinkplanner-setup",
}
## Tests disable these before adding the scene to the tree.
@export var restore_autosave: bool = true
@export var autosave_enabled: bool = true
## Automatic update check on start. Only exported desktop builds check; the
## editor and the headless tests stay offline.
@export var check_for_updates: bool = true
@onready var rink_canvas: RinkCanvas = %RinkCanvas
@onready var title_label: Label = %Title
@ -254,6 +263,8 @@ const MAX_MUSIC_FILE_BYTES := 64 * 1024 * 1024
@onready var hub_account_value: Label = %HubAccountValue
@onready var hub_connect_button: Button = %HubConnectButton
@onready var hub_dialog: AcceptDialog = %HubDialog
@onready var update_dialog: ConfirmationDialog = %UpdateDialog
@onready var update_text: Label = %UpdateText
@onready var hub_dialog_account: Label = %HubDialogAccount
@onready var hub_search_edit: LineEdit = %HubSearchEdit
@onready var hub_search_button: Button = %HubSearchButton
@ -354,6 +365,11 @@ var _hub_job: HubJob
var _hub_running: bool = false
var _hub_items: Array[Dictionary] = []
var _hub_pending_download: Dictionary = {}
var _update_thread: Thread
var _update_job: UpdateJob
var _update_running: bool = false
var _update_available: Dictionary = {}
var _update_manual: bool = false
var _cleanup_candidates: Array = []
var _pending_delete_name: String = ""
var _pending_rename_name: String = ""
@ -529,6 +545,8 @@ func _ready() -> void:
)
cloud_auth_dialog.confirmed.connect(_on_cloud_auth_confirmed)
cloud_auth_dialog.canceled.connect(_on_cloud_auth_canceled)
update_dialog.confirmed.connect(_on_update_confirmed)
update_dialog.canceled.connect(_on_update_canceled)
label_button.pressed.connect(_open_label_dialog)
multi_select_button.toggled.connect(_on_multi_select_toggled)
group_sequence_button.pressed.connect(_on_group_sequence_pressed)
@ -556,6 +574,9 @@ func _ready() -> void:
if not (restore_autosave and _restore_session()):
new_routine()
if check_for_updates:
_start_update_check.call_deferred(false)
func get_routine() -> Routine:
return _routine
@ -3861,6 +3882,7 @@ func _process(delta: float) -> void:
_poll_sync_thread()
_poll_oauth_thread()
_poll_hub_thread()
_poll_update_thread()
if _sync_running and _sync_job != null and not _sync_job.progress.is_empty():
status_label.text = "Sync: " + _sync_job.progress
@ -5249,6 +5271,8 @@ func _setup_file_menu() -> void:
popup.add_item("Jetzt synchronisieren", FileAction.SYNC_NOW)
popup.add_item("Sync-Einstellungen…", FileAction.SYNC_SETTINGS)
popup.add_item("Küren verwalten…", FileAction.MANAGE_ROUTINES)
popup.add_separator()
popup.add_item("Nach Updates suchen…", FileAction.UPDATE_CHECK)
popup.id_pressed.connect(_on_file_menu_pressed)
@ -5274,6 +5298,8 @@ func _on_file_menu_pressed(action: int) -> void:
_open_routine_manager()
FileAction.HUB_OPEN:
_open_hub_dialog()
FileAction.UPDATE_CHECK:
_start_update_check(true)
func _set_routine(routine: Routine, path: String) -> void:
@ -8013,3 +8039,317 @@ func _update_status() -> void:
_:
hint = "Tippen: Sprung setzen · Element-Button: Kürzel, Kombination"
status_label.text = "%s | %s" % [text, hint]
# --- Update check -----------------------------------------------------------
func _start_update_check(manual: bool) -> void:
if _update_running:
if manual:
_show_message("Es läuft bereits eine Update-Prüfung.")
return
if not manual and not _update_check_allowed():
return
_update_manual = manual
if manual:
status_label.text = "Suche nach Updates …"
_start_update_job(UpdateJob.Task.CHECK)
## Only exported desktop builds check automatically; the editor and the
## headless tests must not touch the network on start.
func _update_check_allowed() -> bool:
if not OS.has_feature("template") or OS.has_feature("web"):
return false
return UpdateInfo.platform_key() in ["macos", "windows", "linux"]
func _start_update_job(task: UpdateJob.Task, payload: Dictionary = {}) -> void:
_update_job = UpdateJob.new()
_update_job.task = task
_update_job.payload = payload
_update_thread = Thread.new()
var thread_error := _update_thread.start(
_update_job.run.bind({"endpoint": UpdateInfo.DEFAULT_ENDPOINT})
)
if thread_error != OK:
_update_thread = null
_update_job = null
_update_running = false
if _update_manual:
_show_message(
"Update-Prüfung konnte nicht gestartet werden (Fehler %d)."
% thread_error
)
else:
push_warning("Update check thread failed: %d" % thread_error)
return
_update_running = true
func _poll_update_thread() -> void:
if _update_thread == null or _update_thread.is_alive():
return
_update_thread.wait_to_finish()
_update_thread = null
_update_running = false
var job := _update_job
_update_job = null
if job == null:
return
_finish_update_job(job)
func _finish_update_job(job: UpdateJob) -> void:
if not job.error.is_empty():
_update_available = {}
if _update_manual:
status_label.text = "Update-Prüfung fehlgeschlagen."
_show_message("Update-Prüfung:\n\n" + job.error)
else:
push_warning("Update check failed: " + job.error)
return
match job.task:
UpdateJob.Task.CHECK:
_finish_update_check(job)
UpdateJob.Task.DOWNLOAD:
_finish_update_download(job)
_:
pass
func _finish_update_check(job: UpdateJob) -> void:
var info := job.result
var current := UpdateInfo.current_version()
var remote := str(info.get("version", "")).strip_edges()
if not UpdateInfo.is_newer(remote, current):
if _update_manual:
status_label.text = "Rinkplanner ist aktuell."
_show_message("Rinkplanner ist aktuell (Version %s)." % current)
return
var platform := UpdateInfo.platform_key()
var download := UpdateInfo.download_for(info, platform)
if download.is_empty():
if _update_manual:
status_label.text = "Kein Update für diese Plattform."
_show_message(
(
"Version %s ist verfügbar, aber für %s liegt keine "
+ "Update-Datei bereit."
) % [remote, OS.get_name()]
)
return
if not _update_manual and UpdateInfo.load_skipped_version() == remote:
return
_update_available = info.duplicate(true)
_update_available["download"] = download
_update_available["platform"] = platform
update_text.text = _update_dialog_text(_update_available, download, current)
update_dialog.popup_centered(Vector2i(640, 420))
func _update_dialog_text(
info: Dictionary,
download: Dictionary,
current: String
) -> String:
var remote := str(info.get("version", "")).strip_edges()
var lines := PackedStringArray([
"Rinkplanner %s ist verfügbar." % remote,
"Installiert: %s" % current,
])
var released := UpdateInfo.format_date(str(info.get("released", "")))
if not released.is_empty():
lines.append("Veröffentlicht: %s" % released)
var notes := str(info.get("notes", "")).strip_edges()
if not notes.is_empty():
lines.append("")
lines.append(notes)
var size := int(download.get("size", 0))
if size > 0:
lines.append("")
lines.append("Download: %.1f MB" % (float(size) / 1048576.0))
lines.append("")
lines.append(_update_install_hint(str(info.get("platform", ""))))
return "\n".join(lines)
func _update_install_hint(platform: String) -> String:
match platform:
"macos":
return (
"Nach der Bestätigung wird die neue App heruntergeladen, "
+ "geprüft und die aktuelle Installation ersetzt. Rinkplanner "
+ "startet danach neu."
)
"windows":
return (
"Nach der Bestätigung wird der Installer heruntergeladen und "
+ "gestartet. Rinkplanner beendet sich dafür."
)
"linux":
return (
"Nach der Bestätigung wird das Update heruntergeladen und "
+ "anschließend im Dateimanager geöffnet."
)
_:
return "Nach der Bestätigung wird das Update heruntergeladen."
func _on_update_confirmed() -> void:
if _update_available.is_empty() or _update_running:
return
var download: Dictionary = _update_available.get("download", {})
var version := str(_update_available.get("version", "")).strip_edges()
var platform := str(_update_available.get("platform", ""))
var file_name := str(UPDATE_FILE_NAMES.get(platform, "rinkplanner-update"))
status_label.text = "Update: Lade Rinkplanner %s …" % version
_start_update_job(UpdateJob.Task.DOWNLOAD, {
"url": str(download.get("url", "")),
"sha256": str(download.get("sha256", "")),
"file_name": file_name,
})
func _on_update_canceled() -> void:
if not _update_available.is_empty():
UpdateInfo.remember_skipped_version(
str(_update_available.get("version", ""))
)
_update_available = {}
status_label.text = "Update verschoben."
func _finish_update_download(job: UpdateJob) -> void:
var path := str(job.result.get("path", ""))
if path.is_empty():
_update_available = {}
status_label.text = "Update fehlgeschlagen."
_show_message("Das Update konnte nicht heruntergeladen werden.")
return
var version := str(_update_available.get("version", "")).strip_edges()
status_label.text = "Update: Installiere Rinkplanner %s …" % version
await get_tree().process_frame
var message := _install_update(path)
_update_available = {}
if not message.is_empty():
_show_message(message)
func _install_update(path: String) -> String:
match OS.get_name():
"macOS":
return _install_macos_update(path)
"Windows":
return _install_windows_update(path)
_:
return _open_update_folder(path)
## Mounts the DMG and replaces the running bundle in place. Falls back to
## opening the image when the copy is not possible (permissions, unbundled
## editor run).
func _install_macos_update(path: String) -> String:
var output: Array = []
var attach_code := OS.execute(
"/usr/bin/hdiutil",
["attach", "-nobrowse", "-readonly", path],
output,
true
)
if attach_code != 0:
OS.shell_open(path)
return (
"Das Update wurde heruntergeladen und im Finder geöffnet. Bitte "
+ "die App aus dem Image in den Programme-Ordner ziehen."
)
var mount := _find_mount_point(output)
var app_name := ""
if not mount.is_empty() and DirAccess.dir_exists_absolute(mount):
for entry: String in DirAccess.get_directories_at(mount):
if entry.ends_with(".app"):
app_name = entry
break
var target := _current_app_bundle()
if mount.is_empty() or app_name.is_empty() or target.is_empty():
if not mount.is_empty():
OS.execute("/usr/bin/hdiutil", ["detach", mount, "-quiet"], output, true)
OS.shell_open(path)
return (
"Das Update wurde heruntergeladen und im Finder geöffnet. Bitte "
+ "die App aus dem Image in den Programme-Ordner ziehen."
)
var source := mount.path_join(app_name)
var copy_output: Array = []
var copy_code := OS.execute(
"/usr/bin/ditto",
[source, target],
copy_output,
true
)
OS.execute("/usr/bin/hdiutil", ["detach", mount, "-quiet"], output, true)
if copy_code != 0:
OS.shell_open(path)
return (
"Das Update wurde heruntergeladen, konnte aber nicht automatisch "
+ "installiert werden. Das Image ist geöffnet; bitte die App "
+ "manuell ersetzen."
)
_remove_update_file(path)
OS.create_process("/usr/bin/open", ["-n", target])
_quit_after_update.call_deferred()
return ""
func _install_windows_update(path: String) -> String:
var global_path := ProjectSettings.globalize_path(path)
var pid := OS.create_process(global_path, [])
if pid <= 0:
OS.shell_open(global_path)
return (
"Der Installer wurde heruntergeladen und im Explorer geöffnet. "
+ "Bitte die Installation abschließen."
)
_quit_after_update.call_deferred()
return ""
func _open_update_folder(path: String) -> String:
var folder := ProjectSettings.globalize_path(path.get_base_dir())
OS.shell_open(folder)
return "Das Update wurde nach\n%s\nheruntergeladen." % folder
func _find_mount_point(output: Array) -> String:
for raw: Variant in output:
for line: String in str(raw).split("\n"):
var fields := line.split("\t")
if fields.size() < 3:
continue
var candidate := fields[fields.size() - 1].strip_edges()
if candidate.begins_with("/Volumes/"):
return candidate
return ""
static func _current_app_bundle() -> String:
var executable := OS.get_executable_path()
var marker := executable.find(".app/")
var bundle := ""
if marker >= 0:
bundle = executable.substr(0, marker + 4)
elif executable.ends_with(".app"):
bundle = executable
if bundle.is_empty() or not DirAccess.dir_exists_absolute(bundle):
return ""
return bundle
func _quit_after_update() -> void:
await get_tree().create_timer(1.0).timeout
get_tree().quit()
static func _remove_update_file(path: String) -> void:
if FileAccess.file_exists(path):
DirAccess.remove_absolute(ProjectSettings.globalize_path(path))

View file

@ -0,0 +1,26 @@
extends SceneTree
## Manual check against the live update endpoint. Not part of the test suite.
## godot --headless --path rinkplanner --script res://tests/manual/check_update.gd
func _init() -> void:
_run.call_deferred()
func _run() -> void:
print("Installiert: ", UpdateInfo.current_version())
print("Endpunkt: ", UpdateInfo.DEFAULT_ENDPOINT)
var client := UpdateClient.new()
var info := client.check(UpdateInfo.DEFAULT_ENDPOINT)
if info.is_empty():
printerr("Update-Prüfung fehlgeschlagen: ", client.last_error)
quit(1)
return
var remote := str(info.get("version", ""))
print("Veröffentlicht: ", remote)
print("Neuer: ", UpdateInfo.is_newer(remote, UpdateInfo.current_version()))
var platform := UpdateInfo.platform_key()
var download := UpdateInfo.download_for(info, platform)
print("Plattform: ", platform)
print("Download: ", download)
quit(0)

View file

@ -0,0 +1 @@
uid://c45knw4nvdwuo

View file

@ -0,0 +1,227 @@
extends SceneTree
## Headless tests for the update check: version comparison, endpoint payload
## validation, platform selection, skipped-version state and the dialog wiring.
## No network access is required.
const WhiteboardScene := preload("res://scenes/whiteboard/whiteboard.tscn")
var _assertions: int = 0
var _failures: PackedStringArray = PackedStringArray()
func _init() -> void:
_run.call_deferred()
func _run() -> void:
_test_current_version()
_test_version_comparison()
_test_platform_keys()
_test_payload_parsing()
_test_download_selection()
_test_date_format()
_test_skipped_state()
await _test_controller_wiring()
UpdateInfo.clear_skipped_version()
_finish()
func _test_current_version() -> void:
var configured := str(
ProjectSettings.get_setting("application/config/version", "")
).strip_edges()
_check(not configured.is_empty(), "project.godot setzt eine Version")
_check(
UpdateInfo.current_version() == configured,
"die Laufzeitversion kommt aus project.godot"
)
_check(
not UpdateInfo.parse_version(UpdateInfo.current_version()).is_empty(),
"die Laufzeitversion ist numerisch"
)
func _test_version_comparison() -> void:
_check(UpdateInfo.is_newer("0.2.0", "0.1.0"), "0.2.0 ist neuer als 0.1.0")
_check(
not UpdateInfo.is_newer("0.1.0", "0.1.0"),
"gleiche Versionen sind nicht neuer"
)
_check(
not UpdateInfo.is_newer("0.1.0", "0.2.0"),
"ältere Versionen sind nicht neuer"
)
_check(
UpdateInfo.is_newer("0.10.0", "0.9.9"),
"Versionen werden numerisch und nicht lexikografisch verglichen"
)
_check(
UpdateInfo.compare_versions("1.0", "1.0.0") == 0,
"fehlende Segmente zählen als Null"
)
_check(
UpdateInfo.is_newer("v0.2.0-beta", "0.1.9"),
"v-Präfix und Vorab-Suffix werden ignoriert"
)
_check(
UpdateInfo.parse_version("0.2.0") == PackedInt32Array([0, 2]),
"abschließende Nullen werden entfernt"
)
func _test_platform_keys() -> void:
_check(UpdateInfo.platform_key("macOS") == "macos", "macOS wird erkannt")
_check(UpdateInfo.platform_key("Windows") == "windows", "Windows wird erkannt")
_check(UpdateInfo.platform_key("Linux") == "linux", "Linux wird erkannt")
_check(UpdateInfo.platform_key("Android") == "android", "Android wird erkannt")
func _test_payload_parsing() -> void:
var payload := {
"version": "0.2.0",
"released": "2026-11-11",
"notes": "Neu: Update-Prüfung.",
"downloads": {
"macos": {"url": "https://example.org/rinkplanner.dmg", "size": 100},
},
}
var info := UpdateInfo.parse_payload(payload)
_check(str(info.get("version", "")) == "0.2.0", "die Version wird gelesen")
_check(
str(info.get("notes", "")) == "Neu: Update-Prüfung.",
"die Notizen werden gelesen"
)
_check(
info.get("downloads") is Dictionary,
"die Download-Liste bleibt erhalten"
)
_check(
UpdateInfo.parse_payload({"version": "abc"}).is_empty(),
"eine nicht numerische Version wird abgelehnt"
)
_check(
UpdateInfo.parse_payload({"version": "0.2.0"}).is_empty(),
"eine fehlende Download-Liste wird abgelehnt"
)
_check(UpdateInfo.parse_payload("kaputt").is_empty(), "Text wird abgelehnt")
_check(
UpdateInfo.parse_payload({
"version": "0.2.0",
"downloads": {"macos": {"url": "https://example.org/a.dmg"}},
"notes": ["Zeile 1", "Zeile 2"],
}).get("notes") == "Zeile 1\nZeile 2",
"Notizen dürfen als Liste kommen"
)
func _test_download_selection() -> void:
var info := {
"downloads": {
"macos": {
"url": "https://example.org/rinkplanner.dmg",
"sha256": "ABCDEF",
"size": 123,
},
"windows": {"url": "http://example.org/rinkplanner.exe"},
},
}
var mac := UpdateInfo.download_for(info, "macos")
_check(not mac.is_empty(), "ein HTTPS-Download wird ausgewählt")
_check(str(mac.get("sha256", "")) == "abcdef", "die Prüfsumme wird normalisiert")
_check(int(mac.get("size", 0)) == 123, "die Größe wird übernommen")
_check(
UpdateInfo.download_for(info, "windows").is_empty(),
"HTTP-Downloads werden abgelehnt"
)
_check(
UpdateInfo.download_for(info, "linux").is_empty(),
"fehlende Plattformen liefern keine Datei"
)
func _test_date_format() -> void:
_check(
UpdateInfo.format_date("2026-11-11") == "11.11.2026",
"ISO-Datum wird deutsch formatiert"
)
_check(
UpdateInfo.format_date("11.11.2026") == "11.11.2026",
"unbekannte Formate bleiben unverändert"
)
func _test_skipped_state() -> void:
UpdateInfo.clear_skipped_version()
_check(
UpdateInfo.load_skipped_version().is_empty(),
"ohne Zustand ist keine Version übersprungen"
)
UpdateInfo.remember_skipped_version("0.2.0")
_check(
UpdateInfo.load_skipped_version() == "0.2.0",
"die übersprungene Version wird gespeichert"
)
UpdateInfo.clear_skipped_version()
_check(
UpdateInfo.load_skipped_version().is_empty(),
"der Zustand lässt sich zurücksetzen"
)
func _test_controller_wiring() -> void:
var scene := WhiteboardScene.instantiate()
var controller := scene as WhiteboardController
controller.restore_autosave = false
controller.autosave_enabled = false
controller.check_for_updates = false
root.add_child(scene)
await process_frame
_check(controller.update_dialog != null, "der Update-Dialog ist verdrahtet")
_check(controller.update_text != null, "der Update-Text ist verdrahtet")
var popup := controller.file_menu_button.get_popup()
_check(
_find_menu_item(popup, "Nach Updates suchen…") >= 0,
"das Datei-Menü bietet die manuelle Update-Prüfung"
)
var text := controller._update_dialog_text(
{
"version": "0.3.0",
"released": "2026-12-01",
"notes": "Testnotiz",
"platform": "macos",
},
{"size": 1048576},
"0.2.0"
)
_check(text.contains("Rinkplanner 0.3.0"), "der Dialog nennt die neue Version")
_check(text.contains("0.2.0"), "der Dialog nennt die installierte Version")
_check(text.contains("Testnotiz"), "der Dialog zeigt die Notizen")
scene.queue_free()
await process_frame
func _find_menu_item(popup: PopupMenu, text: String) -> int:
for index: int in range(popup.item_count):
if popup.get_item_text(index) == text:
return index
return -1
func _check(condition: bool, message: String) -> void:
_assertions += 1
if not condition:
_failures.append(message)
func _finish() -> void:
if _failures.is_empty():
print("Update tests: %d checks passed." % _assertions)
quit(0)
return
printerr("Update tests failed (%d/%d):" % [_failures.size(), _assertions])
for failure: String in _failures:
printerr(" - " + failure)
quit(1)

View file

@ -0,0 +1 @@
uid://ca5ghpa3v4utn

View file

@ -43,7 +43,7 @@ VERSION="$(
sed -n 's/^[[:space:]]*application\/product_version="\([^"]*\)"/\1/p' \
"$PROJECT_DIR/export_presets.cfg" | head -1
)"
VERSION="${VERSION:-0.1.0.0}"
VERSION="${VERSION:-0.2.0.0}"
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
VERSION="$VERSION.0"
fi

178
tools/publish_version.sh Executable file
View file

@ -0,0 +1,178 @@
#!/usr/bin/env bash
# Veröffentlicht den Update-Endpunkt für die App.
#
# Erzeugt build/version.json aus der Version in rinkplanner/project.godot und
# den vorhandenen Installern und lädt ihn nach
# https://rinkplanner.programmschmiede.de/version.json
#
# Aufruf:
# ./tools/publish_version.sh # macOS-DMG veröffentlichen
# ./tools/publish_version.sh --windows # zusätzlich den Windows-Installer
# ./tools/publish_version.sh --no-upload # nur build/version.json schreiben
# ./tools/publish_version.sh --check # live-Endpunkt anzeigen
# ./tools/publish_version.sh --notes "Text" # Neuerungen im Dialog
#
# Beim Windows-Installer wird die Version nicht geprüft: erst bauen, dann mit
# --windows veröffentlichen.
set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/_export_common.sh"
MACOS="$REPO_ROOT/build/macos/rinkplanner-setup.dmg"
WINDOWS_EXE="$REPO_ROOT/build/windows/rinkplanner-setup.exe"
OUT="$REPO_ROOT/build/version.json"
ENDPOINT_URL="https://rinkplanner.programmschmiede.de/version.json"
FTP_TARGET_DIR="rinkplanner.programmschmiede.de"
NOTES=""
NO_UPLOAD=0
CHECK=0
WITH_WINDOWS=0
usage() {
cat <<'EOF'
Aufruf: tools/publish_version.sh [--windows] [--notes TEXT]
[--no-upload] [--check]
--windows Windows-Installer (build/windows/rinkplanner-setup.exe)
mit aufnehmen. Vorher neu bauen.
--notes Neuerungen für den Update-Dialog.
--no-upload Nur build/version.json schreiben, nicht hochladen.
--check Den live veröffentlichten Endpunkt anzeigen.
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--windows)
WITH_WINDOWS=1
shift
;;
--notes)
NOTES="${2:-}"
if [[ -z "$NOTES" ]]; then
echo "--notes braucht einen Text." >&2
exit 1
fi
shift 2
;;
--no-upload)
NO_UPLOAD=1
shift
;;
--check)
CHECK=1
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unbekannte Option: $1" >&2
usage >&2
exit 1
;;
esac
done
if [[ "$CHECK" -eq 1 ]]; then
curl -fsSL -H "Cache-Control: no-cache" "$ENDPOINT_URL"
exit 0
fi
VERSION="$(
sed -n 's/^config\/version="\([^"]*\)"/\1/p' "$PROJECT_DIR/project.godot" |
head -1
)"
if [[ -z "$VERSION" ]]; then
echo "Version fehlt in rinkplanner/project.godot (config/version)." >&2
exit 1
fi
MACOS_ARG=""
if [[ -f "$MACOS" ]]; then
MACOS_ARG="$MACOS"
fi
WINDOWS_ARG=""
if [[ "$WITH_WINDOWS" -eq 1 ]]; then
if [[ ! -f "$WINDOWS_EXE" ]]; then
echo "Windows-Installer fehlt: $WINDOWS_EXE" >&2
echo "Zuerst ./tools/export_windows_installer.sh ausführen." >&2
exit 1
fi
WINDOWS_ARG="$WINDOWS_EXE"
fi
if [[ -z "$MACOS_ARG" && -z "$WINDOWS_ARG" ]]; then
echo "Kein Installer gefunden. Zuerst bauen:" >&2
echo " ./tools/export_macos_installer.sh" >&2
echo " ./tools/export_windows_installer.sh" >&2
exit 1
fi
mkdir -p "$(dirname "$OUT")"
python3 - "$VERSION" "$NOTES" "$MACOS_ARG" "$WINDOWS_ARG" "$(date +%F)" <<'PY' > "$OUT"
import hashlib
import json
import os
import sys
version, notes, macos, windows, released = sys.argv[1:6]
base_url = "https://programmschmiede.de/rinkplanner/download/"
def entry(path):
digest = hashlib.sha256()
with open(path, "rb") as handle:
for chunk in iter(lambda: handle.read(1024 * 1024), b""):
digest.update(chunk)
return {
"url": base_url + os.path.basename(path),
"sha256": digest.hexdigest(),
"size": os.path.getsize(path),
}
data = {"version": version, "released": released, "downloads": {}}
if notes.strip():
data["notes"] = notes.strip()
if macos:
data["downloads"]["macos"] = entry(macos)
if windows:
data["downloads"]["windows"] = entry(windows)
json.dump(data, sys.stdout, indent=2, ensure_ascii=False)
print()
PY
echo "Version: $VERSION"
cat "$OUT"
if [[ "$NO_UPLOAD" -eq 1 ]]; then
echo "Nicht hochgeladen (--no-upload). Datei: $OUT"
exit 0
fi
CREDENTIALS="$REPO_ROOT/docs/credentials.txt"
if [[ ! -f "$CREDENTIALS" ]]; then
echo "Zugangsdaten fehlen: $CREDENTIALS" >&2
exit 1
fi
set -a
# shellcheck disable=SC1090
source "$CREDENTIALS"
set +a
curl -sS --ftp-pasv --user "$FTP_USER:$FTP_PASSWORD" \
-T "$OUT" "ftp://$FTP_URL/$FTP_TARGET_DIR/version.json" \
-w "upload: %{http_code} %{size_upload} bytes\n"
REMOTE_TMP="$(mktemp "${TMPDIR:-/tmp}/rinkplanner-version.XXXXXX")"
trap 'rm -f "$REMOTE_TMP"' EXIT
curl -fsSL -H "Cache-Control: no-cache" "$ENDPOINT_URL" > "$REMOTE_TMP"
if ! cmp -s "$OUT" "$REMOTE_TMP"; then
echo "Hinweis: Der live ausgelieferte Endpunkt weicht noch ab (Cache?)." >&2
echo "Bitte gleich erneut mit --check prüfen." >&2
exit 2
fi
echo "Endpunkt: $ENDPOINT_URL"

View file

@ -78,6 +78,9 @@ fi
"$GODOT" --headless --path "$PROJECT_DIR" \
--script res://tests/run_hub_tests.gd
"$GODOT" --headless --path "$PROJECT_DIR" \
--script res://tests/run_update_tests.gd
"$GODOT" --headless --path "$PROJECT_DIR" \
--script res://tests/run_asset_manifest_tests.gd

View file

@ -1,13 +1,13 @@
; Rinkplanner Windows-Installer (per-user, ohne Administratorrechte).
;
; Aufruf über tools/export_windows_installer.sh. Erwartet:
; -DAPP_VERSION=0.1.0.0
; -DAPP_VERSION=0.2.0.0
; -DSOURCE_EXE=/pfad/zu/rinkplanner.exe
; -DOUT_FILE=/pfad/zu/rinkplanner-setup.exe
; -DICON_FILE=/pfad/zu/rinkplanner.ico
!ifndef APP_VERSION
!define APP_VERSION "0.1.0.0"
!define APP_VERSION "0.2.0.0"
!endif
!ifndef SOURCE_EXE
!error "SOURCE_EXE fehlt (Pfad zur rinkplanner.exe)."