Skip to content

Commit

Permalink
Add packaging of licenses
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoch committed Jan 6, 2022
1 parent bb5a82f commit 6d05429
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"CheckoutExternalRepositories",
"Clean",
"Compile",
"DownloadLicenses",
"GenerateGlobalSolution",
"GeneratePublicApi",
"GenerateTools",
Expand Down Expand Up @@ -162,6 +163,7 @@
"CheckoutExternalRepositories",
"Clean",
"Compile",
"DownloadLicenses",
"GenerateGlobalSolution",
"GeneratePublicApi",
"GenerateTools",
Expand Down
4 changes: 2 additions & 2 deletions .teamcity/settings.kts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ object Pack : BuildType({
steps {
exec {
path = "build.cmd"
arguments = "Restore Compile Pack --skip"
arguments = "Restore DownloadLicenses Compile Pack --skip"
conditions { contains("teamcity.agent.jvm.os.name", "Windows") }
}
exec {
path = "build.sh"
arguments = "Restore Compile Pack --skip"
arguments = "Restore DownloadLicenses Compile Pack --skip"
conditions { doesNotContain("teamcity.agent.jvm.os.name", "Windows") }
}
}
Expand Down
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ stages:
path: $(HOME)/.nuget/packages
- task: CmdLine@2
inputs:
script: './build.cmd Restore Compile Pack --skip'
script: './build.cmd Restore DownloadLicenses Compile Pack --skip'
- task: PublishBuildArtifacts@1
inputs:
artifactName: packages
Expand Down Expand Up @@ -121,7 +121,7 @@ stages:
path: $(USERPROFILE)/.nuget/packages
- task: CmdLine@2
inputs:
script: './build.cmd Restore Compile Pack --skip'
script: './build.cmd Restore DownloadLicenses Compile Pack --skip'
- task: PublishBuildArtifacts@1
inputs:
artifactName: packages
Expand Down Expand Up @@ -175,7 +175,7 @@ stages:
path: $(HOME)/.nuget/packages
- task: CmdLine@2
inputs:
script: './build.cmd Restore Compile Pack --skip'
script: './build.cmd Restore DownloadLicenses Compile Pack --skip'
- task: PublishBuildArtifacts@1
inputs:
artifactName: packages
Expand Down
2 changes: 1 addition & 1 deletion build/Build.CI.AzurePipelines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
AzurePipelinesImage.MacOsLatest,
PullRequestsDisabled = true,
InvokedTargets = new[] { nameof(ITest.Test), nameof(IPack.Pack) },
NonEntryTargets = new[] { nameof(IRestore.Restore), nameof(ICompile.Compile), nameof(InstallFonts), nameof(ReleaseImage) },
NonEntryTargets = new[] { nameof(IRestore.Restore), nameof(DownloadLicenses), nameof(ICompile.Compile), nameof(InstallFonts), nameof(ReleaseImage) },
ExcludedTargets = new[] { nameof(Clean), nameof(ISignPackages.SignPackages) },
CacheKeyFiles = new[] { "global.json", "source/**/*.csproj" })]
partial class Build
Expand Down
1 change: 1 addition & 0 deletions build/Build.CI.TeamCity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
new[]
{
nameof(IRestore.Restore),
nameof(DownloadLicenses),
nameof(ICompile.Compile),
nameof(InstallFonts),
nameof(ReleaseImage)
Expand Down
49 changes: 49 additions & 0 deletions build/Build.Licenses.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2021 Maintainers of NUKE.
// Distributed under the MIT License.
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using Nuke.Common;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Nuke.Common.IO;
using Nuke.Components;
using Serilog;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.HttpTasks;

partial class Build
{
AbsolutePath LicensesDirectory => TemporaryDirectory / "licenses";

IEnumerable<(string Project, string Url)> Licenses
=> new[]
{
("Glob", "https://raw.githubusercontent.com/kthompson/glob/develop/LICENSE"),
("ICSharpCode.SharpZipLib", "https://raw.githubusercontent.com/icsharpcode/SharpZipLib/master/LICENSE.txt"),
("JetBrains.Annotations", "https://raw.githubusercontent.com/JetBrains/JetBrains.Annotations/main/license.md"),
("Microsoft.ApplicationInsights", "https://raw.githubusercontent.com/microsoft/ApplicationInsights-dotnet/main/LICENSE"),
("Microsoft.Build", "https://raw.githubusercontent.com/dotnet/msbuild/main/LICENSE"),
("Microsoft.CodeAnalysis", "https://raw.githubusercontent.com/dotnet/roslyn/main/License.txt"),
("Newtonsoft.Json", "https://raw.githubusercontent.com/JamesNK/Newtonsoft.Json/master/LICENSE.md"),
("NuGet", "https://raw.githubusercontent.com/NuGet/NuGet.Client/dev/LICENSE.txt"),
("Octokit", "https://raw.githubusercontent.com/octokit/octokit.net/main/LICENSE.txt"),
("Serilog", "https://raw.githubusercontent.com/serilog/serilog/dev/LICENSE"),
("YamlDotNet", "https://raw.githubusercontent.com/aaubry/YamlDotNet/master/LICENSE.txt")
};

Target DownloadLicenses => _ => _
.Before<ICompile>()
.DependentFor<IPack>()
.Executes(() =>
{
EnsureCleanDirectory(LicensesDirectory);
var downloadTasks = Licenses.Select(async x =>
{
await HttpDownloadFileAsync(x.Url, LicensesDirectory / $"{x.Project}.txt");
Log.Information("Downloaded license for {Project}", x.Project);
});
Task.WaitAll(downloadTasks.ToArray());
});
}
2 changes: 1 addition & 1 deletion source/Nuke.GlobalTool.Tests/Nuke.GlobalTool.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ProjectReference Include="..\Nuke.Common\Nuke.Common.csproj" />
<ProjectReference Include="..\Nuke.GlobalTool\Nuke.GlobalTool.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Remove="cake-scripts\*" />
<None Include="cake-scripts\*" />
Expand Down
4 changes: 4 additions & 0 deletions source/Nuke.GlobalTool/Nuke.GlobalTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@
<EmbeddedResource Include="templates\*" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\.nuke\temp\licenses\*.txt" PackagePath="licenses" Pack="true" Visible="false" />
</ItemGroup>

</Project>

0 comments on commit 6d05429

Please sign in to comment.