From ec57dd310a6ad9657c08d143bd82a66da532dc78 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Wed, 20 Jul 2022 20:48:10 +0800 Subject: [PATCH] fbt: Respect SOURCE_DATE_EPOCH when setting build date (#1421) * fbt: using SOURCE_DATE_EPOCH from environment for build timestamp (if set) Co-authored-by: hedger --- scripts/version.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/version.py b/scripts/version.py index 87bf7ed8..896b58a4 100644 --- a/scripts/version.py +++ b/scripts/version.py @@ -5,7 +5,7 @@ from flipper.app import App import subprocess import os import json -from datetime import date +from datetime import date, datetime class GitVersion: @@ -77,9 +77,15 @@ class Main(App): def generate(self): current_info = GitVersion(self.args.sourcedir).get_version_info() + + if "SOURCE_DATE_EPOCH" in os.environ: + build_date = datetime.utcfromtimestamp(int(os.environ["SOURCE_DATE_EPOCH"])) + else: + build_date = date.today() + current_info.update( { - "BUILD_DATE": date.today().strftime("%d-%m-%Y"), + "BUILD_DATE": build_date.strftime("%d-%m-%Y"), "TARGET": self.args.target, } )