feat: Overhaul game version label content and trigger packaging of an Omega game zip in our new Jenkins (#4409)

This commit is contained in:
Rasmus Praestholm 2021-01-23 14:07:29 -06:00 committed by GitHub
parent 2427ce3360
commit 8aeca10df3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 64 deletions

11
Jenkinsfile vendored
View file

@ -34,6 +34,17 @@ node ("heavy-java") {
} else {
println "Running on a branch other than 'master' or 'develop' bypassing publishing"
}
// Trigger the Omega dist job to repackage a game zip with modules
if (env.JOB_NAME.equals("Terasology/engine/develop")) {
build job: 'Terasology/Omega/develop', wait: false
} else if (env.JOB_NAME.equals("Terasology/engine/master")) {
build job: 'Terasology/Omega/master', wait: false
} else if (env.JOB_NAME.equals("Nanoware/Terasology/develop")) {
build job: 'Nanoware/Omega/develop', wait: false
} else if (env.JOB_NAME.equals("Nanoware/Terasology/master")) {
build job: 'Nanoware/Omega/master', wait: false
}
}
stage('Analytics') {
sh "./gradlew --console=plain check spotbugsmain javadoc"

View file

@ -31,20 +31,10 @@ ext {
startDateTimeString = dateTimeFormat.format(new Date())
versionInfoFileDir = new File(buildDir, 'classes/org/terasology/version')
versionInfoFile = new File(versionInfoFileDir, 'versionInfo.properties')
versionFileName = 'VERSION'
versionBase = new File(templatesDir, "version.txt").text.trim()
displayVersion = versionBase
}
def convertGitBranch = { gitBranch ->
if (gitBranch != null) {
// Remove "origin/" from "origin/develop"
gitBranch.substring(gitBranch.lastIndexOf("/") + 1)
} else {
""
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Java Section //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -175,7 +165,7 @@ jar {
def manifestClasspath = "$subDirLibs/" + configurations."${sourceSets.main.runtimeClasspathConfigurationName}".collect {
it.getName()
}.join(" $subDirLibs/")
attributes("Class-Path": manifestClasspath, "Implementation-Title": "Terasology-" + project.name, "Implementation-Version": env.BUILD_NUMBER + ", " + convertGitBranch(env.GIT_BRANCH) + ", " + env.BUILD_ID + ", " + displayVersion)
attributes("Class-Path": manifestClasspath, "Implementation-Title": "Terasology", "Implementation-Version": displayVersion + ", engine v" + version + " , build number " + env.BUILD_NUMBER)
}
}
}
@ -230,10 +220,10 @@ group = 'org.terasology.engine'
println "Version for $project.name loaded as $version for group $group"
// This version info file actually goes inside the built jar and can be used at runtime
// This version info file actually goes inside the built jar and can be used at runtime - *if* building in Jenkins (JOB_NAME set)
task createVersionInfoFile {
inputs.property('dateTime', startDateTimeString)
onlyIf { env.BUILD_URL != null }
onlyIf { env.JOB_NAME != null }
doLast {
versionInfoFileDir.mkdirs()
ant.propertyfile(file: versionInfoFile) {
@ -242,8 +232,6 @@ task createVersionInfoFile {
ant.entry(key: 'buildTag', value: env.BUILD_TAG)
ant.entry(key: 'buildUrl', value: env.BUILD_URL)
ant.entry(key: 'jobName', value: env.JOB_NAME)
ant.entry(key: 'gitBranch', value: convertGitBranch(env.GIT_BRANCH))
ant.entry(key: 'gitCommit', value: env.GIT_COMMIT)
ant.entry(key: 'dateTime', value: startDateTimeString)
ant.entry(key: 'displayVersion', value: displayVersion)
ant.entry(key: 'engineVersion', value: version)
@ -251,8 +239,7 @@ task createVersionInfoFile {
}
}
//TODO: Remove it when gestalt will can to handle ProtectionDomain without classes (Resources)
//TODO: Remove this when gestalt can handle ProtectionDomain without classes (Resources)
task copyResourcesToClasses(type: Copy) {
from sourceSets.main.output.resourcesDir
into sourceSets.main.output.classesDirs.first()

View file

@ -1,18 +1,6 @@
/*
* Copyright 2013 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.version;
import org.slf4j.Logger;
@ -22,8 +10,6 @@
import java.io.InputStream;
import java.util.Properties;
/**
*/
public final class TerasologyVersion {
private static final Logger logger = LoggerFactory.getLogger(TerasologyVersion.class);
@ -36,8 +22,7 @@ public final class TerasologyVersion {
private static final String BUILD_ID = "buildId";
private static final String BUILD_TAG = "buildTag";
private static final String BUILD_URL = "buildUrl";
private static final String GIT_BRANCH = "gitBranch";
private static final String GIT_COMMIT = "gitCommit";
private static final String JOB_NAME = "jobName";
private static final String DATE_TIME = "dateTime";
private static final String DISPLAY_VERSION = "displayVersion";
private static final String ENGINE_VERSION = "engineVersion";
@ -48,8 +33,7 @@ public final class TerasologyVersion {
private final String buildId;
private final String buildTag;
private final String buildUrl;
private final String gitBranch;
private final String gitCommit;
private final String jobName;
private final String dateTime;
private final String toString;
private final String displayVersion;
@ -69,8 +53,7 @@ private TerasologyVersion() {
buildId = properties.getProperty(BUILD_ID, DEFAULT_VALUE);
buildTag = properties.getProperty(BUILD_TAG, DEFAULT_VALUE);
buildUrl = properties.getProperty(BUILD_URL, DEFAULT_VALUE);
gitBranch = properties.getProperty(GIT_BRANCH, DEFAULT_VALUE);
gitCommit = properties.getProperty(GIT_COMMIT, DEFAULT_VALUE);
jobName = properties.getProperty(JOB_NAME, DEFAULT_VALUE);
dateTime = properties.getProperty(DATE_TIME, DEFAULT_VALUE);
displayVersion = properties.getProperty(DISPLAY_VERSION, DEFAULT_VALUE);
engineVersion = properties.getProperty(ENGINE_VERSION, DEFAULT_VALUE);
@ -93,13 +76,9 @@ private TerasologyVersion() {
toStringBuilder.append("=");
toStringBuilder.append(buildUrl);
toStringBuilder.append(", ");
toStringBuilder.append(GIT_BRANCH);
toStringBuilder.append(JOB_NAME);
toStringBuilder.append("=");
toStringBuilder.append(gitBranch);
toStringBuilder.append(", ");
toStringBuilder.append(GIT_COMMIT);
toStringBuilder.append("=");
toStringBuilder.append(gitCommit);
toStringBuilder.append(jobName);
toStringBuilder.append(", ");
toStringBuilder.append(DATE_TIME);
toStringBuilder.append("=");
@ -139,12 +118,8 @@ public String getBuildUrl() {
return buildUrl;
}
public String getGitBranch() {
return gitBranch;
}
public String getGitCommit() {
return gitCommit;
public String getJobName() {
return jobName;
}
public String getDateTime() {
@ -164,23 +139,33 @@ public String getengineVersion() {
* @return prettified version String
*/
public String getHumanVersion() {
// TODO replace with a nicer version later with full version numbering in place
String humanVersion = "";
TerasologyVersion ver = getInstance();
// MOAR CAPS!
// Game-level release name: Alpha-## until we hit Beta - not engine-specific, but defined here for now
if (!ver.getDisplayVersion().trim().equals("")) {
humanVersion = displayVersion.toUpperCase();
}
// Expect tag to start with "jenkins-" and remove that
if (ver.getBuildTag().trim().length() > 8) {
humanVersion += " " + ver.getBuildTag().substring(8);
humanVersion = displayVersion.toUpperCase() + " ";
}
String formattedDate = "";
// Expect a date string but ignore time of day
if (ver.getDateTime().trim().length() > 10) {
humanVersion += " " + ver.getDateTime().substring(0, 10);
formattedDate += ver.getDateTime().substring(0, 10);
}
// Use the job name from Jenkins to determine which flavor we're dealing with (release, dev build, other)
if (jobName.equals("Terasology/engine/master")) {
// This is a release, hopefully stable, but who knows ..
humanVersion += "Release \n(engine v" + engineVersion + ", build " + buildNumber + ", " + formattedDate + ")";
} else if (jobName.equals("Terasology/engine/develop")) {
// This is a dev build, so a snapshot for the given release name
humanVersion += "Preview \n(engine v" + engineVersion + ", dev build " + buildNumber + ", " + formattedDate + ")";
} else if (!jobName.equals("")) {
// This is some other actual build that came from Jenkins
humanVersion += "Special: " + jobName + "\n(engine v" + engineVersion + ", build " + buildNumber + ", " + formattedDate + ")";
} else {
// Likely this didn't come from Jenkins at all
humanVersion += "Custom version - running from source or hand-built";
}
return humanVersion;

View file

@ -210,7 +210,6 @@ tasks.register<Copy>("createVersionFile") {
expand(mapOf(
"buildNumber" to env["BUILD_NUMBER"],
"buildUrl" to env["BUILD_URL"],
"gitBranch" to env["GIT_BRANCH"],
"dateTime" to startDateTimeString,
"displayVersion" to displayVersion
))

View file

@ -4,7 +4,6 @@ Terasology - Version
Jenkins:
URL: ${buildUrl}
Build number: ${buildNumber}
GIT branch: ${gitBranch}
Created at: ${dateTime}
http://terasology.org

View file

@ -1 +1 @@
alpha
alpha-18