Skip to content

Commit 5196b2c

Browse files
committed
Added the analyzer to the build project and allowed a no-unlist
1 parent 6a98f68 commit 5196b2c

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

tools/build/BuildDefinition.cs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,24 @@ public static SuccessfulAotTests AotTest(Options options, SuccessfulBuild _)
156156
return default;
157157
}
158158

159-
public static NuGetPackage Pack(Options options, GitVersion version, SuccessfulUnitTests _, SuccessfulAotTests __)
159+
public static List<NuGetPackage> Pack(Options options, GitVersion version, SuccessfulUnitTests _, SuccessfulAotTests __)
160160
{
161+
var result = new List<NuGetPackage>();
161162
var verbosity = options.Verbose ? "detailed" : "minimal";
162163
var buildDir = Path.Combine(BasePath, "YamlDotNet");
163164
Run("nuget", $"pack YamlDotNet.nuspec -Version {version.NuGetVersion} -OutputDirectory bin", buildDir);
164-
165165
var packagePath = Path.Combine(buildDir, "bin", $"YamlDotNet.{version.NuGetVersion}.nupkg");
166-
return new NuGetPackage(packagePath);
166+
result.Add(new NuGetPackage(packagePath, "YamlDotNet"));
167+
168+
buildDir = Path.Combine(BasePath, "YamlDotNet.Analyzers.StaticGenerator");
169+
Run("nuget", $"pack YamlDotNet.Analyzers.StaticGenerator.nuspec -Version {version.NuGetVersion} -OutputDirectory bin", buildDir);
170+
packagePath = Path.Combine(buildDir, "bin", $"YamlDotNet.Analyzers.StaticGenerator.{version.NuGetVersion}.nupkg");
171+
result.Add(new NuGetPackage(packagePath, "YamlDotNet.Analyzers.StaticGenerator"));
172+
173+
return result;
167174
}
168175

169-
public static void Publish(Options options, GitVersion version, NuGetPackage package)
176+
public static void Publish(Options options, GitVersion version, List<NuGetPackage> packages)
170177
{
171178
var apiKey = Environment.GetEnvironmentVariable("NUGET_API_KEY");
172179
if (string.IsNullOrEmpty(apiKey))
@@ -186,13 +193,16 @@ public static void Publish(Options options, GitVersion version, NuGetPackage pac
186193
}
187194
else
188195
{
189-
Console.WriteLine($"nuget push {package.Path} -ApiKey *** -Source https://api.nuget.org/v3/index.json");
190-
Run("nuget", $"push {package.Path} -ApiKey {apiKey} -Source https://api.nuget.org/v3/index.json", noEcho: true);
191-
192-
if (version.IsPreRelease)
196+
foreach (var package in packages)
193197
{
194-
Console.WriteLine($"nuget delete YamlDotNet {version.NuGetVersion} -NonInteractive -ApiKey *** -Source https://api.nuget.org/v3/index.json");
195-
Run("nuget", $"delete YamlDotNet {version.NuGetVersion} -NonInteractive -ApiKey {apiKey} -Source https://api.nuget.org/v3/index.json", noEcho: true);
198+
Console.WriteLine($"nuget push {package.Path} -ApiKey *** -Source https://api.nuget.org/v3/index.json");
199+
Run("nuget", $"push {package.Path} -ApiKey {apiKey} -Source https://api.nuget.org/v3/index.json", noEcho: true);
200+
201+
if (version.IsPreRelease && UnlistPackage)
202+
{
203+
Console.WriteLine($"nuget delete {package.Name} {version.NuGetVersion} -NonInteractive -ApiKey *** -Source https://api.nuget.org/v3/index.json");
204+
Run("nuget", $"delete {package.Name} {version.NuGetVersion} -NonInteractive -ApiKey {apiKey} -Source https://api.nuget.org/v3/index.json", noEcho: true);
205+
}
196206
}
197207
}
198208
}
@@ -564,12 +574,14 @@ public PreviousReleases(IEnumerable<Version> versions)
564574

565575
public class NuGetPackage
566576
{
567-
public NuGetPackage(string path)
577+
public NuGetPackage(string path, string name)
568578
{
569579
Path = path;
580+
Name = name;
570581
}
571582

572583
public string Path { get; }
584+
public string Name { get; }
573585
}
574586

575587
internal class LoggerHttpHandler : HttpClientHandler

tools/build/Program.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Program
2424
private static bool verbose;
2525
public static Host Host { get; private set; }
2626
private static readonly Dictionary<Type, object> state = new Dictionary<Type, object>();
27+
public static bool UnlistPackage { get; private set; } = true;
2728

2829
private static T GetState<T>() where T : notnull
2930
{
@@ -130,6 +131,12 @@ static async Task<int> Main(string[] args)
130131
return false;
131132
}
132133

134+
if (a == "--no-unlist")
135+
{
136+
UnlistPackage = false;
137+
return false;
138+
}
139+
133140
return true;
134141
})
135142
.ToList();
@@ -213,6 +220,7 @@ static async Task<int> Main(string[] args)
213220
Console.WriteLine($"{palette.Default}Additional options:");
214221
Console.WriteLine($" {palette.Option}--no-prerelease {palette.Default}Force the current version to be considered final{palette.Reset}");
215222
Console.WriteLine($" {palette.Option}--version=<version> {palette.Default}Force the current version to equal to the specified value{palette.Reset}");
223+
Console.WriteLine($" {palette.Option}--no-unlist {palette.Default}Don't unlist the pushed NuGet package{palette.Reset}");
216224
}
217225

218226
return exitCode;

0 commit comments

Comments
 (0)