Skip to content

Commit

Permalink
properly add version to package
Browse files Browse the repository at this point in the history
  • Loading branch information
Her Email committed Nov 19, 2023
1 parent 82ca4dd commit 46aced5
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 15 deletions.
1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
workflows: ["unit test"]
branches:
- main
- activitypub
types:
- completed

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions boofilsic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.9.0"
12 changes: 10 additions & 2 deletions boofilsic/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@

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"))

Expand Down
3 changes: 0 additions & 3 deletions common/management/commands/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
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):
Expand Down
10 changes: 10 additions & 0 deletions common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,13 @@ def run(cls, job_id):
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()
2 changes: 2 additions & 0 deletions common/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
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
Expand Down Expand Up @@ -151,5 +152,6 @@ def run(self):
Indexer.init()

# Register cron jobs if not yet
JobManager.schedule_all()

logger.info("Finished post-migration setup.")
4 changes: 2 additions & 2 deletions misc/bin/neodb-hello
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 3 additions & 6 deletions misc/bin/neodb-init
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 0 deletions misc/bin/neodb-version
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 46aced5

Please sign in to comment.