mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-23 00:58:48 +00:00
[ci skip] ci: add trace logging for upm package.json generator
This commit is contained in:
parent
e2a608f11d
commit
2bfe0b24d0
@ -3,9 +3,15 @@ using System.Text.Json;
|
|||||||
|
|
||||||
string version;
|
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]))
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -14,14 +20,18 @@ else
|
|||||||
var attribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
var attribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
||||||
if (attribute is null || string.IsNullOrWhiteSpace(attribute.InformationalVersion))
|
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
|
else
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("AssemblyInformationalVersionAttribute found.");
|
||||||
version = attribute.InformationalVersion;
|
version = attribute.InformationalVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Building for version {version}.");
|
||||||
|
|
||||||
var package = new
|
var package = new
|
||||||
{
|
{
|
||||||
name = "me.olivr.x10d",
|
name = "me.olivr.x10d",
|
||||||
@ -35,5 +45,8 @@ var package = new
|
|||||||
licensesUrl = "https://github.com/oliverbooth/X10D/blob/main/LICENSE.md"
|
licensesUrl = "https://github.com/oliverbooth/X10D/blob/main/LICENSE.md"
|
||||||
};
|
};
|
||||||
|
|
||||||
using FileStream outputStream = File.Create("package.json");
|
using FileStream stream = File.Open("package.json", FileMode.Create, FileAccess.ReadWrite);
|
||||||
JsonSerializer.Serialize(outputStream, package, new JsonSerializerOptions {WriteIndented = true});
|
Console.WriteLine("Serializing package.json.");
|
||||||
|
JsonSerializer.Serialize(stream, package, new JsonSerializerOptions {WriteIndented = true});
|
||||||
|
stream.Position = 0;
|
||||||
|
stream.CopyTo(Console.OpenStandardOutput());
|
||||||
|
Loading…
Reference in New Issue
Block a user