diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02cdf3d..7440c95 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,11 +126,12 @@ jobs: - name: Checkout uses: actions/checkout@v4 - # App version from tauri.conf.json (e.g. 0.1.0); the run number keeps each - # tag unique → tag like v0.1.0-build.42. + # App version from the single source of truth, frontend/package.json (the + # same value Tauri names the installers from). The run number is appended + # as a -b suffix to keep each push's tag/release unique → e.g. v0.1.1-b42. - name: Resolve version id: version - run: echo "version=$(jq -r .version frontend/src-tauri/tauri.conf.json)" >> "$GITHUB_OUTPUT" + run: echo "version=$(jq -r .version frontend/package.json)" >> "$GITHUB_OUTPUT" - name: Download installers from both builds uses: actions/download-artifact@v4 @@ -140,8 +141,8 @@ jobs: - name: Publish release uses: softprops/action-gh-release@v2 with: - tag_name: v${{ steps.version.outputs.version }}-build.${{ github.run_number }} - name: Konduktor v${{ steps.version.outputs.version }} (build ${{ github.run_number }}) + tag_name: v${{ steps.version.outputs.version }}-b${{ github.run_number }} + name: Konduktor v${{ steps.version.outputs.version }}-b${{ github.run_number }} target_commitish: ${{ github.sha }} generate_release_notes: true # auto changelog from commits/PRs since last release fail_on_unmatched_files: true diff --git a/CLAUDE.md b/CLAUDE.md index 8870f6e..fa98879 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -158,6 +158,26 @@ frontend at `http://localhost:5173`. - Python 3.14 note: pin dependencies loosely enough to get prebuilt wheels (older `pydantic-core` pins force a from-source Rust build that fails). +## Versioning + +**There is ONE source of truth for the app version: the `version` field in +[frontend/package.json](frontend/package.json).** To release a new version, bump +that number and nothing else — everything derives from it: + +- **Tauri / installers** — `tauri.conf.json` sets `"version": "../package.json"`, + so the `.dmg`/`.exe` names + bundle version come from `package.json`. +- **Backend API** — `konduktor/__init__.py` `_read_version()` reads + `package.json` (dev: `/frontend/package.json`; frozen sidecar: bundled at + the PyInstaller root via `sys._MEIPASS`, added in `konduktor-sidecar.spec`). + `main.py` uses this for the FastAPI `version`. Falls back to `"0.0.0"` if not + found (cosmetic, must never crash startup). +- **CI release** — `.github/workflows/build.yml` reads it with + `jq .version frontend/package.json` and tags each push + `v-b` (release name `Konduktor v-b`). + The `-b` suffix keeps every push's tag/release unique. +- **NOT a source**: `src-tauri/Cargo.toml` `version` is inert Rust crate metadata + (Tauri uses the config's `../package.json`); don't treat it as the app version. + ## Roadmap - ✅ Phase 1 — backend core + read-only API diff --git a/backend/konduktor-sidecar.spec b/backend/konduktor-sidecar.spec index 2f3a483..cefe5a4 100644 --- a/backend/konduktor-sidecar.spec +++ b/backend/konduktor-sidecar.spec @@ -28,6 +28,11 @@ for pkg in ("uvloop", "httptools", "websockets"): # Imported by name, not statically discoverable. hiddenimports += ["multipart", "anyio"] +# Bundle the canonical version file so konduktor.__version__ can read it at +# runtime from sys._MEIPASS (frontend/package.json is the single source of the +# app version — see konduktor/__init__.py). Path is relative to this spec. +datas += [("../frontend/package.json", ".")] + a = Analysis( ["sidecar.py"], pathex=[], diff --git a/backend/konduktor/__init__.py b/backend/konduktor/__init__.py index 9bd9cb5..88a7378 100644 --- a/backend/konduktor/__init__.py +++ b/backend/konduktor/__init__.py @@ -1,3 +1,35 @@ """Konduktor — Traktor library management & track preparation.""" -__version__ = "0.1.1" +from __future__ import annotations + +import json +import sys +from pathlib import Path + + +def _read_version() -> str: + """Return the app version — the single source of truth is + ``frontend/package.json`` (also what Tauri names the installers from). + + - Dev / source checkout: read it from the repo, two levels up from this + package (``/frontend/package.json``). + - Frozen sidecar: ``package.json`` is bundled at the PyInstaller root (see + ``konduktor-sidecar.spec``), reachable via ``sys._MEIPASS``. + + Falls back to ``"0.0.0"`` if it can't be located (the FastAPI version string + is cosmetic, so a miss must never crash startup). + """ + candidates = [] + meipass = getattr(sys, "_MEIPASS", None) + if meipass: + candidates.append(Path(meipass) / "package.json") + candidates.append(Path(__file__).resolve().parents[2] / "frontend" / "package.json") + for path in candidates: + try: + return json.loads(path.read_text(encoding="utf-8"))["version"] + except Exception: + continue + return "0.0.0" + + +__version__ = _read_version() diff --git a/frontend/package.json b/frontend/package.json index ffabe20..6a56ba6 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "frontend", "private": true, - "version": "0.0.0", + "version": "0.1.1", "type": "module", "scripts": { "dev": "vite", diff --git a/frontend/src-tauri/Cargo.toml b/frontend/src-tauri/Cargo.toml index 81a3860..6341b4b 100644 --- a/frontend/src-tauri/Cargo.toml +++ b/frontend/src-tauri/Cargo.toml @@ -1,6 +1,9 @@ [package] name = "app" -version = "0.1.0" +# Rust crate metadata only — NOT the app version. The bundled app version comes +# from frontend/package.json (see tauri.conf.json `"version": "../package.json"`), +# so this value is inert for the installer/bundle and needn't be kept in sync. +version = "0.1.1" description = "A Tauri App" authors = ["you"] license = "" diff --git a/frontend/src-tauri/tauri.conf.json b/frontend/src-tauri/tauri.conf.json index d76661c..89035ef 100644 --- a/frontend/src-tauri/tauri.conf.json +++ b/frontend/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "productName": "Konduktor", - "version": "0.1.0", + "version": "../package.json", "identifier": "com.liquidicestudios.konduktor", "build": { "frontendDist": "../dist",