diff --git a/.bazelrc b/.bazelrc index 715d3fce..d6385ba7 100644 --- a/.bazelrc +++ b/.bazelrc @@ -10,9 +10,10 @@ common --tool_java_runtime_version=remotejdk_21 # compilation (and Turbine can't run Lombok), so disable header compilation. build --java_header_compilation=false -# Stamping: workspace status provides STABLE_VERSION as YYYY.MMDD.HHMM -# (per-minute UTC, each component <65535 for MSI). Invoked as `bash` so it -# works on Linux/macOS and on Windows via Git bash (C:\Program Files\Git\bin\bash.exe). +# Stamping: workspace status provides STABLE_VERSION as YY.MM.N +# (per-minute UTC, N = (DD-1)*1440+HH*60+MM, fits MSI 255.255.65535 and +# macOS CFBundleVersion 1-3 integers). Invoked as `bash` so it works on +# Linux/macOS and on Windows via Git bash (C:\Program Files\Git\bin\bash.exe). # Use --config=stamp or --stamp together with this command. The stamp config # bundles both. build:stamp --stamp diff --git a/java/com/cowlark/fluxengine/core/Version.java b/java/com/cowlark/fluxengine/core/Version.java index 1bdee2e0..aa4da2f9 100644 --- a/java/com/cowlark/fluxengine/core/Version.java +++ b/java/com/cowlark/fluxengine/core/Version.java @@ -6,10 +6,12 @@ /* Provides the application version, supplied at build time via Bazel stamping. * * Bazel generates version.properties via scripts/version.bzl from - * STABLE_VERSION (scripts/workspace_status.sh as YYYY.MMDD.HHMM per-minute UTC, - * each component <65535 so valid for Windows MSI ProductVersion). The value is - * also available as -Dfluxengine.version if set; otherwise the properties file - * is read. When built without --stamp, falls back to 1.0.0-dev. + * STABLE_VERSION (scripts/workspace_status.sh as YY.MM.N per-minute UTC + * where N = (DD-1)*1440 + HH*60 + MM, fits MSI 255.255.65535 and macOS + * CFBundleVersion 1-3 integers). This is the same version passed to jpackage + * as --app-version, so Version.get() reports the installer version. The value + * is also available as -Dfluxengine.version if set; otherwise the properties + * file is read. When built without --stamp, falls back to 1.0.0-dev. */ public final class Version { diff --git a/scripts/jpackage.bzl b/scripts/jpackage.bzl index ccea9621..2fccb11c 100644 --- a/scripts/jpackage.bzl +++ b/scripts/jpackage.bzl @@ -84,7 +84,8 @@ def _jpackage_impl(ctx): # supplied via --resource-dir to avoid post-processing. # # Stamping: when stamp=True and --stamp is set, read STABLE_VERSION from - # the stable-status file (produced by scripts/workspace_status.sh via + # the stable-status file (produced by scripts/workspace_status.sh as + # YY.MM.N per-minute UTC, N = (DD-1)*1440+HH*60+MM, via # `bash scripts/workspace_status.sh`, which works on Linux/macOS and on # Windows via Git bash). Fall back to app_version (1.0.0) otherwise. stamp_inputs = [ctx.info_file] if ctx.attr.stamp else [] diff --git a/scripts/version.bzl b/scripts/version.bzl index a8d5e365..aa9878f4 100644 --- a/scripts/version.bzl +++ b/scripts/version.bzl @@ -1,4 +1,9 @@ -"""Generates version.properties containing fluxengine.version from Bazel stamp.""" +"""Generates version.properties containing fluxengine.version from Bazel stamp. + +STABLE_VERSION is produced by scripts/workspace_status.sh as YY.MM.N per-minute +UTC (N = (DD-1)*1440+HH*60+MM) and is used as jpackage --app-version, so +fluxengine.version matches the installer version. +""" def _version_properties_impl(ctx): out = ctx.actions.declare_file("version.properties") diff --git a/scripts/workspace_status.sh b/scripts/workspace_status.sh index 195d8ab1..f6587d2d 100755 --- a/scripts/workspace_status.sh +++ b/scripts/workspace_status.sh @@ -4,8 +4,18 @@ # Uses bash from Git on Windows (C:\Program Files\Git\bin\bash.exe) as well as # Linux/macOS. Produces STABLE_VERSION for jpackage and -Dfluxengine.version. # -# Format YYYY.MMDD.HHMM (per-minute, UTC) e.g. 2026.0919.1430 -# Each dotted component <65535 so valid for Windows MSI ProductVersion, -# Debian upstream_version and RPM Version. -echo "STABLE_VERSION $(date -u +%Y.%m%d.%H%M)" +# Format YY.MM.N (per-minute UTC) where N is minutes since start of month: +# N = (DD - 1) * 1440 + HH * 60 + MM, 0 <= N <= 44639 +# e.g. 26.09.19 14:30 UTC -> N = 18*1440 + 14*60 + 30 = 26790 -> 26.9.26790 +# Three components satisfy macOS CFBundleVersion (1-3 integers, 18 chars, +# jpackage on JDK 21 rejects >3), MSI ProductVersion 255.255.65535 (first +# <256, second <256, third <65535), Debian upstream_version and RPM Version, +# while preserving per-minute monotonicity. +YY=$(date -u +%y) +MM=$(date -u +%m) +DD=$(date -u +%d) +HH=$(date -u +%H) +MIN=$(date -u +%M) +N=$(( (10#$DD - 1) * 1440 + 10#$HH * 60 + 10#$MIN )) +echo "STABLE_VERSION $((10#$YY)).$((10#$MM)).$N" echo "BUILD_TIMESTAMP $(date -u +%Y-%m-%dT%H:%M:%SZ)"