Skip to content

Commit

Permalink
Merge pull request #1050 from corbob/update-cake-recipe
Browse files Browse the repository at this point in the history
(build) (ENGTASKS-3694) Update Chocolatey.Cake.Recipe to latest
  • Loading branch information
gep13 authored Jun 12, 2024
2 parents 348926d + 58d5337 commit fb6e8a9
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 15 deletions.
82 changes: 70 additions & 12 deletions .teamcity/settings.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ project {
buildType(ChocolateyGUI)
buildType(ChocolateyGUISchd)
buildType(ChocolateyGUIQA)
buildType(ChocolateyGUISign)
}

object ChocolateyGUI : BuildType({
Expand Down Expand Up @@ -52,15 +53,10 @@ object ChocolateyGUI : BuildType({
}
}

step {
name = "Include Signing Keys"
type = "PrepareSigningEnvironment"
}

script {
name = "Call Cake"
scriptContent = """
build.official.bat --verbosity=diagnostic --target=CI --testExecutionType=unit --shouldRunOpenCover=false
build.bat --verbosity=diagnostic --target=CI --testExecutionType=unit --shouldRunOpenCover=false
""".trimIndent()
}
}
Expand Down Expand Up @@ -189,15 +185,10 @@ object ChocolateyGUIQA : BuildType({
}
}

step {
name = "Include Signing Keys"
type = "PrepareSigningEnvironment"
}

script {
name = "Call Cake"
scriptContent = """
build.official.bat --verbosity=diagnostic --target=CI --testExecutionType=none --shouldRunAnalyze=false --shouldRunIlMerge=false --shouldObfuscateOutputAssemblies=false --shouldRunChocolatey=false --shouldRunNuGet=false --shouldRunSonarQube=true --shouldRunDependencyCheck=true --shouldAuthenticodeSignMsis=false --shouldAuthenticodeSignOutputAssemblies=false --shouldAuthenticodeSignPowerShellScripts=false
build.bat --verbosity=diagnostic --target=CI --testExecutionType=none --shouldRunAnalyze=false --shouldRunIlMerge=false --shouldObfuscateOutputAssemblies=false --shouldRunChocolatey=false --shouldRunNuGet=false --shouldRunSonarQube=true --shouldRunDependencyCheck=true --shouldAuthenticodeSignMsis=false --shouldAuthenticodeSignOutputAssemblies=false --shouldAuthenticodeSignPowerShellScripts=false
""".trimIndent()
}
}
Expand All @@ -217,3 +208,70 @@ object ChocolateyGUIQA : BuildType({
}
}
})

object ChocolateyGUISign : BuildType({
id = AbsoluteId("ChocolateyGUISign")
name = "Chocolatey GUI (Script Signing)"

artifactRules = """
""".trimIndent()

params {
param("env.vcsroot.branch", "%vcsroot.branch%")
param("env.Git_Branch", "%teamcity.build.vcs.branch.ChocolateyGUI_ChocolateyGuiVcsRoot%")
param("env.FORCE_OFFICIAL_AUTHENTICODE_SIGNATURE", "true")
param("teamcity.git.fetchAllHeads", "true")
password("env.GITHUB_PAT", "%system.GitHubPAT%", display = ParameterDisplay.HIDDEN, readOnly = true)
}

vcs {
root(DslContext.settingsRoot)

branchFilter = """
+:*
""".trimIndent()
}

steps {
powerShell {
name = "Prerequisites"
scriptMode = script {
content = """
# Install Chocolatey Requirements
if ((Get-WindowsFeature -Name NET-Framework-Features).InstallState -ne 'Installed') {
Install-WindowsFeature -Name NET-Framework-Features
}
choco install windows-sdk-7.1 netfx-4.0.3-devpack dotnet-6.0-runtime --confirm --no-progress
exit ${'$'}LastExitCode
""".trimIndent()
}
}

step {
name = "Include Signing Keys"
type = "PrepareSigningEnvironment"
}

script {
name = "Call Cake"
scriptContent = """
build.official.bat --verbosity=diagnostic --target=Sign-PowerShellScripts --exclusive
""".trimIndent()
}
}

triggers {
vcs {
triggerRules = """
+:nuspec/**/*.ps1
""".trimIndent()
branchFilter = "+:develop"
}
}

requirements {
doesNotExist("docker.server.version")
doesNotContain("teamcity.agent.name", "Docker")
}
})
19 changes: 16 additions & 3 deletions recipe.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#load nuget:?package=Chocolatey.Cake.Recipe&version=0.27.0
#load nuget:?package=Chocolatey.Cake.Recipe&version=0.28.4

///////////////////////////////////////////////////////////////////////////////
// MODULES
Expand All @@ -22,10 +22,22 @@ else
Environment.SetVariableNames();
}

Func<FilePathCollection> getScriptsToVerify = () =>
{
var scriptsToVerify = GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/**/*.{ps1|psm1|psd1}");

Information("The following PowerShell scripts have been selected to be verified...");
foreach (var scriptToVerify in scriptsToVerify)
{
Information(scriptToVerify.FullPath);
}

return scriptsToVerify;
};

Func<FilePathCollection> getScriptsToSign = () =>
{
var scriptsToSign = GetFiles(BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/**/*.ps1") +
GetFiles(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/**/*.ps1");
var scriptsToSign = GetFiles("./nuspec/**/*.{ps1|psm1|psd1}");

Information("The following PowerShell scripts have been selected to be signed...");
foreach (var scriptToSign in scriptsToSign)
Expand Down Expand Up @@ -107,6 +119,7 @@ BuildParameters.SetParameters(context: Context,
productDescription: "Chocolatey GUI is a product of Chocolatey Software, Inc. - All Rights Reserved",
productCopyright: "Copyright 2014 - Present Open Source maintainers of Chocolatey GUI, and Chocolatey Software, Inc. - All Rights Reserved.",
useChocolateyGuiStrongNameKey: true,
getScriptsToVerify: getScriptsToVerify,
getScriptsToSign: getScriptsToSign,
getFilesToSign: getFilesToSign,
getMsisToSign: getMsisToSign,
Expand Down

0 comments on commit fb6e8a9

Please sign in to comment.