Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append Timestamp to version when building locally #779

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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