Skip to content

Commit 188cd0c

Browse files
committed
improved versioning for build artifacts
1 parent b3c3cb3 commit 188cd0c

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

build/artifacts.cake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public class BuildPackages
2424

2525
private static Func<string, BuildPackage> BuildPackage(
2626
DirectoryPath nugetRooPath,
27-
string semVersion,
27+
string version,
2828
bool isChocolateyPackage = false)
2929
{
3030
return package => new BuildPackage(
3131
id: package,
3232
nuspecPath: string.Concat("./nuspec/", package, ".nuspec"),
33-
packagePath: nugetRooPath.CombineWithFilePath(string.Concat(package, ".", semVersion, ".nupkg")),
33+
packagePath: nugetRooPath.CombineWithFilePath(string.Concat(package, ".", version, ".nupkg")),
3434
isChocolateyPackage: isChocolateyPackage);
3535
}
3636
}

build/paths.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class BuildPaths
4242
var vsixVersion = version.DotNetVersion;
4343
var vsixOutputFilePath = buildArtifactDir.CombineWithFilePath("gittools.gitversion-" + vsixVersion + ".vsix");
4444

45-
var gemVersion = version.SemVersion.Replace("-", ".pre.");
45+
var gemVersion = version.SemVersion.Replace("-", ".");
4646
var gemOutputFilePath = buildArtifactDir.CombineWithFilePath("gitversion-" + gemVersion + ".gem");
4747

4848
// Directories

build/utils.cake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,7 @@ string[] GetDockerTags(GitVersion gitVersion, string platform, string variant, b
193193
$"{name}:{platform}-{gitVersion.LegacySemVerPadded}"
194194
};
195195

196-
if (!string.IsNullOrWhiteSpace(gitVersion.BuildMetaDataPadded)) {
197-
tags.Add($"{name}:{platform}-{gitVersion.LegacySemVerPadded}.{gitVersion.BuildMetaDataPadded}");
198-
}
196+
tags.Add($"{name}:{platform}-{gitVersion.LegacySemVerPadded}-{gitVersion.CommitsSinceVersionSource}");
199197

200198
if (variant == "dotnetcore" && isStableRelease) {
201199
tags.Add($"{name}:latest");

build/version.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class BuildVersion
1414
var semVersion = gitVersion.LegacySemVerPadded;
1515
var dotnetVersion = version;
1616

17-
semVersion += "." + gitVersion.CommitsSinceVersionSource;
17+
semVersion += "-" + gitVersion.CommitsSinceVersionSource;
1818
dotnetVersion += "." + gitVersion.CommitsSinceVersionSource;
1919

2020
return new BuildVersion

run.cake

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Setup(context =>
5959
msBuildSettings = new DotNetCoreMSBuildSettings()
6060
.WithProperty("Version", parameters.Version.SemVersion)
6161
.WithProperty("AssemblyVersion", parameters.Version.Version)
62-
.WithProperty("PackageVersion", parameters.Version.NuGetVersion)
62+
.WithProperty("PackageVersion", parameters.Version.SemVersion)
6363
.WithProperty("FileVersion", parameters.Version.Version);
6464

6565
if(!parameters.IsRunningOnWindows)
@@ -285,7 +285,7 @@ Task("Pack-Gem")
285285

286286
var gemspecFile = new FilePath(workDir + "/gitversion.gemspec");
287287
// update version number
288-
ReplaceTextInFile(gemspecFile, "$version$", parameters.Version.SemVersion);
288+
ReplaceTextInFile(gemspecFile, "$version$", parameters.Version.SemVersion.Replace("-", "."));
289289

290290
var toolPath = FindToolInPath(IsRunningOnWindows() ? "gem.cmd" : "gem");
291291
GemBuild(gemspecFile, new Cake.Gem.Build.GemBuildSettings()
@@ -306,7 +306,7 @@ Task("Pack-Nuget")
306306
if (FileExists(package.NuspecPath)) {
307307
var nugetSettings = new NuGetPackSettings
308308
{
309-
Version = parameters.Version.NuGetVersion,
309+
Version = parameters.Version.SemVersion,
310310
BasePath = parameters.PackagesBuildMap[package.Id],
311311
OutputDirectory = parameters.Paths.Directories.NugetRoot,
312312
};
@@ -342,7 +342,7 @@ Task("Pack-Chocolatey")
342342

343343
ChocolateyPack(package.NuspecPath, new ChocolateyPackSettings {
344344
Verbose = true,
345-
Version = parameters.Version.NuGetVersion,
345+
Version = parameters.Version.SemVersion,
346346
OutputDirectory = parameters.Paths.Directories.NugetRoot,
347347
Files = GetFiles(artifactPath + "/**/*.*")
348348
.Select(file => new ChocolateyNuSpecContent { Source = file.FullPath, Target = file.FullPath.Replace(artifactPath, "") })
@@ -392,6 +392,19 @@ Task("Pack")
392392
.IsDependentOn("Pack-Nuget")
393393
.IsDependentOn("Pack-Chocolatey")
394394
.IsDependentOn("Zip-Files")
395+
.Does(() =>
396+
{
397+
Information("The build artifacts: \n");
398+
foreach(var artifact in parameters.Artifacts.All)
399+
{
400+
if (FileExists(artifact.ArtifactPath)) { Information("Artifact: {0}", artifact.ArtifactPath); }
401+
}
402+
403+
foreach(var package in parameters.Packages.All)
404+
{
405+
if (FileExists(package.PackagePath)) { Information("Artifact: {0}", package.PackagePath); }
406+
}
407+
})
395408
.ReportError(exception =>
396409
{
397410
Error(exception.Dump());

0 commit comments

Comments
 (0)