diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index ce587d05d..28cfe86ec 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -48,6 +48,11 @@ jobs: ref: upm path: upm + - name: Build package.json + run: | + dotnet run --project ./X10D.UpmPackageGenerator/X10D.UpmPackageGenerator.csproj "./X10D/bin/Debug/netstandard2.1/X10D.dll" + cp package.json upm/package.json + - name: Commit update run: | cd upm @@ -61,5 +66,6 @@ jobs: git add X10D.Unity.dll git add X10D.xml git add X10D.Unity.xml + git add package.json git commit -m "Update upm branch ($GITHUB_SHA)" git push diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 8edc4462f..9642fcddf 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -54,6 +54,11 @@ jobs: ref: upm path: upm + - name: Build package.json + run: | + dotnet run --project ./X10D.UpmPackageGenerator/X10D.UpmPackageGenerator.csproj "./X10D/bin/Release/netstandard2.1/X10D.dll" + cp package.json upm/package.json + - name: Commit update run: | cd upm @@ -67,5 +72,6 @@ jobs: git add X10D.Unity.dll git add X10D.xml git add X10D.Unity.xml + git add package.json git commit -m "Update upm branch ($GITHUB_SHA)" git push diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f91543ea8..1064f6f7e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,6 +54,11 @@ jobs: ref: upm path: upm + - name: Build package.json + run: | + dotnet run --project ./X10D.UpmPackageGenerator/X10D.UpmPackageGenerator.csproj "./X10D/bin/Release/netstandard2.1/X10D.dll" + cp package.json upm/package.json + - name: Commit update run: | cd upm @@ -67,5 +72,6 @@ jobs: git add X10D.Unity.dll git add X10D.xml git add X10D.Unity.xml + git add package.json git commit -m "Update upm branch ($GITHUB_SHA)" git push diff --git a/X10D.UpmPackageGenerator/Program.cs b/X10D.UpmPackageGenerator/Program.cs new file mode 100644 index 000000000..b57e095a7 --- /dev/null +++ b/X10D.UpmPackageGenerator/Program.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Text.Json; + +string version; + +if (args.Length == 0 || string.IsNullOrWhiteSpace(args[0])) +{ + version = Environment.GetEnvironmentVariable("GITHUB_SHA") ?? "0.0.0"; +} + +string path = args[0]; +var assembly = Assembly.LoadFrom(path); +var attribute = assembly.GetCustomAttribute(); +if (attribute is null || string.IsNullOrWhiteSpace(attribute.InformationalVersion)) +{ + version = Environment.GetEnvironmentVariable("GITHUB_SHA") ?? "0.0.0"; +} +else +{ + version = attribute.InformationalVersion; +} + +var package = new +{ + name = "me.olivr.x10d", + author = new {name = "Oliver Booth", email = "me@olivr.me", url = "https://oliverbooth.dev"}, + displayName = "X10D", + version, + unity = "2021.3", + description = "Extension methods on crack", + keywords = new[] {"dotnet", "extension-methods"}, + changelogUrl = "https://github.com/oliverbooth/X10D/blob/main/CHANGELOG.md", + licensesUrl = "https://github.com/oliverbooth/X10D/blob/main/LICENSE.md" +}; + +Console.WriteLine(JsonSerializer.Serialize(package, new JsonSerializerOptions {WriteIndented = true})); diff --git a/X10D.UpmPackageGenerator/X10D.UpmPackageGenerator.csproj b/X10D.UpmPackageGenerator/X10D.UpmPackageGenerator.csproj new file mode 100644 index 000000000..2b14c8172 --- /dev/null +++ b/X10D.UpmPackageGenerator/X10D.UpmPackageGenerator.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/X10D.sln b/X10D.sln index 7498472c7..25a2e3e0a 100644 --- a/X10D.sln +++ b/X10D.sln @@ -41,6 +41,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{ .github\workflows\unity.yml = .github\workflows\unity.yml EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X10D.UpmPackageGenerator", "X10D.UpmPackageGenerator\X10D.UpmPackageGenerator.csproj", "{CCBF047D-1B01-45EC-8D89-B00B4AC482CA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -75,6 +77,10 @@ Global {B04AF429-30CF-4B69-81BA-38F560CA9126}.Debug|Any CPU.Build.0 = Debug|Any CPU {B04AF429-30CF-4B69-81BA-38F560CA9126}.Release|Any CPU.ActiveCfg = Release|Any CPU {B04AF429-30CF-4B69-81BA-38F560CA9126}.Release|Any CPU.Build.0 = Release|Any CPU + {CCBF047D-1B01-45EC-8D89-B00B4AC482CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CCBF047D-1B01-45EC-8D89-B00B4AC482CA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CCBF047D-1B01-45EC-8D89-B00B4AC482CA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CCBF047D-1B01-45EC-8D89-B00B4AC482CA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -82,4 +88,6 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6F733785-8837-410C-BD91-C4AD1F0A6914} EndGlobalSection + GlobalSection(NestedProjects) = preSolution + EndGlobalSection EndGlobal