diff --git a/X10D.UpmPackageGenerator/Program.cs b/X10D.UpmPackageGenerator/Program.cs index 5fd345d..62b1747 100644 --- a/X10D.UpmPackageGenerator/Program.cs +++ b/X10D.UpmPackageGenerator/Program.cs @@ -3,9 +3,15 @@ using System.Text.Json; string version; +string? githubSha = Environment.GetEnvironmentVariable("GITHUB_SHA"); +Console.WriteLine(string.IsNullOrWhiteSpace(githubSha) + ? "GITHUB_SHA environment variable not found. This is not a CI run." + : $"Building from commit {githubSha}."); + if (args.Length == 0 || string.IsNullOrWhiteSpace(args[0])) { - version = Environment.GetEnvironmentVariable("GITHUB_SHA") ?? "0.0.0"; + Console.WriteLine("No input file specified. Attempting to use GITHUB_SHA."); + version = githubSha ?? "0.0.0"; } else { @@ -14,14 +20,18 @@ else var attribute = assembly.GetCustomAttribute(); if (attribute is null || string.IsNullOrWhiteSpace(attribute.InformationalVersion)) { - version = Environment.GetEnvironmentVariable("GITHUB_SHA") ?? "0.0.0"; + Console.WriteLine("AssemblyInformationalVersionAttribute not found. Attempting to use GITHUB_SHA."); + version = githubSha ?? "0.0.0"; } else { + Console.WriteLine("AssemblyInformationalVersionAttribute found."); version = attribute.InformationalVersion; } } +Console.WriteLine($"Building for version {version}."); + var package = new { name = "me.olivr.x10d", @@ -35,5 +45,8 @@ var package = new licensesUrl = "https://github.com/oliverbooth/X10D/blob/main/LICENSE.md" }; -using FileStream outputStream = File.Create("package.json"); -JsonSerializer.Serialize(outputStream, package, new JsonSerializerOptions {WriteIndented = true}); +using FileStream stream = File.Open("package.json", FileMode.Create, FileAccess.ReadWrite); +Console.WriteLine("Serializing package.json."); +JsonSerializer.Serialize(stream, package, new JsonSerializerOptions {WriteIndented = true}); +stream.Position = 0; +stream.CopyTo(Console.OpenStandardOutput());