new version script
This commit is contained in:
parent
2fdcdba889
commit
0688f46d8b
10
.github/workflows/build-docker-open-data.yml
vendored
10
.github/workflows/build-docker-open-data.yml
vendored
@ -34,16 +34,6 @@ jobs:
|
|||||||
echo VERSION=develop >> $GITHUB_OUTPUT
|
echo VERSION=develop >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update Version number
|
|
||||||
- name: Update version file
|
|
||||||
uses: DamianReeves/write-file-action@v1.2
|
|
||||||
with:
|
|
||||||
path: recipes/version.py
|
|
||||||
contents: |
|
|
||||||
VERSION_NUMBER = '${{ steps.get_version.outputs.VERSION }}-open-data'
|
|
||||||
BUILD_REF = '${{ github.sha }}'
|
|
||||||
write-mode: overwrite
|
|
||||||
|
|
||||||
# clone open data plugin
|
# clone open data plugin
|
||||||
- name: clone open data plugin repo
|
- name: clone open data plugin repo
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@master
|
||||||
|
10
.github/workflows/build-docker.yml
vendored
10
.github/workflows/build-docker.yml
vendored
@ -34,16 +34,6 @@ jobs:
|
|||||||
echo VERSION=develop >> $GITHUB_OUTPUT
|
echo VERSION=develop >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update Version number
|
|
||||||
- name: Update version file
|
|
||||||
uses: DamianReeves/write-file-action@v1.2
|
|
||||||
with:
|
|
||||||
path: recipes/version.py
|
|
||||||
contents: |
|
|
||||||
VERSION_NUMBER = '${{ steps.get_version.outputs.VERSION }}'
|
|
||||||
BUILD_REF = '${{ github.sha }}'
|
|
||||||
write-mode: overwrite
|
|
||||||
|
|
||||||
# Build Vue frontend
|
# Build Vue frontend
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
FROM python:3.10-alpine3.18
|
FROM python:3.10-alpine3.18
|
||||||
|
|
||||||
#Install all dependencies.
|
#Install all dependencies.
|
||||||
RUN apk add --no-cache postgresql-libs postgresql-client gettext zlib libjpeg libwebp libxml2-dev libxslt-dev openldap git
|
RUN apk add --no-cache postgresql-libs postgresql-client gettext zlib libjpeg libwebp libxml2-dev libxslt-dev openldap
|
||||||
|
|
||||||
#Print all logs without buffering it.
|
#Print all logs without buffering it.
|
||||||
ENV PYTHONUNBUFFERED 1
|
ENV PYTHONUNBUFFERED 1
|
||||||
@ -19,13 +19,14 @@ RUN \
|
|||||||
if [ `apk --print-arch` = "armv7" ]; then \
|
if [ `apk --print-arch` = "armv7" ]; then \
|
||||||
printf "[global]\nextra-index-url=https://www.piwheels.org/simple\n" > /etc/pip.conf ; \
|
printf "[global]\nextra-index-url=https://www.piwheels.org/simple\n" > /etc/pip.conf ; \
|
||||||
fi
|
fi
|
||||||
RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev zlib-dev jpeg-dev libwebp-dev openssl-dev libffi-dev cargo openldap-dev python3-dev && \
|
RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev zlib-dev jpeg-dev libwebp-dev openssl-dev libffi-dev cargo openldap-dev python3-dev git && \
|
||||||
echo -n "INPUT ( libldap.so )" > /usr/lib/libldap_r.so && \
|
echo -n "INPUT ( libldap.so )" > /usr/lib/libldap_r.so && \
|
||||||
python -m venv venv && \
|
python -m venv venv && \
|
||||||
/opt/recipes/venv/bin/python -m pip install --upgrade pip && \
|
/opt/recipes/venv/bin/python -m pip install --upgrade pip && \
|
||||||
venv/bin/pip install wheel==0.37.1 && \
|
venv/bin/pip install wheel==0.37.1 && \
|
||||||
venv/bin/pip install setuptools_rust==1.1.2 && \
|
venv/bin/pip install setuptools_rust==1.1.2 && \
|
||||||
venv/bin/pip install -r requirements.txt --no-cache-dir &&\
|
venv/bin/pip install -r requirements.txt --no-cache-dir &&\
|
||||||
|
/opt/recipes/venv/bin/python version.py && \
|
||||||
apk --purge del .build-deps
|
apk --purge del .build-deps
|
||||||
|
|
||||||
#Copy project and execute it.
|
#Copy project and execute it.
|
||||||
|
@ -18,32 +18,30 @@
|
|||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
|
|
||||||
<h3 class="mt-5">{% trans 'System Information' %}</h3>
|
<h3 class="mt-5">{% trans 'System Information' %}</h3>
|
||||||
|
{% if version_if %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-md-6">
|
<div class="col">
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
{% for v in version_info %}
|
{% for v in version_info %}
|
||||||
<div class="list-group-item list-group-item-action">
|
<div class="list-group-item list-group-item-action">
|
||||||
<div class="d-flex w-100 justify-content-between">
|
<div class="d-flex w-100 justify-content-between">
|
||||||
{% if v.website %}
|
<h5 class="mb-1">{{ v.name }} ({{ v.branch }}) {% if v.tag %}- {{ v.tag }}{% endif %}</h5>
|
||||||
<a href="{{ v.website }}" target="_blank"><h5 class="mb-1">{{ v.name }}</h5></a>
|
</div>
|
||||||
{% else %}
|
<pre class="card-text p-2" style="border: 1px solid lightgrey; border-radius: 5px" target="_blank">{{ v.version }}</pre>
|
||||||
<h5 class="mb-1">{{ v.name }}</h5>
|
<a href="{{ v.website }}">Website</a>
|
||||||
{% endif %}
|
|
||||||
{% if v.commit_link %}
|
{% if v.commit_link %}
|
||||||
<a href="{{ v.commit_link }}" target="_blank">Commit</a>
|
- <a href="{{ v.commit_link }}" target="_blank">Commit</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<pre class="card-text">{{ v.version }}</pre>
|
{% endfor %}
|
||||||
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% else %}
|
||||||
|
{% blocktrans %}
|
||||||
|
You need to execute <code>version.py</code> in your update script to generate version information (done automatically in docker).
|
||||||
|
{% endblocktrans %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<h4 class="mt-3">{% trans 'Media Serving' %} <span class="badge badge-{% if gunicorn_media %}danger{% else %}success{% endif %}">{% if gunicorn_media %}
|
<h4 class="mt-3">{% trans 'Media Serving' %} <span class="badge badge-{% if gunicorn_media %}danger{% else %}success{% endif %}">{% if gunicorn_media %}
|
||||||
{% trans 'Warning' %}{% else %}{% trans 'Ok' %}{% endif %}</span></h4>
|
{% trans 'Warning' %}{% else %}{% trans 'Ok' %}{% endif %}</span></h4>
|
||||||
@ -56,10 +54,9 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{% trans 'Everything is fine!' %}
|
{% trans 'Everything is fine!' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<br/>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<h4>{% trans 'Secret Key' %} <span
|
|
||||||
|
<h4 class="mt-3">{% trans 'Secret Key' %} <span
|
||||||
class="badge badge-{% if secret_key %}danger{% else %}success{% endif %}">{% if secret_key %}
|
class="badge badge-{% if secret_key %}danger{% else %}success{% endif %}">{% if secret_key %}
|
||||||
{% trans 'Warning' %}{% else %}{% trans 'Ok' %}{% endif %}</span></h4>
|
{% trans 'Warning' %}{% else %}{% trans 'Ok' %}{% endif %}</span></h4>
|
||||||
{% if secret_key %}
|
{% if secret_key %}
|
||||||
@ -72,10 +69,8 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{% trans 'Everything is fine!' %}
|
{% trans 'Everything is fine!' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<br/>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<h4>{% trans 'Debug Mode' %} <span
|
<h4 class="mt-3">{% trans 'Debug Mode' %} <span
|
||||||
class="badge badge-{% if debug %}danger{% else %}success{% endif %}">{% if debug %}
|
class="badge badge-{% if debug %}danger{% else %}success{% endif %}">{% if debug %}
|
||||||
{% trans 'Warning' %}{% else %}{% trans 'Ok' %}{% endif %}</span></h4>
|
{% trans 'Warning' %}{% else %}{% trans 'Ok' %}{% endif %}</span></h4>
|
||||||
{% if debug %}
|
{% if debug %}
|
||||||
@ -87,10 +82,8 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{% trans 'Everything is fine!' %}
|
{% trans 'Everything is fine!' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<br/>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<h4>{% trans 'Database' %} <span
|
<h4 class="mt-3">{% trans 'Database' %} <span
|
||||||
class="badge badge-{% if postgres %}warning{% else %}success{% endif %}">{% if postgres %}
|
class="badge badge-{% if postgres %}warning{% else %}success{% endif %}">{% if postgres %}
|
||||||
{% trans 'Info' %}{% else %}{% trans 'Ok' %}{% endif %}</span></h4>
|
{% trans 'Info' %}{% else %}{% trans 'Ok' %}{% endif %}</span></h4>
|
||||||
{% if postgres %}
|
{% if postgres %}
|
||||||
@ -101,12 +94,6 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{% trans 'Everything is fine!' %}
|
{% trans 'Everything is fine!' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<br/>
|
|
||||||
<br/>
|
|
||||||
<h4>Plugins</h4>
|
|
||||||
{% for p in plugins %}
|
|
||||||
{{ p.name }} - {{ p.version }} <br/>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
<h4 class="mt-3">Debug</h4>
|
<h4 class="mt-3">Debug</h4>
|
||||||
<textarea class="form-control" rows="20">
|
<textarea class="form-control" rows="20">
|
||||||
|
@ -7,7 +7,7 @@ from rest_framework.schemas import get_schema_view
|
|||||||
|
|
||||||
from cookbook.helper import dal
|
from cookbook.helper import dal
|
||||||
from recipes.settings import DEBUG, PLUGINS
|
from recipes.settings import DEBUG, PLUGINS
|
||||||
from recipes.version import VERSION_NUMBER
|
from version_info import TANDOOR_VERSION
|
||||||
|
|
||||||
from .models import (Automation, Comment, CustomFilter, Food, InviteLink, Keyword, MealPlan, Recipe,
|
from .models import (Automation, Comment, CustomFilter, Food, InviteLink, Keyword, MealPlan, Recipe,
|
||||||
RecipeBook, RecipeBookEntry, RecipeImport, ShoppingList, Step, Storage,
|
RecipeBook, RecipeBookEntry, RecipeImport, ShoppingList, Step, Storage,
|
||||||
@ -148,7 +148,7 @@ urlpatterns = [
|
|||||||
path('docs/search/', views.search_info, name='docs_search'),
|
path('docs/search/', views.search_info, name='docs_search'),
|
||||||
path('docs/api/', views.api_info, name='docs_api'),
|
path('docs/api/', views.api_info, name='docs_api'),
|
||||||
|
|
||||||
path('openapi/', get_schema_view(title="Django Recipes", version=VERSION_NUMBER, public=True,
|
path('openapi/', get_schema_view(title="Django Recipes", version=TANDOOR_VERSION, public=True,
|
||||||
permission_classes=(permissions.AllowAny,)), name='openapi-schema'),
|
permission_classes=(permissions.AllowAny,)), name='openapi-schema'),
|
||||||
|
|
||||||
path('api/', include((router.urls, 'api'))),
|
path('api/', include((router.urls, 'api'))),
|
||||||
|
@ -24,8 +24,9 @@ from cookbook.helper.permission_helper import group_required, has_group_permissi
|
|||||||
from cookbook.models import (Comment, CookLog, InviteLink, SearchFields, SearchPreference, ShareLink,
|
from cookbook.models import (Comment, CookLog, InviteLink, SearchFields, SearchPreference, ShareLink,
|
||||||
Space, ViewLog, UserSpace)
|
Space, ViewLog, UserSpace)
|
||||||
from cookbook.tables import (CookLogTable, ViewLogTable)
|
from cookbook.tables import (CookLogTable, ViewLogTable)
|
||||||
from recipes.settings import PLUGINS, BASE_DIR
|
from recipes.settings import PLUGINS
|
||||||
from recipes.version import BUILD_REF, VERSION_NUMBER
|
|
||||||
|
from version_info import VERSION_INFO
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
@ -319,34 +320,11 @@ def system(request):
|
|||||||
|
|
||||||
secret_key = False if os.getenv('SECRET_KEY') else True
|
secret_key = False if os.getenv('SECRET_KEY') else True
|
||||||
|
|
||||||
version_info = []
|
|
||||||
try:
|
|
||||||
r = subprocess.check_output(['git', 'show', '-s'], cwd=BASE_DIR)
|
|
||||||
version_info.append({
|
|
||||||
'name': 'Tandoor ' + VERSION_NUMBER,
|
|
||||||
'version': re.sub(r'<.*>', '', r.decode()),
|
|
||||||
'website': 'https://github.com/TandoorRecipes/recipes',
|
|
||||||
'commit_link': 'https://github.com/TandoorRecipes/recipes/commit/' + r.decode().split('\n')[0].split(' ')[1],
|
|
||||||
})
|
|
||||||
|
|
||||||
for p in PLUGINS:
|
|
||||||
r = subprocess.check_output(['git', 'show', '-s'], cwd=p['base_path'])
|
|
||||||
version_info.append({
|
|
||||||
'name': 'Plugin: ' + p['name'],
|
|
||||||
'version': re.sub(r'<.*>', '', r.decode()),
|
|
||||||
'website': p['website'],
|
|
||||||
'commit_link': p['website'] + '/commit/' + r.decode().split('\n')[0].split(' ')[1],
|
|
||||||
})
|
|
||||||
except:
|
|
||||||
if settings.DEBUG:
|
|
||||||
traceback.print_exc()
|
|
||||||
|
|
||||||
return render(request, 'system.html', {
|
return render(request, 'system.html', {
|
||||||
'gunicorn_media': settings.GUNICORN_MEDIA,
|
'gunicorn_media': settings.GUNICORN_MEDIA,
|
||||||
'debug': settings.DEBUG,
|
'debug': settings.DEBUG,
|
||||||
'postgres': postgres,
|
'postgres': postgres,
|
||||||
'version_info': version_info,
|
'version_info': VERSION_INFO,
|
||||||
'ref': BUILD_REF,
|
|
||||||
'plugins': PLUGINS,
|
'plugins': PLUGINS,
|
||||||
'secret_key': secret_key
|
'secret_key': secret_key
|
||||||
})
|
})
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
VERSION_NUMBER = ""
|
|
||||||
BUILD_REF = ""
|
|
63
version.py
Normal file
63
version.py
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import os
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
PLUGINS_DIRECTORY = os.path.join(BASE_DIR, 'recipes', 'plugins')
|
||||||
|
|
||||||
|
version_info = []
|
||||||
|
try:
|
||||||
|
r = subprocess.check_output(['git', 'show', '-s'], cwd=BASE_DIR).decode()
|
||||||
|
tandoor_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=BASE_DIR).decode()
|
||||||
|
tandoor_hash = r.split('\n')[0].split(' ')[1]
|
||||||
|
try:
|
||||||
|
tandoor_tag = subprocess.check_output(['git', 'describe', '--exact-match', tandoor_hash], cwd=os.path.join(BASE_DIR, 'recipes', 'plugins', d)).decode().replace('\n', '')
|
||||||
|
except:
|
||||||
|
tandoor_tag = ''
|
||||||
|
|
||||||
|
version_info.append({
|
||||||
|
'name': 'Tandoor ',
|
||||||
|
'version': re.sub(r'<.*>', '', r),
|
||||||
|
'website': 'https://github.com/TandoorRecipes/recipes',
|
||||||
|
'commit_link': 'https://github.com/TandoorRecipes/recipes/commit/' + r.split('\n')[0].split(' ')[1],
|
||||||
|
'ref': tandoor_hash,
|
||||||
|
'branch': tandoor_branch,
|
||||||
|
'tag': tandoor_tag
|
||||||
|
})
|
||||||
|
|
||||||
|
if os.path.isdir(PLUGINS_DIRECTORY):
|
||||||
|
for d in os.listdir(PLUGINS_DIRECTORY):
|
||||||
|
if d != '__pycache__':
|
||||||
|
try:
|
||||||
|
apps_path = f'recipes.plugins.{d}.apps'
|
||||||
|
__import__(apps_path)
|
||||||
|
app_config_classname = dir(sys.modules[apps_path])[1]
|
||||||
|
plugin_module = f'recipes.plugins.{d}.apps.{app_config_classname}'
|
||||||
|
plugin_class = getattr(sys.modules[apps_path], app_config_classname)
|
||||||
|
|
||||||
|
r = subprocess.check_output(['git', 'show', '-s'], cwd=os.path.join(BASE_DIR, 'recipes', 'plugins', d)).decode()
|
||||||
|
branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=os.path.join(BASE_DIR, 'recipes', 'plugins', d)).decode()
|
||||||
|
commit_hash = r.split('\n')[0].split(' ')[1]
|
||||||
|
try:
|
||||||
|
tag = subprocess.check_output(['git', 'describe', '--exact-match', commit_hash], cwd=os.path.join(BASE_DIR, 'recipes', 'plugins', d)).decode().replace('\n', '')
|
||||||
|
except:
|
||||||
|
tag = ''
|
||||||
|
|
||||||
|
version_info.append({
|
||||||
|
'name': 'Plugin: ' + plugin_class.verbose_name if hasattr(plugin_class, 'verbose_name') else plugin_class.name,
|
||||||
|
'version': re.sub(r'<.*>', '', r),
|
||||||
|
'website': plugin_class.website if hasattr(plugin_class, 'website') else '',
|
||||||
|
'commit_link': plugin_class.github if hasattr(plugin_class, 'github') else '' + '/commit/' + commit_hash,
|
||||||
|
'ref': commit_hash,
|
||||||
|
'branch': branch,
|
||||||
|
'tag': tag
|
||||||
|
})
|
||||||
|
except Exception:
|
||||||
|
traceback.print_exc()
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
with open('version_info.py', 'w+', encoding='UTF-8') as f:
|
||||||
|
f.write(f'TANDOOR_VERSION = "{tandoor_tag}"\nTANDOOR_REF = "{tandoor_hash}"\nVERSION_INFO = {version_info}')
|
3
version_info.py
Normal file
3
version_info.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
TANDOOR_VERSION = ""
|
||||||
|
TANDOOR_REF = ""
|
||||||
|
VERSION_INFO = []
|
Loading…
Reference in New Issue
Block a user