diff --git a/AGENTS.md b/AGENTS.md index 62505ce..003b8e8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -223,7 +223,17 @@ bun run test:server ``` Tests require the server running. The test script starts the server, runs tests, then stops it. +## Version Management + +Version is managed via `VERSION.txt` (single source of truth). All other version references (`backend/package.json`, `frontend/package.json`, `backend/src/index.ts`) use placeholder `{{VERSION}}` and are replaced at build time. + +### Versioning Rules +- Bump micro version (0.1.x) on every commit +- Update `VERSION.txt` before committing +- Never commit actual version numbers in source files + ## Version History +- 0.1.2: VERSION.txt build-time injection, docs nav fixes, blog link - 0.1.1: System default AI configuration via env vars, "Use system default" checkbox in settings - 0.1.0: Automatic geolocation capture, Starlight documentation site - 0.0.6: Automatic geolocation capture on event creation, reverse geocoding to place names diff --git a/Dockerfile b/Dockerfile index 3ab471c..8b15c93 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,9 @@ # Multi-stage build: Backend + Frontend +FROM alpine:latest AS version +COPY VERSION.txt /tmp/version.txt + FROM oven/bun:1.1-alpine AS backend-builder +COPY --from=version /tmp/version.txt /tmp/version.txt WORKDIR /app/backend COPY backend/package*.json ./ @@ -7,11 +11,13 @@ RUN bun install COPY backend/prisma ./prisma RUN bunx prisma generate COPY backend/src ./src -RUN bun build src/index.ts --outdir ./dist --target bun +COPY backend/package.json ./ +RUN sed -i "s/{{VERSION}}/$(cat /tmp/version.txt)/g" src/index.ts && sed -i "s/{{VERSION}}/$(cat /tmp/version.txt)/g" package.json && bun build src/index.ts --outdir ./dist --target bun FROM node:20-alpine AS frontend-builder ARG VITE_GIT_URL=https://git.kropa.tech/lotherk/deardiary ARG VITE_WEBSITE_URL=https://deardiary.lother.io +COPY --from=backend-builder /tmp/version.txt /tmp/version.txt WORKDIR /app/frontend COPY frontend/package*.json ./ @@ -19,7 +25,7 @@ RUN npm install COPY frontend ./ ENV VITE_GIT_URL=$VITE_GIT_URL ENV VITE_WEBSITE_URL=$VITE_WEBSITE_URL -RUN npm run build +RUN sed -i "s/{{VERSION}}/$(cat /tmp/version.txt)/g" package.json && npm run build FROM oven/bun:1.1-alpine AS runner diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 0000000..8294c18 --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +0.1.2 \ No newline at end of file diff --git a/backend/package.json b/backend/package.json index 403635c..0e1e334 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "deardiary-backend", - "version": "0.0.3", + "version": "{{VERSION}}", "type": "module", "scripts": { "dev": "bun --watch src/index.ts", diff --git a/backend/src/index.ts b/backend/src/index.ts index 6129bd1..d54bfdb 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -726,7 +726,7 @@ app.post('/api/v1/ai/test', async (c) => { } }); -const DEARDIARY_VERSION = '0.1.0'; +const DEARDIARY_VERSION = '{{VERSION}}'; const MIN_IMPORT_VERSION = '0.0.3'; interface ExportData { diff --git a/build-version.sh b/build-version.sh new file mode 100755 index 0000000..c53ed28 --- /dev/null +++ b/build-version.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Build script: injects version from VERSION.txt into all build-time locations + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$SCRIPT_DIR" + +VERSION=$(cat "$ROOT_DIR/VERSION.txt") + +echo "Injecting version $VERSION..." + +# Backend version constant +sed -i "s/const DEARDIARY_VERSION = '[^']*'/const DEARDIARY_VERSION = '$VERSION'/" "$ROOT_DIR/backend/src/index.ts" + +# Backend package.json +sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/" "$ROOT_DIR/backend/package.json" + +# Frontend package.json +sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/" "$ROOT_DIR/frontend/package.json" + +echo "Done." diff --git a/frontend/package.json b/frontend/package.json index c86aba5..3d1bb1f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "deardiary-frontend", "private": true, - "version": "0.1.0", + "version": "{{VERSION}}", "type": "module", "scripts": { "dev": "vite",