mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-23 23:55:13 +00:00
Add sourcelink support (#1574)
* add sourcelink support * Update sourcelink (2.0.2 -> 2.1.0) * Add parameter to enable source linking * tidy up the arguments with an extension method allowing an argument to be conditionally appended * Add an explicit "test sourcelink" build task and remove the MSBuild one, so we can get some build script output without needing the whole build to be in verbose logging * run sourcelink test against the NuGet packages
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
||||||
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
|
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
|
||||||
|
<DebugType>embedded</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -32,4 +33,10 @@
|
|||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="SourceLink.Create.GitHub" Version="2.1.0" PrivateAssets="All" />
|
||||||
|
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.1.0" />
|
||||||
|
<DotNetCliToolReference Include="dotnet-sourcelink" Version="2.1.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
||||||
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
|
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
|
||||||
|
<DebugType>embedded</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -32,4 +33,10 @@
|
|||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="SourceLink.Create.GitHub" Version="2.1.0" PrivateAssets="All" />
|
||||||
|
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.1.0" />
|
||||||
|
<DotNetCliToolReference Include="dotnet-sourcelink" Version="2.1.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ init:
|
|||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- dotnet --info
|
- dotnet --info
|
||||||
- ps: .\build.ps1
|
- ps: .\build.ps1 -LinkSources
|
||||||
|
|
||||||
test: off
|
test: off
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ Param(
|
|||||||
[string]$Target = "Default",
|
[string]$Target = "Default",
|
||||||
[ValidateSet("Release", "Debug")]
|
[ValidateSet("Release", "Debug")]
|
||||||
[string]$Configuration = "Release",
|
[string]$Configuration = "Release",
|
||||||
|
[switch]$LinkSources,
|
||||||
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
|
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
|
||||||
[string]$Verbosity = "Verbose",
|
[string]$Verbosity = "Verbose",
|
||||||
[switch]$WhatIf,
|
[switch]$WhatIf,
|
||||||
@@ -97,6 +98,7 @@ if (!(Test-Path $NugetPath)) {
|
|||||||
$Arguments = @{
|
$Arguments = @{
|
||||||
target=$Target;
|
target=$Target;
|
||||||
configuration=$Configuration;
|
configuration=$Configuration;
|
||||||
|
linkSources=$LinkSources;
|
||||||
verbosity=$Verbosity;
|
verbosity=$Verbosity;
|
||||||
dryrun=$WhatIf;
|
dryrun=$WhatIf;
|
||||||
}.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value };
|
}.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value };
|
||||||
|
|||||||
2
build.sh
2
build.sh
@@ -8,4 +8,4 @@ fi
|
|||||||
|
|
||||||
cd build
|
cd build
|
||||||
dotnet restore
|
dotnet restore
|
||||||
dotnet run
|
dotnet run -- --linkSources=true
|
||||||
@@ -6,6 +6,7 @@ public class Context : FrostingContext
|
|||||||
{
|
{
|
||||||
public string Target { get; set; }
|
public string Target { get; set; }
|
||||||
public string Configuration { get; set; }
|
public string Configuration { get; set; }
|
||||||
|
public bool LinkSources { get; set; }
|
||||||
public BuildVersion Version { get; set; }
|
public BuildVersion Version { get; set; }
|
||||||
|
|
||||||
public DirectoryPath Artifacts { get; set; }
|
public DirectoryPath Artifacts { get; set; }
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public class Lifetime : FrostingLifetime<Context>
|
|||||||
{
|
{
|
||||||
context.Target = context.Argument<string>("target", "Default");
|
context.Target = context.Argument<string>("target", "Default");
|
||||||
context.Configuration = context.Argument<string>("configuration", "Release");
|
context.Configuration = context.Argument<string>("configuration", "Release");
|
||||||
|
context.LinkSources = context.Argument("linkSources", false);
|
||||||
|
|
||||||
context.Artifacts = "./packaging/";
|
context.Artifacts = "./packaging/";
|
||||||
|
|
||||||
@@ -61,6 +62,7 @@ public class Lifetime : FrostingLifetime<Context>
|
|||||||
context.Information("Version: {0}", context.Version.Prefix);
|
context.Information("Version: {0}", context.Version.Prefix);
|
||||||
context.Information("Version suffix: {0}", context.Version.Suffix);
|
context.Information("Version suffix: {0}", context.Version.Suffix);
|
||||||
context.Information("Configuration: {0}", context.Configuration);
|
context.Information("Configuration: {0}", context.Configuration);
|
||||||
|
context.Information("LinkSources: {0}", context.LinkSources);
|
||||||
context.Information("Target: {0}", context.Target);
|
context.Information("Target: {0}", context.Target);
|
||||||
context.Information("AppVeyor: {0}", context.AppVeyor);
|
context.Information("AppVeyor: {0}", context.AppVeyor);
|
||||||
context.Information("TravisCI: {0}", context.TravisCI);
|
context.Information("TravisCI: {0}", context.TravisCI);
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ public class Build : FrostingTask<Context>
|
|||||||
context.DotNetCoreBuild("./Octokit.sln", new DotNetCoreBuildSettings
|
context.DotNetCoreBuild("./Octokit.sln", new DotNetCoreBuildSettings
|
||||||
{
|
{
|
||||||
Configuration = context.Configuration,
|
Configuration = context.Configuration,
|
||||||
ArgumentCustomization = args => args.Append("/p:Version={0}", context.Version.GetSemanticVersion())
|
ArgumentCustomization = args => args
|
||||||
|
.Append("/p:Version={0}", context.Version.GetSemanticVersion())
|
||||||
|
.AppendIfTrue(context.LinkSources, "/p:SourceLinkCreate=true")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Cake.Frosting;
|
using Cake.Frosting;
|
||||||
|
|
||||||
[Dependency(typeof(Package))]
|
[Dependency(typeof(TestSourceLink))]
|
||||||
public sealed class Default : FrostingTask<Context>
|
public sealed class Default : FrostingTask<Context>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
36
build/Tasks/TestSourceLink.cs
Normal file
36
build/Tasks/TestSourceLink.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using Cake.Common;
|
||||||
|
using Cake.Common.Diagnostics;
|
||||||
|
using Cake.Common.IO;
|
||||||
|
using Cake.Core;
|
||||||
|
using Cake.Core.IO;
|
||||||
|
using Cake.Frosting;
|
||||||
|
|
||||||
|
[Dependency(typeof(Package))]
|
||||||
|
public class TestSourceLink : FrostingTask<Context>
|
||||||
|
{
|
||||||
|
public override void Run(Context context)
|
||||||
|
{
|
||||||
|
var nugetPackages = context.GetFiles($"./{context.Artifacts}/*.nupkg");
|
||||||
|
|
||||||
|
foreach (var nugetPackage in nugetPackages)
|
||||||
|
{
|
||||||
|
context.Information("Testing sourcelink info in {0}", context.Environment.WorkingDirectory.GetRelativePath(nugetPackage));
|
||||||
|
var exitCode = context.StartProcess("dotnet", new ProcessSettings
|
||||||
|
{
|
||||||
|
WorkingDirectory = "Octokit",
|
||||||
|
Arguments = $"sourcelink test {nugetPackage.FullPath}"
|
||||||
|
});
|
||||||
|
|
||||||
|
if (exitCode != 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Sourcelink test failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool ShouldRun(Context context)
|
||||||
|
{
|
||||||
|
return context.LinkSources;
|
||||||
|
}
|
||||||
|
}
|
||||||
10
build/Utilities/CakeExtensions.cs
Normal file
10
build/Utilities/CakeExtensions.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using Cake.Core;
|
||||||
|
using Cake.Core.IO;
|
||||||
|
|
||||||
|
public static class CakeExtensions
|
||||||
|
{
|
||||||
|
public static ProcessArgumentBuilder AppendIfTrue(this ProcessArgumentBuilder builder, bool condition, string format, params object[] args)
|
||||||
|
{
|
||||||
|
return condition ? builder.Append(format, args) : builder;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user