Align the full version schema across all artifacts

Summary:
The version number used for packaging symbols and xswiftbus was not the
full one including the timestamp.
This change adds the last commit timestamp (in contrast to the build
timestamp used before) as regular part of the version number. This helps
us to also keep the version number consistent with the content across all
installers. The version number will change only, if the last commit was
modified and not with each different build.
In the end, all jenkins jobs building from the same commit should produce
artifacts with the same version everywhere.

ref T204

Reviewers: #swift_pilot_client, kbasan

Reviewed By: #swift_pilot_client, kbasan

Subscribers: jenkins

Maniphest Tasks: T204

Differential Revision: https://dev.swift-project.org/D68
This commit is contained in:
Roland Winklmeier
2017-11-29 15:36:17 +01:00
parent d8c156a762
commit d7d4fdff2c
7 changed files with 62 additions and 43 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -22,8 +22,10 @@ else: GIT_BIN = $$system(which git 2> /dev/null)
isEmpty(GIT_BIN) {
GIT_HEAD_SHA1="<unknown>"
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)

View File

@@ -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 <-
}

View File

@@ -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();

View File

@@ -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; }

View File

@@ -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);
}