Skip to content

Commit 047a628

Browse files
committed
Merge branch 'release/0.2.0'
* release/0.2.0: (#11) Add GitReleaaseManager template files (#11) Update GitReleaseManager configuration (#11) Update to latest GitReleaseManager (#10) Add support for build/sign of MSI (maint) Used consistent names/location for tasks (maint) Add more output information (#5) Removed hard coded file path (#9) Add support for Transifex (#8) Added ability to run GitReleaseManager (#7) Add GitHub Actions build provider (#6) Change name of CI Task (#2) Update to latest Cake.Recipe package
2 parents 45c10b5 + 9d9c0bd commit 047a628

32 files changed

+888
-437
lines changed

.appveyor.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ image: Visual Studio 2019
44
# Build Script #
55
#---------------------------------#
66
build_script:
7-
- ps: .\build.ps1 --target=AppVeyor
7+
- ps: .\build.ps1 --target=CI
88

99
# Tests
1010
test: off
@@ -24,4 +24,4 @@ branches:
2424
# Build Cache #
2525
#---------------------------------#
2626
cache:
27-
- tools -> build.ps1
27+
- tools -> recipe.cake

.config/dotnet-tools.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"cake.tool": {
6+
"version": "0.38.5",
7+
"commands": [
8+
"dotnet-cake"
9+
]
10+
}
11+
}
12+
}

.templates/default/create/footer.sbn

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{ if config.create.include_footer }}
2+
3+
### {{ config.create.footer_heading }}
4+
5+
{{ if config.create.milestone_replace_text
6+
replace_milestone_title config.create.footer_content config.create.milestone_replace_text milestone.target.title
7+
else
8+
config.create.footer_content
9+
end
10+
end }}

.templates/default/index.sbn

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{-
2+
include 'release-info'
3+
if milestone.target.description
4+
include 'milestone'
5+
end
6+
include 'issues' | string.rstrip
7+
if template_kind == "CREATE"
8+
include 'create/footer'
9+
end
10+
~}}

.templates/default/issue-details.sbn

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### {{ issue_label }}
2+
3+
{{ for issue in issues.items[issue_label]
4+
include 'issue-note'
5+
end }}

.templates/default/issue-note.sbn

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- {{ issue.title }} - see [#{{ issue.number }}]({{ issue.html_url }})

.templates/default/issues.sbn

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
{{ for issue_label in issue_labels
3+
include 'issue-details'
4+
end }}

.templates/default/milestone.sbn

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
{{ milestone.target.description }}

.templates/default/release-info.sbn

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{
2+
if issues.count > 0
3+
if commits.count > 0
4+
}}As part of this release we had [{{ commits.count }} {{ commits.count | string.pluralize "commit" "commits" }}]({{ commits.html_url }}) which resulted in [{{ issues.count }} {{ issues.count | string.pluralize "issue" "issues" }}]({{ milestone.target.html_url }}?closed=1) being closed.
5+
{{ else
6+
}}As part of this release we had [{{ issues.count }} {{ issues.count | string.pluralize "issue" "issues" }}]({{ milestone.target.html_url }}?closed=1) closed.
7+
{{ end
8+
else if commits.count > 0
9+
}}As part of this release we had [{{ commits.count }} {{ commits.count | string.pluralize "commit" "commits" }}]({{ commits.html_url }}).
10+
{{ end -}}

Chocolatey.Cake.Recipe/Content/addins.cake

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#addin nuget:?package=Cake.ReSharperReports&version=0.10.0
2222
#addin nuget:?package=Cake.StrongNameSigner&version=0.1.0
2323
#addin nuget:?package=Cake.StrongNameTool&version=0.0.5
24+
#addin nuget:?package=Cake.Transifex&version=1.0.1
2425
#addin nuget:?package=MagicChunks&version=2.0.0.119
2526

2627
// TODO: Conditionally decide whether to install packages or not

Chocolatey.Cake.Recipe/Content/build.cake

+48-3
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,32 @@ public void CopyBuildOutput()
383383
}
384384
}
385385

386+
BuildParameters.Tasks.BuildMsiTask = Task("Build-MSI")
387+
.IsDependentOn("Sign-Assemblies")
388+
.IsDependeeOf("Sign-Msis")
389+
.WithCriteria(() => BuildParameters.ShouldBuildMsi, "Skipping because building of MSI has been disabled")
390+
.Does(() => RequireTool(ToolSettings.MSBuildExtensionPackTool, () => {
391+
Information("Building MSI from the following solution: {0}", BuildParameters.SolutionFilePath);
392+
393+
var msbuildSettings = new MSBuildSettings()
394+
.SetPlatformTarget(PlatformTarget.x86)
395+
.UseToolVersion(ToolSettings.BuildMSBuildToolVersion)
396+
.WithProperty("TreatWarningsAsErrors", BuildParameters.TreatWarningsAsErrors.ToString())
397+
.WithTarget("Build")
398+
.SetMaxCpuCount(ToolSettings.MaxCpuCount)
399+
.SetConfiguration("WIX")
400+
.WithLogger(
401+
Context.Tools.Resolve("MSBuild.ExtensionPack.Loggers.dll").FullPath,
402+
"XmlFileLogger",
403+
string.Format(
404+
"logfile=\"{0}\";invalidCharReplacement=_;verbosity=Detailed;encoding=UTF-8",
405+
BuildParameters.Paths.Directories.Build + "/MSBuild.msi.log")
406+
);
407+
408+
MSBuild(BuildParameters.SolutionFilePath, msbuildSettings);
409+
})
410+
);
411+
386412
BuildParameters.Tasks.PackageTask = Task("Package");
387413
BuildParameters.Tasks.DefaultTask = Task("Default")
388414
.IsDependentOn("Package");
@@ -403,10 +429,11 @@ BuildParameters.Tasks.UploadArtifactsTask = Task("Upload-Artifacts")
403429
}
404430
});
405431

