diff --git a/install.pri b/install.pri index ef8cd5bc4..626c1ecb7 100644 --- a/install.pri +++ b/install.pri @@ -219,7 +219,6 @@ bitrock_builder_bin = $$(BITROCK_BUILDER) INSTALLER_PLATFORM = osx INSTALLER_BASENAME = swift-installer-osx-$${WORD_SIZE}-$${BLACK_VERSION} INSTALLER_EXT = app - INSTALLER_CONTAINER_EXT = dmg } else:unix { INSTALLER_PLATFORM = linux-x$${WORD_SIZE} @@ -234,29 +233,6 @@ bitrock_builder_bin = $$(BITROCK_BUILDER) QMAKE_EXTRA_TARGETS += create_installer } -############### Publish Jenkins build artifact ############### - -!isEmpty(create_installer.commands) { - win32: { - # Fixme: the path to date.exe is currently hard coded - PUBLISHED_FILENAME = $${INSTALLER_BASENAME}.$$system(C:\UnxUtils\usr\local\wbin\date.exe -u +%Y%m%d%H%M%S).$${INSTALLER_EXT} - publish_installer.commands = move $${INSTALLER_BASENAME}.$${INSTALLER_EXT} ../$${PUBLISHED_FILENAME} - } - - unix: { - isEmpty(INSTALLER_CONTAINER_EXT) { - PUBLISHED_FILENAME = $${INSTALLER_BASENAME}.$$system(date -u '+%Y%m%d%H%M%S').$${INSTALLER_EXT} - publish_installer.commands = mv $${INSTALLER_BASENAME}.$${INSTALLER_EXT} ../$${PUBLISHED_FILENAME} - } else { - PUBLISHED_FILENAME = $${INSTALLER_BASENAME}.$$system(date -u '+%Y%m%d%H%M%S').$${INSTALLER_CONTAINER_EXT} - publish_installer.commands = mv $${INSTALLER_BASENAME}.$${INSTALLER_CONTAINER_EXT} ../$${PUBLISHED_FILENAME} - } - } - - publish_installer.depends = create_installer - QMAKE_EXTRA_TARGETS += publish_installer -} - ############### Bitrock Installbuilder Files ############### # List them in IDE diff --git a/scripts/jenkins.py b/scripts/jenkins.py index 3abb0137f..9f0c79787 100644 --- a/scripts/jenkins.py +++ b/scripts/jenkins.py @@ -82,13 +82,28 @@ class Builder: print('Running install ...') build_path = self._get_swift_build_path() os.chdir(build_path) - if self._should_run_publish(): - subprocess.check_call([self.make_cmd, 'publish_installer'], env=dict(os.environ)) + if self._should_publish(): + subprocess.check_call([self.make_cmd, 'create_installer'], env=dict(os.environ)) pass else: subprocess.check_call([self.make_cmd, 'install'], env=dict(os.environ)) pass + def publish(self): + if self._should_publish(): + os_map = {'Linux': 'linux', 'Darwin': 'osx', 'Windows': 'win'} + extension_map = {'Linux': 'run', 'Darwin': 'dmg', 'Windows': 'exe'} + version_segments = self.version.split('.') + lastSegment = version_segments.pop() + version_without_timestamp = '.'.join(version_segments) + installer_name_old = '-'.join(['swift', 'installer', os_map[platform.system()], self.word_size, version_without_timestamp]) + installer_name_new = '.'.join([installer_name_old, lastSegment]) + installer_name_old = installer_name_old + '.' + extension_map[platform.system()] + installer_name_new = installer_name_new + '.' + extension_map[platform.system()] + build_path = os.path.abspath(path.join(self._get_swift_build_path(), installer_name_old)) + dest_path = os.path.abspath(path.join(self._get_swift_build_path(), os.pardir, installer_name_new)) + os.rename(build_path, dest_path) + def package_xswiftbus(self): """ Packages xswiftbus as 7z compressed archive into the swift source root. @@ -142,7 +157,7 @@ class Builder: def _should_run_checks(self): return True - def _should_run_publish(self): + def _should_publish(self): return True def _should_create_symbols(self): @@ -216,9 +231,18 @@ class Builder: pass line = f.readline() f.close() - version = '.'.join([version_major, version_minor, version_micro]) + + # Converted from swift's CBuildConfig::lastCommitTimestampAsVersionSegment + last_commit_timestamp = int(self.__get_last_commit_timestamp()) + year_offset = 201000000000 + last_commit_timestamp = last_commit_timestamp - year_offset + version = '.'.join([version_major, version_minor, version_micro, str(last_commit_timestamp)]) return version + def __get_last_commit_timestamp(self): + out = subprocess.check_output(['git', 'log', '-1', '--date=format:"%Y%m%d%H%M"', '--pretty=format:%cd']) + return out.decode("utf-8").strip('"') + def __upload_symbol_files(self, symbol_path): print('Uploading symbols') url = 'http://crashreports.swift-project.org/symfiles' @@ -288,8 +312,8 @@ class MinGWBuilder(Builder): def _should_run_checks(self): return False - def _should_run_publish(self): - return False + def _should_publish(self): + return True def _should_create_symbols(self): return False @@ -424,6 +448,7 @@ def main(argv): builder.build(jobs, dev_build) builder.checks() builder.install() + builder.publish() builder.package_xswiftbus() builder.symbols(upload_symbols) diff --git a/src/blackconfig/blackconfig.pro b/src/blackconfig/blackconfig.pro index 67a9ab6e0..66a44d1eb 100644 --- a/src/blackconfig/blackconfig.pro +++ b/src/blackconfig/blackconfig.pro @@ -22,8 +22,10 @@ else: GIT_BIN = $$system(which git 2> /dev/null) isEmpty(GIT_BIN) { GIT_HEAD_SHA1="" + GIT_COMMIT_TS="0" } else { GIT_HEAD_SHA1=$$system(git rev-parse --short HEAD) + GIT_COMMIT_TS=$$system(git log -1 --date=format:'%Y%m%d%H%M' --pretty=format:%cd) } load(common_post) diff --git a/src/blackconfig/buildconfig.cpp b/src/blackconfig/buildconfig.cpp index a13180e5d..39a9c5edd 100644 --- a/src/blackconfig/buildconfig.cpp +++ b/src/blackconfig/buildconfig.cpp @@ -192,7 +192,7 @@ namespace BlackConfig const QVersionNumber &CBuildConfig::getVersion() { - static const QVersionNumber v { versionMajor(), versionMinor(), versionMicro(), buildTimestampAsVersionSegment(buildTimestamp()) }; + static const QVersionNumber v { versionMajor(), versionMinor(), versionMicro(), lastCommitTimestampAsVersionSegment(lastCommitTimestamp()) }; return v; } @@ -220,20 +220,20 @@ namespace BlackConfig return dt; } - int CBuildConfig::buildTimestampAsVersionSegment(const QDateTime &buildTimestamp) + int CBuildConfig::lastCommitTimestampAsVersionSegment(const QDateTime &lastCommitTimestamp) { - if (buildTimestamp.isValid()) + if (lastCommitTimestamp.isValid()) { - const QString bts = buildTimestamp.toString("yyyyMMddHHmm"); + const QString bts = lastCommitTimestamp.toString("yyyyMMddHHmm"); bool ok; - const long long btsll = bts.toLongLong(&ok); // at least 64bit + const long long lctsll = bts.toLongLong(&ok); // at least 64bit if (!ok) { return 0; } // now we have to converto int // max 2147483647 (2^31 - 1) // 1MMddHHmm (years since 2010) const long long yearOffset = 201000000000; - const int btsInt = btsll - yearOffset; - return btsInt; + const int lctsInt = lctsll - yearOffset; + return lctsInt; } return 0; // intentionally 0 => 0.7.3.0 <- } diff --git a/src/blackconfig/buildconfig.h b/src/blackconfig/buildconfig.h index cc3fafd92..15edd4783 100644 --- a/src/blackconfig/buildconfig.h +++ b/src/blackconfig/buildconfig.h @@ -119,6 +119,9 @@ namespace BlackConfig //! Returns SHA-1 of git HEAD at build time static const QString &gitHeadSha1(); + //! Timestamp of the last commit (NOT the authored timestamp) + static const QDateTime &lastCommitTimestamp(); // defined in buildconfig_gen.cpp.in + //! Build timestamp static const QDateTime &buildTimestamp(); @@ -131,8 +134,8 @@ namespace BlackConfig //! Version as QVersionNumber static const QString &getVersionString(); - //! Turns build timestamp into a version number - static int buildTimestampAsVersionSegment(const QDateTime &buildTimestamp); + //! Turns last commit timestamp into a version number + static int lastCommitTimestampAsVersionSegment(const QDateTime &lastCommitTimestamp); //! Build ABI parts as in http://doc.qt.io/qt-5/qsysinfo.html#buildAbi static const QStringList &getBuildAbiParts(); diff --git a/src/blackconfig/buildconfig_gen.cpp.in b/src/blackconfig/buildconfig_gen.cpp.in index 726c26f3e..22bcf27a1 100644 --- a/src/blackconfig/buildconfig_gen.cpp.in +++ b/src/blackconfig/buildconfig_gen.cpp.in @@ -161,6 +161,22 @@ const QString &BlackConfig::CBuildConfig::gitHeadSha1() return gitHeadSha1; } +namespace Private +{ + const QDateTime lastCommitTimestampImpl() + { + QDateTime dt = QDateTime::fromString(\"$$GIT_COMMIT_TS\", \"yyyyMMddHHmm\"); + dt.setTimeSpec(Qt::UTC); + return dt; + } +} + +const QDateTime &BlackConfig::CBuildConfig::lastCommitTimestamp() +{ + static const QDateTime dt = Private::lastCommitTimestampImpl(); + return dt; +} + int BlackConfig::CBuildConfig::versionMajor() { return $$BLACK_VER_MAJ; } int BlackConfig::CBuildConfig::versionMinor() { return $$BLACK_VER_MIN; } int BlackConfig::CBuildConfig::versionMicro() { return $$BLACK_VER_MIC; } diff --git a/src/blackmisc/db/distribution.cpp b/src/blackmisc/db/distribution.cpp index f89d3b944..379124c90 100644 --- a/src/blackmisc/db/distribution.cpp +++ b/src/blackmisc/db/distribution.cpp @@ -253,10 +253,7 @@ namespace BlackMisc return QVersionNumber::fromString(v); } - const QString versionTimestampString = BlackMisc::digitOnlyString(ts1Match.captured(0)); - const QDateTime versionTimestamp = QDateTime::fromString(versionTimestampString, "yyyyMMddHHmmss"); - const QString lastSegment = QString::number(CBuildConfig::buildTimestampAsVersionSegment(versionTimestamp)); - + const QString lastSegment = BlackMisc::digitOnlyString(ts1Match.captured(0)); v += lastSegment; return QVersionNumber::fromString(v); }