From e57264fd959eeed604842ad822a9c894361cd1c3 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 6 Jan 2024 19:32:33 +0000 Subject: [PATCH] [ci] more specific version in /system_info, less specific version in footer --- .github/workflows/release.yml | 7 +++++-- Dockerfile | 4 +++- core/sys_config.php | 4 ++-- ext/et/main.php | 13 ++++++++++++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0179b7cdf..2a9c36be2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,8 +17,11 @@ jobs: id: get_version run: echo VERSION=${GITHUB_REF/refs\/tags\/v/} >> $GITHUB_OUTPUT - - name: Test version in sys_config - run: grep ${{ steps.get_version.outputs.VERSION }} core/sys_config.php + - name: Check and set sys_config + run: | + grep ${{ steps.get_version.outputs.VERSION }} core/sys_config.php + echo "_d('BUILD_TIME', '$(date +'%Y-%m-%dT%H:%M:%S')');" >> core/sys_config.php + echo "_d('BUILD_HASH', '$GITHUB_SHA');" >> core/sys_config.php - name: Build run: | diff --git a/Dockerfile b/Dockerfile index e5fdaedb3..65875a73e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,8 +66,10 @@ FROM base AS run EXPOSE 8000 # HEALTHCHECK --interval=1m --timeout=3s CMD curl --fail http://127.0.0.1:8000/ || exit 1 ARG BUILD_TIME=unknown BUILD_HASH=unknown -ENV UID=1000 GID=1000 UPLOAD_MAX_FILESIZE=50M BUILD_TIME=${BUILD_TIME} BUILD_HASH=${BUILD_HASH} +ENV UID=1000 GID=1000 UPLOAD_MAX_FILESIZE=50M COPY --from=build /app /app WORKDIR /app +RUN echo "_d('BUILD_TIME', '$BUILD_TIME');" >> core/sys_config.php && \ + echo "_d('BUILD_HASH', '$BUILD_HASH');" >> core/sys_config.php ENTRYPOINT ["/app/.docker/entrypoint.sh"] CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] diff --git a/core/sys_config.php b/core/sys_config.php index e11ba9491..1fea1fde1 100644 --- a/core/sys_config.php +++ b/core/sys_config.php @@ -23,7 +23,7 @@ function _d(string $name, $value): void define($name, $value); } } -$_g = file_exists(".git") ? '+' : ''; + _d("DATABASE_DSN", null); // string PDO database connection details _d("DATABASE_TIMEOUT", 10000); // int Time to wait for each statement to complete _d("CACHE_DSN", null); // string cache connection details @@ -31,7 +31,7 @@ function _d(string $name, $value): void _d("COOKIE_PREFIX", 'shm'); // string if you run multiple galleries with non-shared logins, give them different prefixes _d("SPEED_HAX", false); // boolean do some questionable things in the name of performance _d("WH_SPLITS", 1); // int how many levels of subfolders to put in the warehouse -_d("VERSION", "2.10.0-beta$_g"); // string shimmie version +_d("VERSION", "2.10.0-beta2"); // string shimmie version _d("TIMEZONE", null); // string timezone _d("EXTRA_EXTS", ""); // string optional extra extensions _d("BASE_HREF", null); // string force a specific base URL (default is auto-detect) diff --git a/ext/et/main.php b/ext/et/main.php index 03f32ee08..95017b813 100644 --- a/ext/et/main.php +++ b/ext/et/main.php @@ -63,6 +63,17 @@ private function get_info(): array } } + $ver = VERSION; + if(defined("BUILD_TIME")) { + $ver .= "-" . substr(constant("BUILD_TIME"), 0, 10); + } + if(defined("BUILD_HASH")) { + $ver .= "-" . substr(constant("BUILD_HASH"), 0, 7); + } + if(file_exists(".git")) { + $ver .= "+"; + } + $info = [ "about" => [ 'title' => $config->get_string(SetupConfig::TITLE), @@ -70,7 +81,7 @@ private function get_info(): array 'url' => make_http(make_link("/")), ], "versions" => [ - 'shimmie' => VERSION, + 'shimmie' => $ver, 'schema' => $config->get_int("db_version"), 'php' => phpversion(), 'db' => $database->get_driver_id()->value . " " . $database->get_version(),