Skip to content

Commit

Permalink
Append Timestamp to version when building locally (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
scme0 authored Oct 16, 2023
1 parent bd4f54b commit d93bd3b
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ class Build : NukeBuild
[OctoVersion(Framework = "net6.0", BranchParameter = nameof(BranchName), AutoDetectBranchParameter = nameof(AutoDetectBranch))]
public OctoVersionInfo OctoVersionInfo;

static readonly string Timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");

string FullSemVer =>
!IsLocalBuild
? OctoVersionInfo.FullSemVer
: $"{OctoVersionInfo.FullSemVer}-{Timestamp}";

string NuGetVersion =>
!IsLocalBuild
? OctoVersionInfo.NuGetVersion
: $"{OctoVersionInfo.NuGetVersion}-{Timestamp}";

// Keep this list in order by most likely to succeed
string[] SigningTimestampUrls => new[]
{
Expand All @@ -77,8 +89,8 @@ class Build : NukeBuild
SourceDir.GlobDirectories("**/bin").ForEach(EnsureCleanDirectory);
SourceDir.GlobDirectories("**/obj").ForEach(EnsureCleanDirectory);
SourceDir.GlobDirectories("**/TestResults").ForEach(EnsureCleanDirectory);
DeleteFile(LocalPackagesDir / $"Octopus.Client.{OctoVersionInfo.FullSemVer}.nupkg");
DeleteFile(LocalPackagesDir / $"Octopus.Server.Client.{OctoVersionInfo.FullSemVer}.nupkg");
DeleteFile(LocalPackagesDir / $"Octopus.Client.{FullSemVer}.nupkg");
DeleteFile(LocalPackagesDir / $"Octopus.Server.Client.{FullSemVer}.nupkg");
});

Target Restore => _ => _
Expand All @@ -87,7 +99,7 @@ class Build : NukeBuild
{
DotNetRestore(_ => _
.SetProjectFile(SourceDir)
.SetVersion(OctoVersionInfo.FullSemVer));
.SetVersion(FullSemVer));
});

Target Compile => _ => _
Expand All @@ -97,7 +109,7 @@ class Build : NukeBuild
DotNetBuild(_ => _
.SetProjectFile(SourceDir)
.SetConfiguration(Configuration)
.SetVersion(OctoVersionInfo.FullSemVer));
.SetVersion(FullSemVer));
});

Target Merge => _ => _
Expand Down Expand Up @@ -186,7 +198,7 @@ class Build : NukeBuild
try
{
ReplaceTextInFiles(octopusClientNuspec, "<version>$version$</version>",
$"<version>{OctoVersionInfo.FullSemVer}</version>");
$"<version>{FullSemVer}</version>");

DotNetPack(_ => _
.SetProject(OctopusClientFolder)
Expand All @@ -195,7 +207,7 @@ class Build : NukeBuild
args.Add($"/p:NuspecFile=Octopus.Client.nuspec");
return args;
})
.SetVersion(OctoVersionInfo.FullSemVer)
.SetVersion(FullSemVer)
.SetConfiguration(Configuration)
.SetOutputDirectory(ArtifactsDir)
.EnableNoBuild()
Expand All @@ -204,7 +216,7 @@ class Build : NukeBuild
}
finally
{
ReplaceTextInFiles(octopusClientNuspec, $"<version>{OctoVersionInfo.FullSemVer}</version>", $"<version>$version$</version>");
ReplaceTextInFiles(octopusClientNuspec, $"<version>{FullSemVer}</version>", $"<version>$version$</version>");
}
});

Expand All @@ -216,7 +228,7 @@ class Build : NukeBuild

DotNetPack(_ => _
.SetProject(OctopusNormalClientFolder)
.SetVersion(OctoVersionInfo.FullSemVer)
.SetVersion(FullSemVer)
.SetConfiguration(Configuration)
.SetOutputDirectory(ArtifactsDir)
.EnableNoBuild()
Expand Down Expand Up @@ -261,8 +273,8 @@ class Build : NukeBuild
.Executes(() =>
{
EnsureExistingDirectory(LocalPackagesDir);
CopyFileToDirectory($"{ArtifactsDir}/Octopus.Client.{OctoVersionInfo.FullSemVer}.nupkg", LocalPackagesDir, FileExistsPolicy.Overwrite);
CopyFileToDirectory($"{ArtifactsDir}/Octopus.Server.Client.{OctoVersionInfo.FullSemVer}.nupkg", LocalPackagesDir, FileExistsPolicy.Overwrite);
CopyFileToDirectory($"{ArtifactsDir}/Octopus.Client.{FullSemVer}.nupkg", LocalPackagesDir, FileExistsPolicy.Overwrite);
CopyFileToDirectory($"{ArtifactsDir}/Octopus.Server.Client.{FullSemVer}.nupkg", LocalPackagesDir, FileExistsPolicy.Overwrite);
});

Target Default => _ => _
Expand Down

0 comments on commit d93bd3b

Please sign in to comment.