From f752d97151c6c30526cad7e8a692d0ad252d38ad Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Thu, 29 Aug 2024 21:39:27 -0400 Subject: [PATCH] feat(discord): add version info (#348) --- Dockerfile | 23 +++++++++++++++++++++-- src/__main__.py | 2 +- src/common.py | 1 + src/discord/cogs/base_commands.py | 4 +++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8b977e1..8cf0ff5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,18 @@ -# syntax=docker/dockerfile:1.4 +# syntax=docker/dockerfile:1 # artifacts: false # platforms: linux/amd64 FROM python:3.12-slim-bookworm +# CI args +ARG BRANCH +ARG BUILD_VERSION +ARG COMMIT +# note: BUILD_VERSION may be blank + +ENV BRANCH=${BRANCH} +ENV BUILD_VERSION=${BUILD_VERSION} +ENV COMMIT=${COMMIT} + # Basic config ARG DAILY_TASKS=true ARG DAILY_RELEASES=true @@ -54,6 +64,15 @@ VOLUME /data WORKDIR /app/ COPY . . -RUN python -m pip install --no-cache-dir -r requirements.txt +RUN <<_SETUP +#!/bin/bash +set -e + +# replace the version in the code +sed -i "s/version = '0.0.0'/version = '${BUILD_VERSION}'/g" src/common.py + +# install dependencies +python -m pip install --no-cache-dir -r requirements.txt +_SETUP CMD ["python", "-m", "src"] diff --git a/src/__main__.py b/src/__main__.py index de3c55a..7968744 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -37,5 +37,5 @@ def main(): reddit_bot.stop() -if __name__ == '__main__': +if __name__ == '__main__': # pragma: no cover main() diff --git a/src/common.py b/src/common.py index 8770e99..ef33e84 100644 --- a/src/common.py +++ b/src/common.py @@ -53,3 +53,4 @@ def get_data_dir(): bot_name = f'{org_name}-Bot' bot_url = 'https://app.lizardbyte.dev' data_dir = get_data_dir() +version = '0.0.0' diff --git a/src/discord/cogs/base_commands.py b/src/discord/cogs/base_commands.py index 24b50bd..99734d8 100644 --- a/src/discord/cogs/base_commands.py +++ b/src/discord/cogs/base_commands.py @@ -3,7 +3,7 @@ from discord.commands import Option # local imports -from src.common import avatar, bot_name, org_name +from src.common import avatar, bot_name, org_name, version from src.discord.views import DonateCommandView from src.discord import cogs_common @@ -37,6 +37,8 @@ async def help_command( else: description += await self.get_command_help(ctx=ctx, cmd=cmd) + description += f"\n\nVersion: {version}\n" + embed = discord.Embed(description=description, color=0xE5A00D) embed.set_footer(text=bot_name, icon_url=avatar)