Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release PR#2 Release version will load dynamically from version.json #1592

Merged
merged 5 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}