Skip to content

Commit

Permalink
Release PR#2 Release version will load dynamically from version.json (
Browse files Browse the repository at this point in the history
#1592)

* release version added to header

* version moved to footer

* version on the website is now dynamic and will be loaded from the version.json file

---------

Co-authored-by: Adrien Pavão <adrien.pavao@gmail.com>
  • Loading branch information
ihsaan-ullah and Didayolo authored Oct 1, 2024
1 parent 747acb2 commit 7ced144
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ <h4 class="ui inverted header">CodaBench</h4>
</div>
</div>
</div>
<div id="version"><a href="https://github.com/codalab/codabench/releases/tag/v1.1.0" target="_blank">v1.1.0</a></div>
{% if VERSION_INFO.tag_name != 'invalid' and VERSION_INFO.tag_name != 'unknown' %}
<div id="version">
<a href="{{ VERSION_INFO.release_url }}" target="_blank">{{ VERSION_INFO.tag_name }}</a>
</div>
{% endif %}
</div>
{# Admin only user switching #}
<user_switch></user_switch>
Expand Down
17 changes: 16 additions & 1 deletion src/utils/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import json

import os
from django.conf import settings

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Set the absolute path for the version file
VERSION_FILE_PATH = os.path.join(os.path.dirname(BASE_DIR), 'version.json')


def common_settings(request):
if request.user.is_authenticated:
Expand All @@ -18,6 +22,16 @@ def common_settings(request):
else:
user_json_data = {"logged_in": False}

# Read version information from the version.json file
version_info = {}
try:
with open(VERSION_FILE_PATH) as version_file:
version_info = json.load(version_file)
except FileNotFoundError:
version_info = {"tag_name": "unknown"}
except json.JSONDecodeError:
version_info = {"tag_name": "invalid"}

return {
'STORAGE_TYPE': settings.STORAGE_TYPE,
'MAX_EXECUTION_TIME_LIMIT': settings.MAX_EXECUTION_TIME_LIMIT,
Expand All @@ -26,4 +40,5 @@ def common_settings(request):
'FLOWER_URL': f"http://{settings.DOMAIN_NAME}:{settings.FLOWER_PUBLIC_PORT}",
'ENABLE_SIGN_UP': settings.ENABLE_SIGN_UP,
'ENABLE_SIGN_IN': settings.ENABLE_SIGN_IN,
'VERSION_INFO': version_info,
}
7 changes: 7 additions & 0 deletions version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tag_name": "v1.11.0",
"release_name": "Release 1.11.0",
"published_at": "2024-09-16",
"body": "",
"release_url": "https://github.com/codalab/codabench/releases/tag/v1.11.0"
}

0 comments on commit 7ced144

Please sign in to comment.