v0.1.2: Add VERSION.txt with build-time injection
This commit is contained in:
10
AGENTS.md
10
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.
|
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
|
## 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.1: System default AI configuration via env vars, "Use system default" checkbox in settings
|
||||||
- 0.1.0: Automatic geolocation capture, Starlight documentation site
|
- 0.1.0: Automatic geolocation capture, Starlight documentation site
|
||||||
- 0.0.6: Automatic geolocation capture on event creation, reverse geocoding to place names
|
- 0.0.6: Automatic geolocation capture on event creation, reverse geocoding to place names
|
||||||
|
|||||||
10
Dockerfile
10
Dockerfile
@@ -1,5 +1,9 @@
|
|||||||
# Multi-stage build: Backend + Frontend
|
# 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
|
FROM oven/bun:1.1-alpine AS backend-builder
|
||||||
|
COPY --from=version /tmp/version.txt /tmp/version.txt
|
||||||
|
|
||||||
WORKDIR /app/backend
|
WORKDIR /app/backend
|
||||||
COPY backend/package*.json ./
|
COPY backend/package*.json ./
|
||||||
@@ -7,11 +11,13 @@ RUN bun install
|
|||||||
COPY backend/prisma ./prisma
|
COPY backend/prisma ./prisma
|
||||||
RUN bunx prisma generate
|
RUN bunx prisma generate
|
||||||
COPY backend/src ./src
|
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
|
FROM node:20-alpine AS frontend-builder
|
||||||
ARG VITE_GIT_URL=https://git.kropa.tech/lotherk/deardiary
|
ARG VITE_GIT_URL=https://git.kropa.tech/lotherk/deardiary
|
||||||
ARG VITE_WEBSITE_URL=https://deardiary.lother.io
|
ARG VITE_WEBSITE_URL=https://deardiary.lother.io
|
||||||
|
COPY --from=backend-builder /tmp/version.txt /tmp/version.txt
|
||||||
|
|
||||||
WORKDIR /app/frontend
|
WORKDIR /app/frontend
|
||||||
COPY frontend/package*.json ./
|
COPY frontend/package*.json ./
|
||||||
@@ -19,7 +25,7 @@ RUN npm install
|
|||||||
COPY frontend ./
|
COPY frontend ./
|
||||||
ENV VITE_GIT_URL=$VITE_GIT_URL
|
ENV VITE_GIT_URL=$VITE_GIT_URL
|
||||||
ENV VITE_WEBSITE_URL=$VITE_WEBSITE_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
|
FROM oven/bun:1.1-alpine AS runner
|
||||||
|
|
||||||
|
|||||||
1
VERSION.txt
Normal file
1
VERSION.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0.1.2
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "deardiary-backend",
|
"name": "deardiary-backend",
|
||||||
"version": "0.0.3",
|
"version": "{{VERSION}}",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun --watch src/index.ts",
|
"dev": "bun --watch 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';
|
const MIN_IMPORT_VERSION = '0.0.3';
|
||||||
|
|
||||||
interface ExportData {
|
interface ExportData {
|
||||||
|
|||||||
22
build-version.sh
Executable file
22
build-version.sh
Executable file
@@ -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."
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "deardiary-frontend",
|
"name": "deardiary-frontend",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.1.0",
|
"version": "{{VERSION}}",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
Reference in New Issue
Block a user