Skip to content

Commit

Permalink
Use one chocolateyInstall.ps1 file for both nuspec files (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
samdanaei authored Oct 8, 2024
1 parent a635627 commit 29474e3
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 14 deletions.
33 changes: 25 additions & 8 deletions build/Build.Pack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,25 +379,42 @@ void BuildMsiInstallerForPlatform(MSBuildTargetPlatform platform, AbsolutePath w
{
(ArtifactsDirectory / "chocolatey").CreateDirectory();

var md5Checksum = (ArtifactsDirectory / "msi" / $"Octopus.Tentacle.{FullSemVer}.msi").GetFileHash();
Log.Information($"MD5 Checksum: Octopus.Tentacle.msi = {md5Checksum}");
var md5ChecksumNetFramework = (ArtifactsDirectory / "msi" / $"Octopus.Tentacle.{FullSemVer}.msi").GetFileHash();
Log.Information($"MD5 Checksum: Octopus.Tentacle.msi = {md5ChecksumNetFramework}");

var md5ChecksumX64 = (ArtifactsDirectory / "msi" / $"Octopus.Tentacle.{FullSemVer}-x64.msi").GetFileHash();
Log.Information($"Checksum: Octopus.Tentacle-x64.msi = {md5ChecksumX64}");
var md5ChecksumX64NetFramework = (ArtifactsDirectory / "msi" / $"Octopus.Tentacle.{FullSemVer}-x64.msi").GetFileHash();
Log.Information($"Checksum: Octopus.Tentacle-x64.msi = {md5ChecksumX64NetFramework}");

var md5ChecksumSelfContained = (ArtifactsDirectory / "msi" / $"Octopus.Tentacle.{FullSemVer}-net8.0-windows-win-x86.msi").GetFileHash();
Log.Information($"MD5 Checksum: Octopus.Tentacle.msi = {md5ChecksumSelfContained}");

var md5ChecksumX64SelfContained = (ArtifactsDirectory / "msi" / $"Octopus.Tentacle.{FullSemVer}-net8.0-windows-win-x64.msi").GetFileHash();
Log.Information($"Checksum: Octopus.Tentacle-x64.msi = {md5ChecksumX64SelfContained}");

var chocolateyInstallScriptPath = SourceDirectory / "Chocolatey" / "chocolateyInstall.ps1";
using var chocolateyInstallScriptFile = new ModifiableFileWithRestoreContentsOnDispose(chocolateyInstallScriptPath);

chocolateyInstallScriptFile.ReplaceRegexInFiles("0.0.0", FullSemVer);
chocolateyInstallScriptFile.ReplaceRegexInFiles("<checksum>", md5Checksum);
chocolateyInstallScriptFile.ReplaceRegexInFiles("<checksumtype>", "md5");
chocolateyInstallScriptFile.ReplaceRegexInFiles("<checksum64>", md5ChecksumX64);
chocolateyInstallScriptFile.ReplaceRegexInFiles("<checksumtype64>", "md5");

chocolateyInstallScriptFile.ReplaceRegexInFiles("<checksum-net-framework>", md5ChecksumNetFramework);
chocolateyInstallScriptFile.ReplaceRegexInFiles("<checksumtype-net-framework>", "md5");
chocolateyInstallScriptFile.ReplaceRegexInFiles("<checksum64-net-framework>", md5ChecksumX64NetFramework);
chocolateyInstallScriptFile.ReplaceRegexInFiles("<checksumtype64-net-framework>", "md5");

chocolateyInstallScriptFile.ReplaceRegexInFiles("<checksum-self-contained>", md5ChecksumSelfContained);
chocolateyInstallScriptFile.ReplaceRegexInFiles("<checksumtype-self-contained>", "md5");
chocolateyInstallScriptFile.ReplaceRegexInFiles("<checksum64-self-contained>", md5ChecksumX64SelfContained);
chocolateyInstallScriptFile.ReplaceRegexInFiles("<checksumtype64-self-contained>", "md5");

ChocolateyTasks.ChocolateyPack(settings => settings
.SetPathToNuspec(SourceDirectory / "Chocolatey" / "OctopusDeploy.Tentacle.nuspec")
.SetVersion(NuGetVersion)
.SetOutputDirectory(ArtifactsDirectory / "chocolatey"));

ChocolateyTasks.ChocolateyPack(settings => settings
.SetPathToNuspec(SourceDirectory / "Chocolatey" / "OctopusDeploy.Tentacle.SelfContained.nuspec")
.SetVersion(NuGetVersion)
.SetOutputDirectory(ArtifactsDirectory / "chocolatey"));
});

[PublicAPI]
Expand Down
19 changes: 19 additions & 0 deletions source/Chocolatey/OctopusDeploy.Tentacle.SelfContained.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" xmlns:octopus="http://octopus.org">
<metadata>
<id>OctopusDeploy.Tentacle.SelfContained</id>
<title>Octopus Deploy - Tentacle (Self-contained)</title>
<version>0.0.0</version>
<authors>Octopus Deploy</authors>
<summary>Deployment agent (self-contained) for Octopus Deploy, an automated deployment server.</summary>
<description>Octopus Deploy is a Continuous Delivery platform for complex deployments across your entire stack. Deploy with ease to Kubernetes, Linux, Windows virtual machines, Amazon Web Services, Azure, or Google Cloud. If the Octopus Tentacle agent, SSH, command line, or a web service can speak to it, Octopus can deploy to it.

This package installs the self-contained Tentacle deployment agent service. The .NET Framework is not a pre-requisite.</description>
<releaseNotes></releaseNotes>
<language>en-US</language>
<iconUrl>http://i.octopusdeploy.com/resources/Avatar3-32x32.png</iconUrl>
<projectUrl>http://octopusdeploy.com/</projectUrl>
<licenseUrl>http://octopusdeploy.com/pricing</licenseUrl>
<tags>octopus deploy</tags>
</metadata>
</package>
4 changes: 2 additions & 2 deletions source/Chocolatey/OctopusDeploy.Tentacle.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<version>0.0.0</version>
<authors>Octopus Deploy</authors>
<summary>Deployment agent for Octopus Deploy, an automated deployment server.</summary>
<description>Octopus Deploy is a user-friendly automated deployment tool for .NET developers.
<description>Octopus Deploy is a Continuous Delivery platform for complex deployments across your entire stack. Deploy with ease to Kubernetes, Linux, Windows virtual machines, Amazon Web Services, Azure, or Google Cloud. If the Octopus Tentacle agent, SSH, command line, or a web service can speak to it, Octopus can deploy to it.

This package installs the Tentacle deployment agent service.</description>
<releaseNotes></releaseNotes>
<language>en-US</language>
Expand Down
19 changes: 15 additions & 4 deletions source/Chocolatey/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@ Install-ChocolateyPackage `
-SilentArgs '/quiet' `
-Url 'https://download.octopusdeploy.com/octopus/Octopus.Tentacle.0.0.0.msi' `
-Url64bit 'https://download.octopusdeploy.com/octopus/Octopus.Tentacle.0.0.0-x64.msi' `
-Checksum '<checksum>' `
-ChecksumType '<checksumtype>' `
-Checksum64 '<checksum64>' `
-ChecksumType64 '<checksumtype64>'
-Checksum '<checksum-net-framework>' `
-ChecksumType '<checksumtype-net-framework>' `
-Checksum64 '<checksum64-net-framework>' `
-ChecksumType64 '<checksumtype64-net-framework>'
Install-ChocolateyPackage `
-PackageName 'OctopusDeploy.Tentacle.SelfContained' `
-FileType 'msi' `
-SilentArgs '/quiet' `
-Url 'https://download.octopusdeploy.com/octopus/Octopus.Tentacle.0.0.0-net8.0-windows-win-x86.msi' `
-Url64bit 'https://download.octopusdeploy.com/octopus/Octopus.Tentacle.0.0.0-net8.0-windows-win-x64.msi' `
-Checksum '<checksum-self-contained>' `
-ChecksumType '<checksumtype-self-contained>' `
-Checksum64 '<checksum64-self-contained>' `
-ChecksumType64 '<checksumtype64-self-contained>'

0 comments on commit 29474e3

Please sign in to comment.