406-
BuildParameters.Tasks.ContinuousIntegrationTask = Task("ContinuousIntegration")
432+
BuildParameters.Tasks.ContinuousIntegrationTask = Task("CI")
407433
.IsDependentOn("Upload-Artifacts")
408434
.IsDependentOn("Publish-PreRelease-Packages")
409435
.IsDependentOn("Publish-Release-Packages")
436+
.IsDependentOn("Publish-GitHub-Release")
410437
.Finally(() =>
411438
{
412439
if (publishingError)
@@ -415,6 +442,12 @@ BuildParameters.Tasks.ContinuousIntegrationTask = Task("ContinuousIntegration")
415442
}
416443
});
417444

445+
BuildParameters.Tasks.ReleaseNotesTask = Task("ReleaseNotes")
446+
.IsDependentOn("Create-Release-Notes");
447+
448+
BuildParameters.Tasks.LabelsTask = Task("Labels")
449+
.IsDependentOn("Create-Default-Labels");
450+
418451
///////////////////////////////////////////////////////////////////////////////
419452
// EXECUTION
420453
///////////////////////////////////////////////////////////////////////////////
@@ -468,19 +501,26 @@ public class Builder
468501
BuildParameters.Tasks.CreateNuGetPackagesTask.IsDependentOn("Sign-PowerShellScripts");
469502
BuildParameters.Tasks.CreateNuGetPackagesTask.IsDependentOn("Sign-Assemblies");
470503
BuildParameters.Tasks.CreateChocolateyPackagesTask.IsDependentOn("Sign-PowerShellScripts");
504+
BuildParameters.Tasks.CreateChocolateyPackagesTask.IsDependentOn("Sign-Msis");
505+
BuildParameters.Tasks.SignMsisTask.IsDependentOn("Sign-Assemblies");
471506
BuildParameters.Tasks.CreateChocolateyPackagesTask.IsDependentOn(prefix + "Build");
472507
BuildParameters.Tasks.ObfuscateAssembliesTask.IsDependeeOf("Sign-Assemblies");
473508
BuildParameters.Tasks.StrongNameSignerTask.IsDependentOn(prefix + "Restore");
474509
BuildParameters.Tasks.StrongNameSignerTask.IsDependeeOf(prefix + "Build");
475-
BuildParameters.Tasks.ChangeStrongNameSignatures.IsDependentOn(prefix + "Restore");
476-
BuildParameters.Tasks.ChangeStrongNameSignatures.IsDependeeOf(prefix + "Build");
510+
BuildParameters.Tasks.ChangeStrongNameSignaturesTask.IsDependentOn(prefix + "Restore");
511+
BuildParameters.Tasks.ChangeStrongNameSignaturesTask.IsDependeeOf(prefix + "Build");
477512
BuildParameters.Tasks.ObfuscateAssembliesTask.IsDependentOn(prefix + "Build");
478513
BuildParameters.Tasks.InspectCodeTask.IsDependentOn(prefix + "Build");
479514
BuildParameters.Tasks.ConfigurationBuilderTask.IsDependentOn(prefix + "Build");
480515
BuildParameters.Tasks.TestTask.IsDependentOn(prefix + "Build");
481516

482517
if (!isDotNetCoreBuild)
483518
{
519+
if (BuildParameters.TransifexEnabled)
520+
{
521+
BuildParameters.Tasks.BuildTask.IsDependentOn("Transifex-Pull-Translations");
522+
}
523+
484524
BuildParameters.Tasks.TestNUnitTask.IsDependentOn(prefix + "Build");
485525
BuildParameters.Tasks.TestxUnitTask.IsDependentOn(prefix + "Build");
486526
BuildParameters.Tasks.TestTask.IsDependentOn("Test-NUnit");
@@ -493,6 +533,11 @@ public class Builder
493533
}
494534
else
495535
{
536+
if (BuildParameters.TransifexEnabled)
537+
{
538+
BuildParameters.Tasks.DotNetCoreBuildTask.IsDependentOn("Transifex-Pull-Translations");
539+
}
540+
496541
BuildParameters.Tasks.PackageTask.IsDependentOn(prefix + "Pack");
497542
BuildParameters.Tasks.GenerateLocalCoverageReportTask.IsDependentOn(prefix + "Test");
498543
BuildParameters.Tasks.TestTask.IsDependentOn("Generate-LocalCoverageReport");

Chocolatey.Cake.Recipe/Content/buildProvider.cake

+19
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,20 @@ public interface IBuildProvider
3232

3333
IBuildInfo Build { get; }
3434

35+
bool SupportsTokenlessCodecov { get; }
36+
37+
IEnumerable<string> PrintVariables { get; }
38+
3539
void UploadArtifact(FilePath file);
40+
41+
BuildProviderType Type { get; }
42+
}
43+
44+
public enum BuildProviderType
45+
{
46+
TeamCity,
47+
GitHubActions,
48+
Local
3649
}
3750

