Skip to content

Commit 4c9da8e

Browse files
committed
feature: new dynamic version number control in code
1 parent 48afe5d commit 4c9da8e

9 files changed

Lines changed: 24 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,16 @@ jobs:
4444
- name: Set up Docker Buildx
4545
uses: docker/setup-buildx-action@v3
4646

47+
- name: Get short SHA
48+
id: vars
49+
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
50+
4751
- name: Build and push Docker image
4852
uses: docker/build-push-action@v5
4953
with:
5054
context: .
5155
push: true
5256
tags: ${{ steps.meta.outputs.tags }}
5357
labels: ${{ steps.meta.outputs.labels }}
58+
build-args: |
59+
APP_VERSION=${{ steps.meta.outputs.version == 'main' && format('latest-{0}', env.sha_short) || steps.meta.outputs.version }}

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ FROM oven/bun:1 AS frontend-builder
33

44
WORKDIR /app/frontend
55

6+
# Catch build argument and expose it to Vite
7+
ARG APP_VERSION=dev
8+
ENV VITE_APP_VERSION=$APP_VERSION
9+
610
# Copy package files
711
COPY frontend/package.json frontend/bun.lock ./
812

@@ -22,6 +26,10 @@ FROM python:3.14-slim AS backend-runner
2226

2327
WORKDIR /app
2428

29+
# Catch build argument and expose it to the backend
30+
ARG APP_VERSION=dev
31+
ENV RAPTR_VERSION=$APP_VERSION
32+
2533
# Install uv
2634
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
2735

backend/app/core/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Settings(BaseSettings):
1414
LOG_LEVEL: str = "INFO"
1515

1616
# General settings
17+
RAPTR_VERSION: str = "dev-local"
1718
APPLICATION_NAME: str = "RAPTR"
1819
ADMIN_EMAIL: str = "admin@raptr.app"
1920
ADMIN_PASSWORD: str | None = None

backend/app/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async def lifespan(app: FastAPI):
3535
app = FastAPI(
3636
lifespan=lifespan,
3737
title="RAPTR Backend API",
38-
version="0.1.0-beta.1",
38+
version=settings.RAPTR_VERSION,
3939
openapi_url="/openapi.json" if settings.FASTAPI_DOCUMENTATION else None,
4040
)
4141

backend/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "raptr-backend-api"
3-
version = "0.1.0-beta.1"
3+
version = "0.0.0.dev0"
44
description = "The backend API for the RAPTR application"
55
readme = "README.md"
66
requires-python = ">=3.14"

backend/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/openapi.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "raptr",
33
"private": true,
4-
"version": "0.1.0-beta.1",
4+
"version": "dev-local",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

frontend/vite.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import path from 'node:path';
22
import tailwindcss from '@tailwindcss/vite';
33
import vue from '@vitejs/plugin-vue';
44
import { defineConfig } from 'vite';
5+
import pkg from './package.json';
56

67
export default defineConfig({
78
plugins: [vue(), tailwindcss()],
@@ -11,6 +12,8 @@ export default defineConfig({
1112
},
1213
},
1314
define: {
14-
__APP_VERSION__: JSON.stringify(process.env.npm_package_version),
15+
__APP_VERSION__: JSON.stringify(
16+
process.env.VITE_APP_VERSION || pkg.version,
17+
),
1518
},
1619
});

0 commit comments

Comments
 (0)