properly add version to package

This commit is contained in:
Her Email 2023-11-19 10:59:51 -05:00 committed by Henri Dickson
parent afb77cf3c1
commit 2c70c8ff2b
10 changed files with 31 additions and 15 deletions

View file

@ -5,7 +5,6 @@ on:
workflows: ["unit test"]
branches:
- main
- activitypub
types:
- completed

View file

@ -8,7 +8,7 @@ RUN --mount=type=cache,sharing=locked,target=/var/cache/apt apt-get update \
COPY . /neodb
RUN echo neodb-`cd /neodb && git rev-parse --short HEAD`-`cd /neodb/neodb-takahe && git rev-parse --short HEAD`-`date -u +%Y%m%d%H%M%S` > /neodb/version
RUN echo `cd /neodb && git rev-parse --short HEAD`-`cd /neodb/neodb-takahe && git rev-parse --short HEAD`-`date -u +%Y%m%d%H%M%S` > /neodb/build_version
RUN rm -rf /neodb/.git /neodb/neodb-takahe/.git
RUN mv /neodb/neodb-takahe /takahe

View file

@ -0,0 +1 @@
__version__ = "0.9.0"

View file

@ -2,13 +2,21 @@ import os
import environ
NEODB_VERSION = "0.8"
from boofilsic import __version__
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
try:
with open(os.path.join(BASE_DIR, "build_version")) as f:
NEODB_VERSION = __version__ + "-" + f.read().strip()
except:
NEODB_VERSION = __version__ + "-dev"
# Parse configuration from:
# - environment variables
# - .env file in project root directory
# - /etc/neodb.conf
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
environ.Env.read_env("/etc/neodb.conf")
environ.Env.read_env(os.path.join(BASE_DIR, ".env"))

View file

@ -4,10 +4,7 @@ from time import sleep
from django.core.management.base import BaseCommand
from loguru import logger
from catalog.jobs import * # noqa
from common.models import BaseJob, JobManager
from mastodon.jobs import * # noqa
from users.jobs import * # noqa
# @JobManager.register
# class DummyJob(BaseJob):

View file

@ -75,3 +75,13 @@ class JobManager:
def get_scheduled_job_ids(cls):
registry = ScheduledJobRegistry(queue=django_rq.get_queue("cron"))
return registry.get_job_ids()
@classmethod
def schedule_all(cls):
# TODO rewrite lazy import in a better way
from catalog.jobs import DiscoverGenerator, PodcastUpdater
from mastodon.jobs import MastodonSiteCheck
from users.jobs import MastodonUserSync
cls.cancel()
cls.schedule()

View file

@ -2,6 +2,7 @@ from django.conf import settings
from loguru import logger
from catalog.search.models import Indexer
from common.models import JobManager
from takahe.models import Config as TakaheConfig
from takahe.models import Domain as TakaheDomain
from takahe.models import Follow as TakaheFollow
@ -151,5 +152,6 @@ class Setup:
Indexer.init()
# Register cron jobs if not yet
JobManager.schedule_all()
logger.info("Finished post-migration setup.")

View file

@ -1,6 +1,6 @@
#!/bin/sh
echo '\033[0;35m====== Welcome to NeoDB ======\033[0m'
cat /neodb/version
echo '\033[0;35m====== NeoDB ======\033[0m'
echo Version: `neodb-version`
echo Your configuration is for ${NEODB_SITE_NAME} on ${NEODB_SITE_DOMAIN}
[[ -z "${NEODB_DEBUG}" ]] || echo DEBUG is ON, showing environment variables:
[[ -z "${NEODB_DEBUG}" ]] || env

View file

@ -1,14 +1,11 @@
#!/bin/sh
echo '\033[0;35m====== Welcome to NeoDB ======\033[0m'
cat /neodb/version
echo '\033[0;35m====== NeoDB ======\033[0m'
echo Version: `neodb-version`
echo Your configuration is for ${NEODB_SITE_NAME} on ${NEODB_SITE_DOMAIN}
[[ -z "${NEODB_DEBUG}" ]] || echo DEBUG is ON, show environment:
[[ -z "${NEODB_DEBUG}" ]] || env
echo
echo NeoDB initializing...
takahe-manage migrate || exit $?
neodb-manage migrate || exit $?
neodb-manage cron --schedule || exit $?
echo NeoDB initialization complete.

2
misc/bin/neodb-version Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
echo "from django.conf import settings; print(settings.NEODB_VERSION+(' debug:on' if settings.DEBUG else ''))" | neodb-manage shell