Skip to content

Commit 9e2b524

Browse files
dragoneeclaude
andcommitted
feat: add app version footer with deployment tracking
Add automatic version tracking via REVISION file generated during deployment. Display version in a fixed footer on all pages except the tasks app. Changes: - Generate REVISION file in deploy workflow with format: version-revision - Add app_version context processor to read and cache REVISION file - Add footer to base.html that shows when APP_VERSION is available - Style footer as fixed bottom-right element with subtle appearance - Hide footer on tasks app page (body_class: app-tasks) - Add REVISION to .gitignore to exclude from version control The version footer only appears in production where the REVISION file exists, and remains hidden during local development. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 003c1f6 commit 9e2b524

File tree

7 files changed

+69
-3
lines changed

7 files changed

+69
-3
lines changed

.github/workflows/deploy.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ jobs:
1616
deploy:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
2022
- uses: actions/setup-python@v4
2123
with:
2224
python-version: '3.10'
@@ -48,6 +50,11 @@ jobs:
4850
run: npm run build-dist
4951
- name: Copy static assets
5052
run: python3 manage.dist.py collectstatic --noinput
53+
- name: Generate REVISION file
54+
run: |
55+
git fetch --tags
56+
git describe --tags > tasks/REVISION
57+
echo "Generated version: $(cat tasks/REVISION)"
5158
- name: Copy files to the server
5259
uses: burnett01/[email protected]
5360
with:

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,4 +343,5 @@ pbtasks-*.sql
343343

344344
# End of https://www.gitignore.io/api/vim,node,linux,macos,django,python,windows,notepadpp,sublimetext
345345

346-
.pyscn/
346+
.pyscn/
347+
REVISION
Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
from datetime import datetime
2+
from pathlib import Path
3+
from django.conf import settings
4+
5+
# Cache for APP_VERSION
6+
_app_version_cache = {'loaded': False, 'version': None}
27

38
def menu(request):
49
return {
510
'current_year': datetime.now().year
6-
}
11+
}
12+
13+
def app_version(request):
14+
"""Context processor to provide APP_VERSION from REVISION file.
15+
16+
Reads the REVISION file (created during deployment) and caches it in memory.
17+
Returns None if the file doesn't exist (e.g., in development).
18+
"""
19+
global _app_version_cache
20+
21+
# Return cached value if already loaded
22+
if _app_version_cache['loaded']:
23+
return {'APP_VERSION': _app_version_cache['version']}
24+
25+
# Try to read REVISION file
26+
revision_file = Path(settings.BASE_DIR) / 'REVISION'
27+
28+
if revision_file.exists():
29+
try:
30+
_app_version_cache['version'] = revision_file.read_text().strip()
31+
except (OSError, IOError):
32+
pass
33+
34+
_app_version_cache['loaded'] = True
35+
return {'APP_VERSION': _app_version_cache['version']}

tasks/assets/styles/example.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,4 +1857,24 @@ $calendar-color: rgba(223, 9, 9, 0.7);
18571857
background-color: #f8d7da;
18581858
border-color: #f5c6cb;
18591859
color: #721c24;
1860+
}
1861+
1862+
.app-version-footer {
1863+
position: fixed;
1864+
bottom: 10px;
1865+
right: 10px;
1866+
padding: 4px 8px;
1867+
background-color: rgba(0, 0, 0, 0.05);
1868+
border-radius: 3px;
1869+
font-size: 0.75rem;
1870+
color: #999;
1871+
z-index: 100;
1872+
1873+
.app-version {
1874+
font-family: monospace;
1875+
}
1876+
1877+
.app-tasks & {
1878+
display: none;
1879+
}
18601880
}

tasks/settings/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
'django.contrib.auth.context_processors.auth',
8383
'django.contrib.messages.context_processors.messages',
8484
'tasks.apps.tree.context_processors.menu',
85+
'tasks.apps.tree.context_processors.app_version',
8586
],
8687
},
8788
},

tasks/templates/base.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
<body class="{% block body_class %}{% endblock %}">
2929
{% block content %} {% endblock %}
3030

31+
{% if APP_VERSION %}
32+
<footer class="app-version-footer">
33+
<span class="app-version">{{ APP_VERSION }}</span>
34+
</footer>
35+
{% endif %}
36+
3137
{% block jsmount %}
3238
{% render_js 'app' %}
3339
{% endblock %}

tasks/templates/tree/tasks.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
{% block title %}Tasks | Tasks Collector{% endblock %}
55

6+
{% block body_class %}app-tasks{% endblock %}
7+
68
{% block content %}
79
<!-- Vue entry-point -->
810

0 commit comments

Comments
 (0)