better static version

This commit is contained in:
Andrew Dolgov 2023-04-10 18:05:13 +03:00
parent 566d164053
commit 6920c44587
No known key found for this signature in database
GPG Key ID: 1A56B4FA25D4AF2A
2 changed files with 14 additions and 3 deletions

View File

@ -8,6 +8,7 @@ ARG BUILD_TIMESTAMP
ARG CI_COMMIT_BRANCH ARG CI_COMMIT_BRANCH
ARG CI_COMMIT_SHORT_SHA ARG CI_COMMIT_SHORT_SHA
ARG CI_COMMIT_TIMESTAMP ARG CI_COMMIT_TIMESTAMP
ARG CI_COMMIT_SHA
RUN apk add --no-cache dcron php81 php81-fpm php81-phar php81-sockets \ RUN apk add --no-cache dcron php81 php81-fpm php81-phar php81-sockets \
php81-pdo php81-gd php81-pgsql php81-pdo_pgsql php81-xmlwriter \ php81-pdo php81-gd php81-pgsql php81-pdo_pgsql php81-xmlwriter \
@ -34,7 +35,9 @@ ADD config.docker.php ${SCRIPT_ROOT}
COPY --from=app-src . ${SRC_DIR} COPY --from=app-src . ${SRC_DIR}
RUN [ ! -z ${BUILD_TIMESTAMP} ] && echo ${BUILD_TIMESTAMP}-${CI_COMMIT_BRANCH}-${CI_COMMIT_SHORT_SHA} ${CI_COMMIT_TIMESTAMP} | tee ${SRC_DIR}/version-static-official.txt RUN [ ! -z ${BUILD_TIMESTAMP} ] \
&& echo ${BUILD_TIMESTAMP}-${CI_COMMIT_BRANCH}-${CI_COMMIT_SHORT_SHA} ${CI_COMMIT_TIMESTAMP} ${CI_COMMIT_SHA} | \
tee ${SRC_DIR}/version_static_official.txt
ARG ORIGIN_REPO_XACCEL=https://git.tt-rss.org/fox/ttrss-nginx-xaccel.git ARG ORIGIN_REPO_XACCEL=https://git.tt-rss.org/fox/ttrss-nginx-xaccel.git

View File

@ -311,7 +311,7 @@ class Config {
static function get_version_html() : string { static function get_version_html() : string {
$version = self::get_version(false); $version = self::get_version(false);
return sprintf("<span title=\"%s\">%s</span>", date("Y-m-d H:i:s", ($version['timestamp'] ?? 0)), $version['version']); return sprintf("<span title=\"%s\n%s\">%s</span>", date("Y-m-d H:i:s", ($version['timestamp'] ?? 0)), $version['commit'], $version['version']);
} }
/** /**
@ -323,7 +323,15 @@ class Config {
if (empty($this->version)) { if (empty($this->version)) {
$this->version["status"] = -1; $this->version["status"] = -1;
if (PHP_OS === "Darwin") { if (file_exists("$root_dir/version_static_official.txt")) {
list ($version, $timestamp, $commit) = explode(" ", file_get_contents("$root_dir/version_static_official.txt"));
$this->version["version"] = trim($version);
$this->version["timestamp"] = strtotime(trim($timestamp));
$this->version["commit"] = trim($commit);
$this->version["status"] = 0;
} else if (PHP_OS === "Darwin") {
$this->version["version"] = "UNKNOWN (Unsupported, Darwin)"; $this->version["version"] = "UNKNOWN (Unsupported, Darwin)";
} else if (file_exists("$root_dir/version_static.txt")) { } else if (file_exists("$root_dir/version_static.txt")) {
$this->version["version"] = trim(file_get_contents("$root_dir/version_static.txt")) . " (Unsupported)"; $this->version["version"] = trim(file_get_contents("$root_dir/version_static.txt")) . " (Unsupported)";