Bisher waren beim Release sechs Stellen von Hand zu ändern; vergisst man eine, fällt es erst im Build oder beim Update-Dialog auf. - `tools/set_version.sh <x.y.z>` schreibt alle Ableitungen aus `project.godot` config/version: Windows `x.y.z.0`, macOS/Android `x.y.z`, Android `version/code = major*10000+minor*100+patch`, NSIS-Fallbacks. - `--check` prüft nur und schlägt bei Abweichung fehl; läuft jetzt in `./tools/test.sh` als erster Schritt. - `version/code` ist damit abgeleitet (0.4.0 -> 400) statt handgezählt. - Neu: `docs/deployment.md` beschreibt für Menschen die Regeln und den Ablauf über alle drei Build-Rechner (Version, Build, Upload, Endpunkt, Website, Nachkontrolle, häufige Fehler). - `docs/updates.md` verweist für Version und Checkliste dorthin, statt die Stellen doppelt zu führen.
113 lines
3.7 KiB
Bash
Executable file
113 lines
3.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Hält alle Versionsangaben an einer Quelle ausgerichtet.
|
|
#
|
|
# ./tools/set_version.sh 0.4.1 # Version setzen (project.godot + Ableitungen)
|
|
# ./tools/set_version.sh --check # nur prüfen, Exit 1 bei Abweichung
|
|
#
|
|
# Quelle ist `rinkplanner/project.godot` (config/version); der Rest wird
|
|
# abgeleitet. `--check` läuft in ./tools/test.sh, damit eine vergessene Stelle
|
|
# sofort auffällt. Details: docs/deployment.md
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
|
|
usage() {
|
|
sed -n '2,10p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'
|
|
}
|
|
|
|
MODE="set"
|
|
VERSION=""
|
|
case "${1:-}" in
|
|
--check) MODE="check" ;;
|
|
-h|--help) usage; exit 0 ;;
|
|
"") usage; exit 2 ;;
|
|
*) VERSION="$1" ;;
|
|
esac
|
|
|
|
python3 - "$REPO_ROOT" "$MODE" "$VERSION" <<'PY'
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
root = Path(sys.argv[1])
|
|
mode = sys.argv[2]
|
|
version = sys.argv[3]
|
|
|
|
PROJECT = root / "rinkplanner" / "project.godot"
|
|
PRESETS = root / "rinkplanner" / "export_presets.cfg"
|
|
NSI = root / "tools" / "windows_installer.nsi"
|
|
WIN_EXPORT = root / "tools" / "export_windows_installer.sh"
|
|
|
|
if mode == "set" and not re.fullmatch(r"\d+\.\d+\.\d+", version):
|
|
sys.exit(f"Ungültige Version: {version} (erwartet x.y.z)")
|
|
|
|
major, minor, patch = (int(part) for part in (
|
|
version.split(".") if version else re.search(
|
|
r'config/version="([^"]+)"', PROJECT.read_text()
|
|
).group(1).split(".")
|
|
))
|
|
version = f"{major}.{minor}.{patch}"
|
|
four = f"{version}.0"
|
|
code = major * 10000 + minor * 100 + patch
|
|
|
|
# (Datei, Regex auf eine Zeile, erwarteter Inhalt der Zeile)
|
|
SPEC = [
|
|
(PROJECT, r'^config/version="[^"]*"$', f'config/version="{version}"'),
|
|
(PRESETS, r'^application/file_version="[^"]*"$',
|
|
f'application/file_version="{four}"'),
|
|
(PRESETS, r'^application/product_version="[^"]*"$',
|
|
f'application/product_version="{four}"'),
|
|
(PRESETS, r'^application/short_version="[^"]*"$',
|
|
f'application/short_version="{version}"'),
|
|
(PRESETS, r'^application/version="[^"]*"$',
|
|
f'application/version="{version}"'),
|
|
(PRESETS, r'^version/name="[^"]*"$', f'version/name="{version}"'),
|
|
(PRESETS, r'^version/code=\d+$', f"version/code={code}"),
|
|
(NSI, r'^\s*!define APP_VERSION "[^"]*"$',
|
|
f' !define APP_VERSION "{four}"'),
|
|
(WIN_EXPORT, r'^VERSION="\$\{VERSION:-[^}]*\}"$',
|
|
f'VERSION="${{VERSION:-{four}}}"'),
|
|
]
|
|
|
|
problems = []
|
|
for path, pattern, expected in SPEC:
|
|
text = path.read_text()
|
|
lines = text.split("\n")
|
|
matches = [i for i, line in enumerate(lines) if re.match(pattern, line)]
|
|
if len(matches) != 1:
|
|
problems.append(
|
|
f"{path.relative_to(root)}: erwartet genau eine Stelle für {pattern}, "
|
|
f"gefunden {len(matches)}"
|
|
)
|
|
continue
|
|
index = matches[0]
|
|
if lines[index] != expected:
|
|
if mode == "check":
|
|
problems.append(
|
|
f"{path.relative_to(root)}:{index + 1}: "
|
|
f"'{lines[index].strip()}' statt '{expected}'"
|
|
)
|
|
else:
|
|
lines[index] = expected
|
|
path.write_text("\n".join(lines))
|
|
|
|
if mode == "check":
|
|
if problems:
|
|
print("Versionsangaben weichen ab:")
|
|
for problem in problems:
|
|
print(f" {problem}")
|
|
print("Setzen mit ./tools/set_version.sh <x.y.z>")
|
|
sys.exit(1)
|
|
print(f"Version {version} ist an allen Stellen konsistent.")
|
|
sys.exit(0)
|
|
|
|
if problems:
|
|
print("Versionsangaben konnten nicht gesetzt werden:")
|
|
for problem in problems:
|
|
print(f" {problem}")
|
|
sys.exit(1)
|
|
print(f"Version {version} gesetzt:")
|
|
print(f" project.godot, Export-Presets (Windows {four}, macOS/Android {version})")
|
|
print(f" Android version/code = {code}")
|
|
print(f" NSIS-Fallbacks in tools/windows_installer.nsi, export_windows_installer.sh")
|
|
PY
|