Skip to content

Commit

Permalink
start adding version info in admin interface
Browse files Browse the repository at this point in the history
  • Loading branch information
stitch committed May 10, 2023
1 parent faa13a4 commit b6a7e27
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ _db.sqlite3_
.devenv.flake.nix

.ruff_cache

# is generated during build, don't include in git
websecmap/__version__.py
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ ENV VENDOR_DIR /source/vendor/
# collect all static files form all django applications into static files directory
RUN /usr/local/bin/dashboard collectstatic

ARG VERSION=0.0.0-dev0
RUN echo "VERSION='$VERSION'" >> /source/dashboard/__version__.py

EXPOSE 8000

ENTRYPOINT [ "/usr/local/bin/dashboard" ]
Expand Down
2 changes: 1 addition & 1 deletion dashboard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
try:
from .__version__ import VERSION

print("Websecmap version: ", VERSION)
print("Dashboard version: ", VERSION)
except ModuleNotFoundError:
# if not available, that means the application is running in development
VERSION = "0.0.0.dev0"
Expand Down
5 changes: 4 additions & 1 deletion dashboard/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
from django.urls import include, path, re_path
from two_factor.urls import urlpatterns as tf_urls

admin.site.site_header = 'Dashboard Admin'
from . import __version__

admin.site.site_header = f'Dashboard Admin {__version__}'
# Don't show version in title, as that might be shared without auth
admin.site.site_title = 'Dashboard Admin'


Expand Down
10 changes: 10 additions & 0 deletions tools/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

# generate a new version number based on most recent tag and commit sha

tag_version=$(git describe --tags --abbrev=0)

sha=$(git rev-parse HEAD)
short_sha=${sha:0:8}

echo "${tag_version}+$short_sha"

0 comments on commit b6a7e27

Please sign in to comment.