Skip to content

Commit

Permalink
(#174) Don't always push latest tag to docker
Browse files Browse the repository at this point in the history
Update Docker build to only set latest tag when it is the latest build.
Previously we would set the latest tag on every tagged build which means
that pre-release and support builds would get tagged as latest. This
corrects that.
  • Loading branch information
corbob committed Feb 3, 2025
1 parent 5104cb1 commit 3d4cf50
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions Chocolatey.Cake.Recipe/Content/docker.cake
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ BuildParameters.Tasks.DockerPush = Task("DockerPush")
});

BuildParameters.Tasks.DockerTagAsLatest = Task("DockerTagAsLatest")
.WithCriteria(() => BuildParameters.IsTagged && BuildParameters.Version.MajorMinorPatch == BuildParameters.Version.FullSemVersion, "Skipping because this isn't a tagged full release build.")
.WithCriteria(() => BuildParameters.BranchType == BranchType.Master && BuildParameters.IsTagged && BuildParameters.Version.MajorMinorPatch == BuildParameters.Version.FullSemVersion, "Skipping because this isn't a tagged full release build.")
.WithCriteria(() => BuildParameters.DockerCredentials.HasCredentials, "Skipping because Docker Credentials were not provided.")
.WithCriteria(() => BuildParameters.ShouldRunDocker, "Skipping because running Docker tasks is not enabled")
.IsDependentOn("DockerLogin")
Expand Down Expand Up @@ -116,14 +116,16 @@ BuildParameters.Tasks.DockerManifest = Task("DockerManifest")

DockerManifestPush(manifestListName);

// Create the latest manifest
DockerManifestCreate(
string.Format("{0}/{1}:latest", BuildParameters.RepositoryOwner, BuildParameters.RepositoryName),
string.Format("{0}/{1}:latest-windows", BuildParameters.RepositoryOwner, BuildParameters.RepositoryName),
new string[] {
string.Format("{0}/{1}:latest-linux", BuildParameters.RepositoryOwner, BuildParameters.RepositoryName)
}
);

DockerManifestPush(string.Format("{0}/{1}:latest", BuildParameters.RepositoryOwner, BuildParameters.RepositoryName));
// Create the latest manifest only if this is the master branch.
if (BuildParameters.BranchType == BranchType.Master) {
DockerManifestCreate(
string.Format("{0}/{1}:latest", BuildParameters.RepositoryOwner, BuildParameters.RepositoryName),
string.Format("{0}/{1}:latest-windows", BuildParameters.RepositoryOwner, BuildParameters.RepositoryName),
new string[] {
string.Format("{0}/{1}:latest-linux", BuildParameters.RepositoryOwner, BuildParameters.RepositoryName)
}
);

DockerManifestPush(string.Format("{0}/{1}:latest", BuildParameters.RepositoryOwner, BuildParameters.RepositoryName));
}
});

0 comments on commit 3d4cf50

Please sign in to comment.