3851
public static IBuildProvider GetBuildProvider(ICakeContext context, BuildSystem buildSystem)
@@ -43,6 +56,12 @@ public static IBuildProvider GetBuildProvider(ICakeContext context, BuildSystem
4356
return new TeamCityBuildProvider(buildSystem.TeamCity, context);
4457
}
4558

59+
if (buildSystem.IsRunningOnGitHubActions)
60+
{
61+
context.Information("Using GitHub Action Provider...");
62+
return new GitHubActionBuildProvider(context);
63+
}
64+
4665
// always fallback to Local Build
4766
context.Information("Using Local Build Provider...");
4867
return new LocalBuildBuildProvider(context);

Chocolatey.Cake.Recipe/Content/credentials.cake

+49
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
public class GitHubCredentials
2+
{
3+
public string Token { get; private set; }
4+
5+
public GitHubCredentials(string token)
6+
{
7+
Token = token;
8+
}
9+
}
10+
11+
public class TransifexCredentials
12+
{
13+
public string ApiToken { get; private set; }
14+
15+
public bool HasCredentials
16+
{
17+
get { return !string.IsNullOrEmpty(ApiToken); }
18+
}
19+
20+
public TransifexCredentials(string apiToken)
21+
{
22+
ApiToken = apiToken;
23+
}
24+
}
25+
126
public class PackageSourceCredentials
227
{
328
public string ApiKey { get; private set; }
@@ -10,4 +35,28 @@ public class PackageSourceCredentials
1035
User = user;
1136
Password = password;
1237
}
38+
}
39+
40+
public static GitHubCredentials GetGitHubCredentials(ICakeContext context)
41+
{
42+
string token = null;
43+
// if "GitHubTokenVariable" is not set, fallback to the gh-cli defaults of GH_TOKEN, GITHUB_TOKEN
44+
var variableNames = new[]{ Environment.GitHubTokenVariable, "GH_TOKEN", "GITHUB_TOKEN" };
45+
foreach (var name in variableNames)
46+
{
47+
token = context.EnvironmentVariable(name);
48+
if (!string.IsNullOrEmpty(token))
49+
{
50+
break;
51+
}
52+
}
53+
54+
return new GitHubCredentials(token);
55+
}
56+
57+
public static TransifexCredentials GetTransifexCredentials(ICakeContext context)
58+
{
59+
return new TransifexCredentials(
60+
context.EnvironmentVariable(Environment.TransifexApiTokenVariable)
61+
);
1362
}

Chocolatey.Cake.Recipe/Content/eazfuscator.cake

+11-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ BuildParameters.Tasks.ObfuscateAssembliesTask = Task("Obfuscate-Assemblies")
1616
settings.KeyFile = BuildParameters.StrongNameKeyPath;
1717
}
1818

19-
settings.ToolPath = "./lib/Eazfuscator.NET/Eazfuscator.NET.exe";
19+
var eazfuscatorToolLocation = Context.Tools.Resolve("Eazfuscator.NET.exe");
20+
21+
if (eazfuscatorToolLocation == null)
22+
{
23+
Warning("Couldn't resolve EazFuscator.NET.Exe tool, so using value from ToolSettings: {0}", ToolSettings.EazfuscatorToolLocation);
24+
Context.Tools.RegisterFile(ToolSettings.EazfuscatorToolLocation);
25+
}
26+
else
27+
{
28+
Information("Using EazFuscator from: {0}", eazfuscatorToolLocation);
29+
}
2030

2131
if (FileExists(msbuildPathFilePath))
2232
{
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
public static class Environment
22
{
33
public static string DefaultPushSourceUrlVariable { get; private set; }
4+
public static string GitHubTokenVariable { get; private set; }
5+
public static string TransifexApiTokenVariable { get; private set; }
46

57
public static void SetVariableNames(
6-
string defaultPushSourceUrlVariable = null)
8+
string defaultPushSourceUrlVariable = null,
9+
string gitHubTokenVariable = null,
10+
string transifexApiTokenVariable = null)
711
{
812
DefaultPushSourceUrlVariable = defaultPushSourceUrlVariable ?? "NUGETDEV_SOURCE";
13+
GitHubTokenVariable = gitHubTokenVariable ?? "GITHUB_PAT";
14+
TransifexApiTokenVariable = transifexApiTokenVariable ?? "TRANSIFEX_API_TOKEN";
915
}
1016
}

0 commit comments

Comments
 (0)