mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add more version information (#5014)
* Add info for installer, branch, publisher * include version info * fix permissions * fix typo * add more info * use GH url * fix node * remove publisher * remove more logging * Add info to version view * enable branch discovery when not set * fix ref to github version * add branch to about dialog * use precise plattform information - if no env is set * fix ref names * load VERSION info * rename plattform to target * extend installer var * add generic plattform info * add docs for version info * add more info * add installer codes * Ammend navigation
This commit is contained in:
parent
f3a13fc625
commit
15ab911da6
@ -15,6 +15,8 @@ env:
|
||||
- INVENTREE_PLUGIN_FILE=/opt/inventree/plugins.txt
|
||||
- INVENTREE_CONFIG_FILE=/opt/inventree/config.yaml
|
||||
after_install: contrib/packager.io/postinstall.sh
|
||||
before:
|
||||
- contrib/packager.io/before.sh
|
||||
dependencies:
|
||||
- curl
|
||||
- python3
|
||||
|
@ -22,6 +22,7 @@ from django.http import Http404
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
import moneyed
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from InvenTree.config import get_boolean_setting, get_custom_file, get_setting
|
||||
from InvenTree.sentry import default_sentry_dsn, init_sentry
|
||||
@ -65,6 +66,12 @@ BASE_DIR = config.get_base_dir()
|
||||
# Load configuration data
|
||||
CONFIG = config.load_config_data(set_cache=True)
|
||||
|
||||
# Load VERSION data if it exists
|
||||
version_file = BASE_DIR.parent.joinpath('VERSION')
|
||||
if version_file.exists():
|
||||
print('load version from file')
|
||||
load_dotenv(version_file)
|
||||
|
||||
# Default action is to run the system in Debug mode
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = get_boolean_setting('INVENTREE_DEBUG', 'debug', True)
|
||||
|
@ -5,11 +5,13 @@ Provides information on the current InvenTree version
|
||||
|
||||
import os
|
||||
import pathlib
|
||||
import platform
|
||||
import re
|
||||
from datetime import datetime as dt
|
||||
from datetime import timedelta as td
|
||||
|
||||
import django
|
||||
from django.conf import settings
|
||||
|
||||
from dulwich.repo import NotGitRepository, Repo
|
||||
|
||||
@ -130,3 +132,48 @@ def inventreeCommitDate():
|
||||
|
||||
commit_dt = dt.fromtimestamp(main_commit.commit_time) + td(seconds=main_commit.commit_timezone)
|
||||
return str(commit_dt.date())
|
||||
|
||||
|
||||
def inventreeInstaller():
|
||||
"""Returns the installer for the running codebase - if set."""
|
||||
# First look in the environment variables, e.g. if running in docker
|
||||
|
||||
installer = os.environ.get('INVENTREE_PKG_INSTALLER', '')
|
||||
|
||||
if installer:
|
||||
return installer
|
||||
elif settings.DOCKER:
|
||||
return 'DOC'
|
||||
elif main_commit is not None:
|
||||
return 'GIT'
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def inventreeBranch():
|
||||
"""Returns the branch for the running codebase - if set."""
|
||||
# First look in the environment variables, e.g. if running in docker
|
||||
|
||||
branch = os.environ.get('INVENTREE_PKG_BRANCH', '')
|
||||
|
||||
if branch:
|
||||
return branch
|
||||
|
||||
if main_commit is None:
|
||||
return None
|
||||
|
||||
branch = main_repo.refs.follow(b'HEAD')[0][1].decode()
|
||||
return branch.removeprefix('refs/heads/')
|
||||
|
||||
|
||||
def inventreeTarget():
|
||||
"""Returns the target platform for the running codebase - if set."""
|
||||
# First look in the environment variables, e.g. if running in docker
|
||||
|
||||
return os.environ.get('INVENTREE_PKG_TARGET', None)
|
||||
|
||||
|
||||
def inventreePlatform():
|
||||
"""Returns the platform for the instance."""
|
||||
|
||||
return platform.platform(aliased=True)
|
||||
|
@ -287,6 +287,30 @@ def inventree_commit_date(*args, **kwargs):
|
||||
return version.inventreeCommitDate()
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
def inventree_installer(*args, **kwargs):
|
||||
"""Return InvenTree package installer string."""
|
||||
return version.inventreeInstaller()
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
def inventree_branch(*args, **kwargs):
|
||||
"""Return InvenTree git branch string."""
|
||||
return version.inventreeBranch()
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
def inventree_target(*args, **kwargs):
|
||||
"""Return InvenTree target string."""
|
||||
return version.inventreeTarget()
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
def inventree_platform(*args, **kwargs):
|
||||
"""Return InvenTree platform string."""
|
||||
return version.inventreePlatform()
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
def inventree_github_url(*args, **kwargs):
|
||||
"""Return URL for InvenTree github site."""
|
||||
|
@ -36,6 +36,13 @@
|
||||
<td>{% trans "Commit Date" %}</td><td>{% render_date commit_date %}{% include "clip.html" %}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% inventree_branch as branch %}
|
||||
{% if branch %}
|
||||
<tr>
|
||||
<td><span class='fas fa-code-branch'></span></td>
|
||||
<td>{% trans "Commit Branch" %}</td><td>{{ branch }}{% include "clip.html" %}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td><span class='fas fa-book'></span></td>
|
||||
|
@ -3,7 +3,11 @@ InvenTree-Version: {% inventree_version %}
|
||||
Django Version: {% django_version %}
|
||||
{% inventree_commit_hash as hash %}{% if hash %}Commit Hash: {{ hash }}{% endif %}
|
||||
{% inventree_commit_date as commit_date %}{% if commit_date %}Commit Date: {% render_date commit_date %}{% endif %}
|
||||
{% inventree_branch as branch %}{% if branch %}Commit Branch: {{ branch }}{% endif %}
|
||||
Database: {% inventree_db_engine %}
|
||||
Debug-Mode: {% inventree_in_debug_mode %}
|
||||
Deployed using Docker: {% inventree_docker_mode %}
|
||||
Platform: {% inventree_platform %}
|
||||
Installer: {% inventree_installer %}
|
||||
{% inventree_target as target %}{% if target %}Target: {{ target }}{% endif %}
|
||||
Active plugins: {% plugins_info %}
|
||||
|
43
contrib/packager.io/before.sh
Executable file
43
contrib/packager.io/before.sh
Executable file
@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# packager.io before script
|
||||
#
|
||||
|
||||
set -eu
|
||||
|
||||
VERSION="$APP_PKG_VERSION-$APP_PKG_ITERATION"
|
||||
echo "Setting VERSION information to $VERSION"
|
||||
echo "$VERSION" > VERSION
|
||||
|
||||
# The sha is the second element in APP_PKG_ITERATION
|
||||
SHA=$(echo $APP_PKG_ITERATION | cut -d'.' -f2)
|
||||
|
||||
# Download info
|
||||
echo "Getting info from github for commit $SHA"
|
||||
curl -L \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||
https://api.github.com/repos/InvenTree/InvenTree/commits/$SHA > commit.json
|
||||
curl -L \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||
https://api.github.com/repos/InvenTree/InvenTree/commits/$SHA/branches-where-head > branches.json
|
||||
|
||||
# Extract info
|
||||
echo "Extracting info from github"
|
||||
DATE=$(jq -r '.commit.committer.date' commit.json)
|
||||
BRANCH=$(jq -r '.[].name' branches.json)
|
||||
NODE_ID=$(jq -r '.node_id' commit.json)
|
||||
SIGNATURE=$(jq -r '.commit.verification.signature' commit.json)
|
||||
|
||||
echo "Write VERSION information"
|
||||
echo "INVENTREE_COMMIT_HASH='$SHA'" >> VERSION
|
||||
echo "INVENTREE_COMMIT_DATE='$DATE'" >> VERSION
|
||||
echo "INVENTREE_PKG_INSTALLER='PKG'" >> VERSION
|
||||
echo "INVENTREE_PKG_BRANCH='$BRANCH'" >> VERSION
|
||||
echo "INVENTREE_PKG_TARGET='$TARGET'" >> VERSION
|
||||
echo "NODE_ID='$NODE_ID'" >> VERSION
|
||||
echo "SIGNATURE='$SIGNATURE'" >> VERSION
|
||||
|
||||
echo "Written VERSION information"
|
||||
cat VERSION
|
39
docs/docs/start/advanced.md
Normal file
39
docs/docs/start/advanced.md
Normal file
@ -0,0 +1,39 @@
|
||||
---
|
||||
title: Advanced Topics
|
||||
---
|
||||
|
||||
## Version Information
|
||||
|
||||
Starting with version 0.12 (and later), InvenTree includes more version information.
|
||||
|
||||
To view this information, navigate to the "About" page in the top menu bar and select "copy version information" on the bottom corner.
|
||||
|
||||
### Contained Information
|
||||
|
||||
The version information contains the following information extracted form the instance:
|
||||
|
||||
| Name | Always | Sample | Source |
|
||||
| --- | --- | --- | --- |
|
||||
| InvenTree-Version | Yes | 0.12.0 dev | instance |
|
||||
| Django Version | Yes | 3.2.19 | instance |
|
||||
| Commit Hash | No | aebff26 | environment: `INVENTREE_COMMIT_HASH`, git |
|
||||
| Commit Date | No | 2023-06-10 | environment: `INVENTREE_COMMIT_DATE`, git |
|
||||
| Commit Branch | No | master | environment: `INVENTREE_PKG_BRANCH`, git |
|
||||
| Database | Yes | postgresql | environment: `INVENTREE_DB_*`, config: `database` - see [config](./config.md#database-options) |
|
||||
| Debug-Mode | Yes | False | environment: `INVENTREE_DEBUG`, config: `config` - see [config](./config.md#basic-options) |
|
||||
| Deployed using Docker | Yes | True | environment: `INVENTREE_DOCKER` |
|
||||
| Platform | Yes | Linux-5.15.0-67-generic-x86_64 | instance |
|
||||
| Installer | Yes | PKG | environment: `INVENTREE_PKG_INSTALLER`, instance |
|
||||
| Target | No | ubuntu:20.04 | environment: `INVENTREE_PKG_TARGET` |
|
||||
| Active plugins | Yes | [{'name': 'InvenTreeBarcode', 'slug': 'inventreebarcode', 'version': '2.0.0'}] | instance |
|
||||
|
||||
|
||||
### Installer codes
|
||||
|
||||
The installer code is used to identify the way InvenTree was installed. If you vendor InvenTree, you can and should set the installer code to your own value to make sure debugging goes smoothly.
|
||||
|
||||
| Code | Description | Official |
|
||||
| --- | --- | --- |
|
||||
| PKG | Installed using a package manager | Yes |
|
||||
| GIT | Installed using git | Yes |
|
||||
| DOC | Installed using docker | Yes |
|
@ -94,6 +94,7 @@ nav:
|
||||
- Serving Files: start/serving_files.md
|
||||
- Data Backup: start/backup.md
|
||||
- Migrating Data: start/migrate.md
|
||||
- Advanced Topics: start/advanced.md
|
||||
- Parts:
|
||||
- Parts: part/part.md
|
||||
- Creating Parts: part/create.md
|
||||
|
@ -36,6 +36,7 @@ pdf2image # PDF to image conversion
|
||||
pillow # Image manipulation
|
||||
pint==0.21 # Unit conversion # FIXED 2023-05-30 breaks tests https://github.com/matmair/InvenTree/actions/runs/5095665936/jobs/9160852560
|
||||
python-barcode[images] # Barcode generator
|
||||
python-dotenv # Environment variable management
|
||||
qrcode[pil] # QR code generator
|
||||
rapidfuzz==0.7.6 # Fuzzy string matching
|
||||
regex # Advanced regular expressions
|
||||
|
@ -213,6 +213,8 @@ python-dateutil==2.8.2
|
||||
# arrow
|
||||
# django-recurrence
|
||||
# icalendar
|
||||
python-dotenv==1.0.0
|
||||
# via -r requirements.in
|
||||
python-fsutil==0.10.0
|
||||
# via django-maintenance-mode
|
||||
python3-openid==3.2.0
|
||||
|
Loading…
Reference in New Issue
Block a user