From fb15780bdcf9dc36dcef37ebc615f44f931e6b81 Mon Sep 17 00:00:00 2001 From: skibitsky Date: Thu, 19 Dec 2024 09:03:53 +0200 Subject: [PATCH 01/11] Release workflow --- .github/workflows/dotnet-build-test.yml | 1 + .github/workflows/release.yml | 40 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/dotnet-build-test.yml b/.github/workflows/dotnet-build-test.yml index 395263b..7e10857 100644 --- a/.github/workflows/dotnet-build-test.yml +++ b/.github/workflows/dotnet-build-test.yml @@ -14,6 +14,7 @@ jobs: dotnet-version: [8.0.x] test-type: [unit-tests, integration-tests] runs-on: ${{ matrix.os }} + timeout-minutes: 30 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..631a7ba --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + nuget: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 8.0.x + + - name: Build Release + run: dotnet build Reown.NoUnity.slnf -c Release --restore + + - name: Pack nugets + run: dotnet pack Reown.NoUnity.slnf -c Release --no-build --output . + + - name: List files + run: tree -L 3 + +# - name: Push to NuGet +# run: dotnet nuget push "*.nupkg" --api-key ${{secrets.nuget_api_key}} --source https://api.nuget.org/v3/index.json + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: build-artifacts + path: | + **/bin/**/*.dll + !**/Tests/**/bin/**/*.dll \ No newline at end of file From f809b2fbeecb5dcd46efc25120af5c56cb24fa73 Mon Sep 17 00:00:00 2001 From: skibitsky Date: Thu, 19 Dec 2024 09:14:11 +0200 Subject: [PATCH 02/11] Enable workflow --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 631a7ba..1ef256f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,7 @@ on: release: types: [published] workflow_dispatch: + pull_request: jobs: nuget: From 2fcdf41e904c458cebf297470399a1aa553e4732 Mon Sep 17 00:00:00 2001 From: skibitsky Date: Fri, 20 Dec 2024 11:28:16 +0200 Subject: [PATCH 03/11] Sync unity package version with nuget version --- .github/scripts/get-version.csx | 28 +++ .github/scripts/sync-unity-version.csx | 206 ++++++++++++++++++ src/Reown.AppKit.Unity/Runtime/AppKit.cs | 5 +- .../Runtime/Utils/VersionMarkerAttribute.cs | 9 + .../Utils/VersionMarkerAttribute.cs.meta | 3 + src/Reown.Sign.Unity/Runtime/SignMetadata.cs | 5 +- 6 files changed, 254 insertions(+), 2 deletions(-) create mode 100755 .github/scripts/get-version.csx create mode 100755 .github/scripts/sync-unity-version.csx create mode 100644 src/Reown.Core.Common/Runtime/Utils/VersionMarkerAttribute.cs create mode 100644 src/Reown.Core.Common/Runtime/Utils/VersionMarkerAttribute.cs.meta diff --git a/.github/scripts/get-version.csx b/.github/scripts/get-version.csx new file mode 100755 index 0000000..3fc71e7 --- /dev/null +++ b/.github/scripts/get-version.csx @@ -0,0 +1,28 @@ +#!/usr/bin/env dotnet-script + +using System.Xml.Linq; + +string GetVersion() +{ + var currentDir = Directory.GetCurrentDirectory(); + var rootDir = Path.GetFullPath(Path.Combine(currentDir, "src")); + var buildPropsPath = Path.Combine(rootDir, "Directory.Build.props"); + + if (!File.Exists(buildPropsPath)) + throw new Exception($"Could not find Directory.Build.props at {buildPropsPath}"); + + var doc = XDocument.Load(buildPropsPath); + + var version = doc.Descendants() + .Elements() + .FirstOrDefault(e => e.Name.LocalName == "DefaultVersion") + ?.Value; + + if (string.IsNullOrEmpty(version)) + throw new Exception("DefaultVersion not found in Directory.Build.props"); + + return version; +} + +var version = GetVersion(); +Console.WriteLine(version); \ No newline at end of file diff --git a/.github/scripts/sync-unity-version.csx b/.github/scripts/sync-unity-version.csx new file mode 100755 index 0000000..2748784 --- /dev/null +++ b/.github/scripts/sync-unity-version.csx @@ -0,0 +1,206 @@ +#!/usr/bin/env dotnet-script + +#load "get-version.csx" + +#r "nuget: Microsoft.CodeAnalysis.CSharp, 4.12.0" +#r "nuget: Newtonsoft.Json, 13.0.0" + +using System.Xml.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +var srcPath = Path.GetFullPath("src"); +Console.WriteLine($"Looking for files in: {srcPath}"); + +var newVersion = GetVersion(); +Console.WriteLine($"Current version: {newVersion}"); + +// Update version fields in the code +var versionFields = await FindVersionFieldsAsync(srcPath); +foreach (var field in versionFields) +{ + Console.WriteLine($"Found version field: {field.fieldName} = {field.version} in {field.filePath}"); + await UpdateVersionAsync(field.filePath, field.fieldName, newVersion); +} + +// Update Unity sample app version +var projectSettingsPath = Path.GetFullPath("sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset"); +await UpdateProjectSettingsVersionAsync(projectSettingsPath, newVersion); + +// Update Unity packages +await UpdatePackageVersionsAsync(srcPath, newVersion); + +private static async Task> FindVersionFieldsAsync(string path) +{ + var results = new List<(string filePath, string fieldName, string version)>(); + foreach (var file in Directory.EnumerateFiles(path, "*.cs", SearchOption.AllDirectories)) + { + var sourceText = SourceText.From(await File.ReadAllTextAsync(file)); + var tree = CSharpSyntaxTree.ParseText(sourceText); + var root = await tree.GetRootAsync(); + + var fields = root.DescendantNodes() + .OfType() + .Where(field => field.AttributeLists + .SelectMany(list => list.Attributes) + .Any(attr => attr.Name.ToString() == "VersionMarker")); + + foreach (var field in fields) + { + var variable = field.Declaration.Variables.First(); + if (variable.Initializer?.Value is LiteralExpressionSyntax literal) + { + results.Add(( + filePath: file, + fieldName: variable.Identifier.Text, + version: literal.Token.ValueText + )); + } + } + } + + return results; +} + +async Task UpdateVersionAsync(string filePath, string fieldName, string newVersion) +{ + var sourceText = SourceText.From(await File.ReadAllTextAsync(filePath)); + var tree = CSharpSyntaxTree.ParseText(sourceText); + var root = await tree.GetRootAsync(); + + // Find the specific field to update + var fieldToUpdate = root.DescendantNodes() + .OfType() + .First(field => + field.AttributeLists + .SelectMany(list => list.Attributes) + .Any(attr => attr.Name.ToString() == "VersionMarker") && + field.Declaration.Variables + .Any(v => v.Identifier.Text == fieldName)); + + var variable = fieldToUpdate.Declaration.Variables.First(); + + if (variable.Initializer?.Value is LiteralExpressionSyntax literal) + { + var currentValue = literal.Token.ValueText; + var newValue = UpdateVersionString(currentValue, newVersion); + + // Create new string literal + var newLiteral = SyntaxFactory.LiteralExpression( + SyntaxKind.StringLiteralExpression, + SyntaxFactory.Literal(newValue) + ); + + // Create new variable with updated initializer + var newVariable = variable.WithInitializer( + SyntaxFactory.EqualsValueClause(newLiteral) + ); + + // Create new field declaration + var newField = fieldToUpdate.WithDeclaration( + fieldToUpdate.Declaration.WithVariables( + SyntaxFactory.SingletonSeparatedList(newVariable) + ) + ); + + // Replace the old field with the new one + var newRoot = root.ReplaceNode(fieldToUpdate, newField); + + // Preserve original formatting + var formattedRoot = newRoot.NormalizeWhitespace(); + + await File.WriteAllTextAsync(filePath, formattedRoot.ToFullString()); + } +} + +string UpdateVersionString(string currentValue, string newVersion) +{ + var semVerPattern = new Regex( + @"^(?.*?)?(?:v)?(?\d+\.\d+\.\d+)$", + RegexOptions.Compiled + ); + var match = semVerPattern.Match(currentValue); + if (!match.Success) + { + throw new ArgumentException( + $"Current value '{currentValue}' doesn't contain a valid version number pattern"); + } + + var prefix = match.Groups["prefix"].Value; + var hasV = currentValue.Contains('v') && + (prefix.Length == 0 || !prefix.EndsWith('v')); + + return $"{prefix}{(hasV ? "v" : "")}{newVersion}"; +} + +async Task UpdateProjectSettingsVersionAsync(string filePath, string newVersion) +{ + if (!File.Exists(filePath)) + { + Console.WriteLine($"Warning: ProjectSettings.asset not found at {filePath}"); + return; + } + + var content = await File.ReadAllTextAsync(filePath); + + var pattern = @"(bundleVersion:)\s*(.+)"; + var replacement = $"$1 {newVersion}"; + + var updatedContent = Regex.Replace(content, pattern, replacement); + + await File.WriteAllTextAsync(filePath, updatedContent); + Console.WriteLine($"Updated bundleVersion in ProjectSettings.asset to {newVersion}"); +} + +async Task UpdatePackageVersionsAsync(string srcPath, string newVersion) +{ + foreach (var file in Directory.EnumerateFiles(srcPath, "package.json", SearchOption.AllDirectories)) + { + var content = await File.ReadAllTextAsync(file); + var packageJson = JObject.Parse(content); + var updated = false; + + using var jsonWriter = new StringWriter(); + using var writer = new JsonTextWriter(jsonWriter) + { + Formatting = Formatting.Indented + }; + using var jsonReader = new JsonTextReader(new StringReader(content)); + + while (jsonReader.Read()) + { + if (jsonReader.TokenType == JsonToken.PropertyName) + { + var propertyName = jsonReader.Value?.ToString(); + writer.WriteToken(jsonReader.TokenType, jsonReader.Value); + + jsonReader.Read(); + if (propertyName == "version" || (propertyName?.StartsWith("com.reown.") ?? false)) + { + if (jsonReader.Value?.ToString() != newVersion) + { + writer.WriteValue(newVersion); + updated = true; + continue; + } + } + writer.WriteToken(jsonReader.TokenType, jsonReader.Value); + } + else + { + writer.WriteToken(jsonReader.TokenType, jsonReader.Value); + } + } + + if (updated) + { + await File.WriteAllTextAsync(file, jsonWriter.ToString()); + Console.WriteLine($"Updated versions in {file}"); + } + } +} diff --git a/src/Reown.AppKit.Unity/Runtime/AppKit.cs b/src/Reown.AppKit.Unity/Runtime/AppKit.cs index 03734c6..4bf60b1 100644 --- a/src/Reown.AppKit.Unity/Runtime/AppKit.cs +++ b/src/Reown.AppKit.Unity/Runtime/AppKit.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using Reown.Core.Common.Utils; using Reown.Sign.Models; using Reown.Sign.Unity; using UnityEngine; @@ -9,7 +10,9 @@ namespace Reown.AppKit.Unity { public abstract class AppKit : MonoBehaviour { - public const string Version = "unity-appkit-v1.1.2"; // TODO: update this from CI + [VersionMarker] + public const string Version = "unity-appkit-v1.1.2"; + public static AppKit Instance { get; protected set; } public static ModalController ModalController { get; protected set; } diff --git a/src/Reown.Core.Common/Runtime/Utils/VersionMarkerAttribute.cs b/src/Reown.Core.Common/Runtime/Utils/VersionMarkerAttribute.cs new file mode 100644 index 0000000..4548976 --- /dev/null +++ b/src/Reown.Core.Common/Runtime/Utils/VersionMarkerAttribute.cs @@ -0,0 +1,9 @@ +using System; + +namespace Reown.Core.Common.Utils +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class VersionMarkerAttribute : Attribute + { + } +} \ No newline at end of file diff --git a/src/Reown.Core.Common/Runtime/Utils/VersionMarkerAttribute.cs.meta b/src/Reown.Core.Common/Runtime/Utils/VersionMarkerAttribute.cs.meta new file mode 100644 index 0000000..fdf57cc --- /dev/null +++ b/src/Reown.Core.Common/Runtime/Utils/VersionMarkerAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 501011529c814f06bc7be9dd6613c2ef +timeCreated: 1734595010 \ No newline at end of file diff --git a/src/Reown.Sign.Unity/Runtime/SignMetadata.cs b/src/Reown.Sign.Unity/Runtime/SignMetadata.cs index 9c89beb..3c0faef 100644 --- a/src/Reown.Sign.Unity/Runtime/SignMetadata.cs +++ b/src/Reown.Sign.Unity/Runtime/SignMetadata.cs @@ -1,7 +1,10 @@ +using Reown.Core.Common.Utils; + namespace Reown.Sign.Unity { public class SignMetadata { - public static string Version = "v1.1.2"; + [VersionMarker] + public const string Version = "v1.1.2"; } } \ No newline at end of file From 8b5ae55632eaf6e29fe9152191c7dbdb611ab094 Mon Sep 17 00:00:00 2001 From: skibitsky Date: Fri, 20 Dec 2024 11:29:44 +0200 Subject: [PATCH 04/11] Fix unity bulid error --- src/Reown.AppKit.Unity/Runtime/AppKit.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Reown.AppKit.Unity/Runtime/AppKit.cs b/src/Reown.AppKit.Unity/Runtime/AppKit.cs index 4bf60b1..ced3208 100644 --- a/src/Reown.AppKit.Unity/Runtime/AppKit.cs +++ b/src/Reown.AppKit.Unity/Runtime/AppKit.cs @@ -4,7 +4,6 @@ using Reown.Sign.Models; using Reown.Sign.Unity; using UnityEngine; -using UnityEngine.Scripting; namespace Reown.AppKit.Unity { From 362eb6f1264558e6c2ca748de999bd9f0e689d50 Mon Sep 17 00:00:00 2001 From: skibitsky Date: Fri, 20 Dec 2024 14:01:33 +0200 Subject: [PATCH 05/11] =?UTF-8?q?Update=20Unity=E2=80=99s=20packages-lock.?= =?UTF-8?q?json,=20loggin=20utilities?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/scripts/logging.csx | 29 +++++ .github/scripts/sync-unity-version.csx | 123 ++++++++++++++++-- .../workflows/sync-unity-package-version.yml | 29 +++++ 3 files changed, 173 insertions(+), 8 deletions(-) create mode 100644 .github/scripts/logging.csx create mode 100644 .github/workflows/sync-unity-package-version.yml diff --git a/.github/scripts/logging.csx b/.github/scripts/logging.csx new file mode 100644 index 0000000..90d8801 --- /dev/null +++ b/.github/scripts/logging.csx @@ -0,0 +1,29 @@ +public static class Log +{ + public static void Header(string message) + { + Console.WriteLine(); + Console.WriteLine($"=== {message} ==="); + } + + public static void SubHeader(string message) + { + Console.WriteLine(); + Console.WriteLine($"--- {message} ---"); + } + + public static void Info(string message) + { + Console.WriteLine($" {message}"); + } + + public static void Success(string message) + { + Console.WriteLine($" ✓ {message}"); + } + + public static void Warning(string message) + { + Console.WriteLine($" ⚠ {message}"); + } +} \ No newline at end of file diff --git a/.github/scripts/sync-unity-version.csx b/.github/scripts/sync-unity-version.csx index 2748784..5a5d978 100755 --- a/.github/scripts/sync-unity-version.csx +++ b/.github/scripts/sync-unity-version.csx @@ -1,6 +1,14 @@ #!/usr/bin/env dotnet-script +// This scripts is used to sync the version of Unity packages and sample apps with the version of NuGet packages. +// It gets the version from the Directory.Build.props file and updates +// - the version in C# where the version field is marked with [VersionMarker] attribute +// - the version in ProjectSettings.asset of the Unity sample app +// - the version and dependency versions in package.json of all Unity packages +// - the version in packages-lock.json of all Unity packages in the sample app + #load "get-version.csx" +#load "logging.csx" #r "nuget: Microsoft.CodeAnalysis.CSharp, 4.12.0" #r "nuget: Newtonsoft.Json, 13.0.0" @@ -15,25 +23,43 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; var srcPath = Path.GetFullPath("src"); -Console.WriteLine($"Looking for files in: {srcPath}"); +Log.Header("Starting Unity Version Sync"); +Log.Info($"Source path: {srcPath}"); var newVersion = GetVersion(); -Console.WriteLine($"Current version: {newVersion}"); +Log.Info($"Target version: {newVersion}"); // Update version fields in the code +Log.SubHeader("Updating Version Fields in Code"); var versionFields = await FindVersionFieldsAsync(srcPath); +if (!versionFields.Any()) +{ + Log.Warning("No version fields found"); +} foreach (var field in versionFields) { - Console.WriteLine($"Found version field: {field.fieldName} = {field.version} in {field.filePath}"); + Log.Info($"Found: {field.fieldName} = {field.version} in {Path.GetRelativePath(".", field.filePath)}"); await UpdateVersionAsync(field.filePath, field.fieldName, newVersion); + Log.Success($"Updated {field.fieldName} to {newVersion}"); } // Update Unity sample app version +Log.SubHeader("Updating Unity Sample App Version"); var projectSettingsPath = Path.GetFullPath("sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset"); -await UpdateProjectSettingsVersionAsync(projectSettingsPath, newVersion); +if (File.Exists(projectSettingsPath)) +{ + await UpdateProjectSettingsVersionAsync(projectSettingsPath, newVersion); + Log.Success($"Updated ProjectSettings.asset to {newVersion}"); +} +else +{ + Log.Warning($"ProjectSettings.asset not found at {projectSettingsPath}"); +} // Update Unity packages +Log.SubHeader("Updating Package Versions"); await UpdatePackageVersionsAsync(srcPath, newVersion); +await UpdatePackagesLockVersionsAsync(Path.GetFullPath("sample"), newVersion); private static async Task> FindVersionFieldsAsync(string path) { @@ -142,7 +168,7 @@ async Task UpdateProjectSettingsVersionAsync(string filePath, string newVersion) { if (!File.Exists(filePath)) { - Console.WriteLine($"Warning: ProjectSettings.asset not found at {filePath}"); + Log.Warning($"ProjectSettings.asset not found at {filePath}"); return; } @@ -154,13 +180,21 @@ async Task UpdateProjectSettingsVersionAsync(string filePath, string newVersion) var updatedContent = Regex.Replace(content, pattern, replacement); await File.WriteAllTextAsync(filePath, updatedContent); - Console.WriteLine($"Updated bundleVersion in ProjectSettings.asset to {newVersion}"); + Log.Success($"Updated bundleVersion in ProjectSettings.asset to {newVersion}"); } async Task UpdatePackageVersionsAsync(string srcPath, string newVersion) { - foreach (var file in Directory.EnumerateFiles(srcPath, "package.json", SearchOption.AllDirectories)) + var files = Directory.EnumerateFiles(srcPath, "package.json", SearchOption.AllDirectories).ToList(); + if (!files.Any()) { + Log.Warning($"No package.json files found in {Path.GetRelativePath(".", srcPath)}"); + return; + } + + foreach (var file in files) + { + Log.Info($"Processing: {Path.GetRelativePath(".", file)}"); var content = await File.ReadAllTextAsync(file); var packageJson = JObject.Parse(content); var updated = false; @@ -200,7 +234,80 @@ async Task UpdatePackageVersionsAsync(string srcPath, string newVersion) if (updated) { await File.WriteAllTextAsync(file, jsonWriter.ToString()); - Console.WriteLine($"Updated versions in {file}"); + Log.Success($"Updated versions in {file}"); + } + } +} + +async Task UpdatePackagesLockVersionsAsync(string basePath, string newVersion) +{ + var files = Directory.EnumerateFiles(basePath, "packages-lock.json", SearchOption.AllDirectories).ToList(); + if (!files.Any()) + { + Log.Warning($"No packages-lock.json files found in {Path.GetRelativePath(".", basePath)}"); + return; + } + + foreach (var file in files) + { + Log.Info($"Processing: {Path.GetRelativePath(".", file)}"); + var content = await File.ReadAllTextAsync(file); + var packageJson = JObject.Parse(content); + var updated = false; + var updatedPackages = new List<(string package, string from, string to)>(); + + // Update versions in dependencies + if (packageJson.TryGetValue("dependencies", out var dependencies) && dependencies is JObject depsObj) + { + foreach (var dep in depsObj.Properties()) + { + if (dep.Name.StartsWith("com.reown.")) + { + var depObj = dep.Value as JObject; + if (depObj != null) + { + // Update dependencies of the package + if (depObj.TryGetValue("dependencies", out var nestedDeps) && nestedDeps is JObject nestedDepsObj) + { + foreach (var nestedDep in nestedDepsObj.Properties()) + { + if (nestedDep.Name.StartsWith("com.reown.")) + { + var oldVersion = nestedDepsObj[nestedDep.Name].ToString(); + if (oldVersion != newVersion) + { + nestedDepsObj[nestedDep.Name] = newVersion; + updated = true; + updatedPackages.Add((nestedDep.Name, oldVersion, newVersion)); + } + } + } + } + + // Update the package version itself if it's not a file reference + if (depObj.TryGetValue("version", out var versionToken)) + { + var currentVersion = versionToken.ToString(); + if (!currentVersion.StartsWith("file:") && currentVersion != newVersion) + { + depObj["version"] = newVersion; + updated = true; + updatedPackages.Add((dep.Name, currentVersion, newVersion)); + } + } + } + } + } + } + + if (updated) + { + await File.WriteAllTextAsync(file, packageJson.ToString(Formatting.Indented)); + Log.Success($"Updated {updatedPackages.Count} package versions:"); + foreach (var (package, from, to) in updatedPackages) + { + Log.Info($" {package}: {from} → {to}"); + } } } } diff --git a/.github/workflows/sync-unity-package-version.yml b/.github/workflows/sync-unity-package-version.yml new file mode 100644 index 0000000..8acb859 --- /dev/null +++ b/.github/workflows/sync-unity-package-version.yml @@ -0,0 +1,29 @@ +name: Sync Unity Package Version + +on: + pull_request: + paths: + - 'src/Directory.Build.props' + workflow_dispatch: + +jobs: + sync-unity-version: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 8.0.x + + - name: Install dotnet-script + run: | + dotnet tool install -g dotnet-script + echo "$HOME/.dotnet/tools" >> $GITHUB_PATH + + - name: Sync Unity Package Version + run: dotnet-script ./.github/scripts/sync-unity-version.csx From 3ce5ff1df7cd89ec0de92feab7935444c67abbdf Mon Sep 17 00:00:00 2001 From: skibitsky Date: Fri, 20 Dec 2024 14:12:20 +0200 Subject: [PATCH 06/11] Update Unity Package Version Sync Workflow --- .github/workflows/sync-unity-package-version.yml | 15 +++++++++++++++ src/Directory.Build.props | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync-unity-package-version.yml b/.github/workflows/sync-unity-package-version.yml index 8acb859..c948169 100644 --- a/.github/workflows/sync-unity-package-version.yml +++ b/.github/workflows/sync-unity-package-version.yml @@ -6,6 +6,10 @@ on: - 'src/Directory.Build.props' workflow_dispatch: +permissions: + contents: write + pull-requests: write + jobs: sync-unity-version: runs-on: ubuntu-latest @@ -13,6 +17,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + token: ${{ secrets.GITHUB_TOKEN }} - name: Setup .NET uses: actions/setup-dotnet@v3 @@ -27,3 +34,11 @@ jobs: - name: Sync Unity Package Version run: dotnet-script ./.github/scripts/sync-unity-version.csx + + - name: Commit changes + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add -u + git commit -m "Sync Unity Package Versions" + git push \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 3da303f..39ed27b 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@ - 1.1.2 + 1.1.3 net7.0;net8.0;netstandard2.1; reown inc. https://reown.com/ From 20f073d87dd10f5a1b0d426a5f2041b713168389 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 20 Dec 2024 12:13:01 +0000 Subject: [PATCH 07/11] Sync Unity Package Versions --- .../Packages/packages-lock.json | 42 ++-- .../ProjectSettings/ProjectSettings.asset | 2 +- src/Reown.AppKit.Unity/Runtime/AppKit.cs | 224 +++++++----------- src/Reown.AppKit.Unity/package.json | 12 +- src/Reown.Core.Common/package.json | 4 +- src/Reown.Core.Crypto/package.json | 12 +- src/Reown.Core.Network/package.json | 6 +- src/Reown.Core.Storage/package.json | 6 +- src/Reown.Core/package.json | 14 +- src/Reown.Sign.Nethereum.Unity/package.json | 8 +- src/Reown.Sign.Nethereum/package.json | 6 +- src/Reown.Sign.Unity/Runtime/SignMetadata.cs | 18 +- src/Reown.Sign.Unity/package.json | 6 +- src/Reown.Sign/package.json | 6 +- src/Reown.Unity.Dependencies/package.json | 4 +- 15 files changed, 164 insertions(+), 206 deletions(-) diff --git a/sample/Reown.AppKit.Unity/Packages/packages-lock.json b/sample/Reown.AppKit.Unity/Packages/packages-lock.json index 21cc9c8..d28efa2 100644 --- a/sample/Reown.AppKit.Unity/Packages/packages-lock.json +++ b/sample/Reown.AppKit.Unity/Packages/packages-lock.json @@ -26,10 +26,10 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.sign.nethereum.unity": "1.1.2", - "com.reown.sign.unity": "1.1.2", - "com.reown.core": "1.1.2", - "com.reown.unity.dependencies": "1.1.2", + "com.reown.sign.nethereum.unity": "1.1.3", + "com.reown.sign.unity": "1.1.3", + "com.reown.core": "1.1.3", + "com.reown.unity.dependencies": "1.1.3", "com.unity.vectorgraphics": "2.0.0-preview.24" } }, @@ -38,11 +38,11 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.core.common": "1.1.2", - "com.reown.core.network": "1.1.2", - "com.reown.core.storage": "1.1.2", - "com.reown.core.crypto": "1.1.2", - "com.reown.unity.dependencies": "1.1.2" + "com.reown.core.common": "1.1.3", + "com.reown.core.network": "1.1.3", + "com.reown.core.storage": "1.1.3", + "com.reown.core.crypto": "1.1.3", + "com.reown.unity.dependencies": "1.1.3" } }, "com.reown.core.common": { @@ -58,10 +58,10 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.core.common": "1.1.2", - "com.reown.core.network": "1.1.2", - "com.reown.core.storage": "1.1.2", - "com.reown.unity.dependencies": "1.1.2" + "com.reown.core.common": "1.1.3", + "com.reown.core.network": "1.1.3", + "com.reown.core.storage": "1.1.3", + "com.reown.unity.dependencies": "1.1.3" } }, "com.reown.core.network": { @@ -69,7 +69,7 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.core.common": "1.1.2" + "com.reown.core.common": "1.1.3" } }, "com.reown.core.storage": { @@ -77,7 +77,7 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.core.common": "1.1.2" + "com.reown.core.common": "1.1.3" } }, "com.reown.sign": { @@ -85,7 +85,7 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.core": "1.1.2" + "com.reown.core": "1.1.3" } }, "com.reown.sign.nethereum": { @@ -93,7 +93,7 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.sign": "1.1.2", + "com.reown.sign": "1.1.3", "com.nethereum.unity": "4.26.0" } }, @@ -102,8 +102,8 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.sign.nethereum": "1.1.2", - "com.reown.sign.unity": "1.1.2" + "com.reown.sign.nethereum": "1.1.3", + "com.reown.sign.unity": "1.1.3" } }, "com.reown.sign.unity": { @@ -111,7 +111,7 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.sign": "1.1.2" + "com.reown.sign": "1.1.3" } }, "com.reown.unity.dependencies": { @@ -367,4 +367,4 @@ } } } -} +} \ No newline at end of file diff --git a/sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset b/sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset index ea8b671..6921cf0 100644 --- a/sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset +++ b/sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset @@ -140,7 +140,7 @@ PlayerSettings: loadStoreDebugModeEnabled: 0 visionOSBundleVersion: 1.0 tvOSBundleVersion: 1.0 - bundleVersion: 1.1.2 + bundleVersion: 1.1.3 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 diff --git a/src/Reown.AppKit.Unity/Runtime/AppKit.cs b/src/Reown.AppKit.Unity/Runtime/AppKit.cs index ced3208..f27fc87 100644 --- a/src/Reown.AppKit.Unity/Runtime/AppKit.cs +++ b/src/Reown.AppKit.Unity/Runtime/AppKit.cs @@ -1,134 +1,92 @@ -using System; -using System.Threading.Tasks; -using Reown.Core.Common.Utils; -using Reown.Sign.Models; -using Reown.Sign.Unity; -using UnityEngine; - -namespace Reown.AppKit.Unity -{ - public abstract class AppKit : MonoBehaviour - { - [VersionMarker] - public const string Version = "unity-appkit-v1.1.2"; - - public static AppKit Instance { get; protected set; } - - public static ModalController ModalController { get; protected set; } - public static AccountController AccountController { get; protected set; } - public static ConnectorController ConnectorController { get; protected set; } - public static ApiController ApiController { get; protected set; } - public static BlockchainApiController BlockchainApiController { get; protected set; } - public static NotificationController NotificationController { get; protected set; } - public static NetworkController NetworkController { get; protected set; } - public static EventsController EventsController { get; protected set; } - public static SiweController SiweController { get; protected set; } - - public static EvmService Evm { get; protected set; } - - public static AppKitConfig Config { get; private set; } - - public SignClientUnity SignClient { get; protected set; } - - public static bool IsInitialized { get; private set; } - - public static bool IsAccountConnected - { - get => ConnectorController.IsAccountConnected; - } - - public static bool IsModalOpen - { - get => ModalController.IsOpen; - } - - public static event EventHandler Initialized; - - public static event EventHandler AccountConnected - { - add => ConnectorController.AccountConnected += value; - remove => ConnectorController.AccountConnected -= value; - } - - public static event EventHandler AccountDisconnected - { - add => ConnectorController.AccountDisconnected += value; - remove => ConnectorController.AccountDisconnected -= value; - } - - public static event EventHandler AccountChanged - { - add => ConnectorController.AccountChanged += value; - remove => ConnectorController.AccountChanged -= value; - } - - public static event EventHandler ChainChanged - { - add => NetworkController.ChainChanged += value; - remove => NetworkController.ChainChanged -= value; - } - - public static async Task InitializeAsync(AppKitConfig config) - { - if (Instance == null) - throw new Exception("Instance not set"); - if (IsInitialized) - throw new Exception("Already initialized"); // TODO: use custom ex type - - Config = config ?? throw new ArgumentNullException(nameof(config)); - - await Instance.InitializeAsyncCore(); - - IsInitialized = true; - Initialized?.Invoke(null, new InitializeEventArgs()); - } - - public static void OpenModal(ViewType viewType = ViewType.None) - { - if (!IsInitialized) - throw new Exception("AppKit not initialized"); // TODO: use custom ex type - - Instance.OpenModalCore(viewType); - } - - public static void CloseModal() - { - if (!IsModalOpen) - return; - - Instance.CloseModalCore(); - } - - public static Task GetAccountAsync() - { - return ConnectorController.GetAccountAsync(); - } - - public static Task DisconnectAsync() - { - if (!IsInitialized) - throw new Exception("AppKit not initialized"); // TODO: use custom ex type - - if (!IsAccountConnected) - throw new Exception("No account connected"); // TODO: use custom ex type - - return Instance.DisconnectAsyncCore(); - } - - protected abstract Task InitializeAsyncCore(); - - protected abstract void OpenModalCore(ViewType viewType = ViewType.None); - - protected abstract void CloseModalCore(); - - protected abstract Task DisconnectAsyncCore(); - - public class InitializeEventArgs : EventArgs - { - [Preserve] - public InitializeEventArgs() - { - } - } - } +using System; +using System.Threading.Tasks; +using Reown.Core.Common.Utils; +using Reown.Sign.Models; +using Reown.Sign.Unity; +using UnityEngine; + +namespace Reown.AppKit.Unity +{ + public abstract class AppKit : MonoBehaviour + { + [VersionMarker] + public const string Version = "unity-appkit-v1.1.3"; + public static AppKit Instance { get; protected set; } + public static ModalController ModalController { get; protected set; } + public static AccountController AccountController { get; protected set; } + public static ConnectorController ConnectorController { get; protected set; } + public static ApiController ApiController { get; protected set; } + public static BlockchainApiController BlockchainApiController { get; protected set; } + public static NotificationController NotificationController { get; protected set; } + public static NetworkController NetworkController { get; protected set; } + public static EventsController EventsController { get; protected set; } + public static SiweController SiweController { get; protected set; } + public static EvmService Evm { get; protected set; } + public static AppKitConfig Config { get; private set; } + public SignClientUnity SignClient { get; protected set; } + public static bool IsInitialized { get; private set; } + public static bool IsAccountConnected { get => ConnectorController.IsAccountConnected; } + public static bool IsModalOpen { get => ModalController.IsOpen; } + + public static event EventHandler Initialized; + public static event EventHandler AccountConnected { add => ConnectorController.AccountConnected += value; remove => ConnectorController.AccountConnected -= value; } + + public static event EventHandler AccountDisconnected { add => ConnectorController.AccountDisconnected += value; remove => ConnectorController.AccountDisconnected -= value; } + + public static event EventHandler AccountChanged { add => ConnectorController.AccountChanged += value; remove => ConnectorController.AccountChanged -= value; } + + public static event EventHandler ChainChanged { add => NetworkController.ChainChanged += value; remove => NetworkController.ChainChanged -= value; } + + public static async Task InitializeAsync(AppKitConfig config) + { + if (Instance == null) + throw new Exception("Instance not set"); + if (IsInitialized) + throw new Exception("Already initialized"); // TODO: use custom ex type + Config = config ?? throw new ArgumentNullException(nameof(config)); + await Instance.InitializeAsyncCore(); + IsInitialized = true; + Initialized?.Invoke(null, new InitializeEventArgs()); + } + + public static void OpenModal(ViewType viewType = ViewType.None) + { + if (!IsInitialized) + throw new Exception("AppKit not initialized"); // TODO: use custom ex type + Instance.OpenModalCore(viewType); + } + + public static void CloseModal() + { + if (!IsModalOpen) + return; + Instance.CloseModalCore(); + } + + public static Task GetAccountAsync() + { + return ConnectorController.GetAccountAsync(); + } + + public static Task DisconnectAsync() + { + if (!IsInitialized) + throw new Exception("AppKit not initialized"); // TODO: use custom ex type + if (!IsAccountConnected) + throw new Exception("No account connected"); // TODO: use custom ex type + return Instance.DisconnectAsyncCore(); + } + + protected abstract Task InitializeAsyncCore(); + protected abstract void OpenModalCore(ViewType viewType = ViewType.None); + protected abstract void CloseModalCore(); + protected abstract Task DisconnectAsyncCore(); + public class InitializeEventArgs : EventArgs + { + [Preserve] + public InitializeEventArgs() + { + } + } + } } \ No newline at end of file diff --git a/src/Reown.AppKit.Unity/package.json b/src/Reown.AppKit.Unity/package.json index 359a86d..c018863 100644 --- a/src/Reown.AppKit.Unity/package.json +++ b/src/Reown.AppKit.Unity/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.appkit.unity", - "version": "1.1.2", + "version": "1.1.3", "displayName": "Reown.AppKit.Unity", "unity": "2022.3", "author": "Reown", @@ -12,10 +12,10 @@ "web3" ], "dependencies": { - "com.reown.sign.nethereum.unity": "1.1.2", - "com.reown.sign.unity": "1.1.2", - "com.reown.core": "1.1.2", - "com.reown.unity.dependencies": "1.1.2", + "com.reown.sign.nethereum.unity": "1.1.3", + "com.reown.sign.unity": "1.1.3", + "com.reown.core": "1.1.3", + "com.reown.unity.dependencies": "1.1.3", "com.unity.vectorgraphics": "2.0.0-preview.24" } -} +} \ No newline at end of file diff --git a/src/Reown.Core.Common/package.json b/src/Reown.Core.Common/package.json index c1921a1..6b01496 100644 --- a/src/Reown.Core.Common/package.json +++ b/src/Reown.Core.Common/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.core.common", - "version": "1.1.2", + "version": "1.1.3", "displayName": "Reown.Core.Common", "unity": "2022.3", "author": "Reown", @@ -10,4 +10,4 @@ "dependencies": { "com.unity.nuget.newtonsoft-json": "3.2.1" } -} +} \ No newline at end of file diff --git a/src/Reown.Core.Crypto/package.json b/src/Reown.Core.Crypto/package.json index 0335b2c..f90cd5c 100644 --- a/src/Reown.Core.Crypto/package.json +++ b/src/Reown.Core.Crypto/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.core.crypto", - "version": "1.1.2", + "version": "1.1.3", "displayName": "Reown.Core.Crypto", "unity": "2022.3", "author": "Reown", @@ -8,9 +8,9 @@ "reown" ], "dependencies": { - "com.reown.core.common": "1.1.2", - "com.reown.core.network": "1.1.2", - "com.reown.core.storage": "1.1.2", - "com.reown.unity.dependencies": "1.1.2" + "com.reown.core.common": "1.1.3", + "com.reown.core.network": "1.1.3", + "com.reown.core.storage": "1.1.3", + "com.reown.unity.dependencies": "1.1.3" } -} +} \ No newline at end of file diff --git a/src/Reown.Core.Network/package.json b/src/Reown.Core.Network/package.json index 17837c8..73c6cc5 100644 --- a/src/Reown.Core.Network/package.json +++ b/src/Reown.Core.Network/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.core.network", - "version": "1.1.2", + "version": "1.1.3", "displayName": "Reown.Core.Network", "unity": "2022.3", "author": "Reown", @@ -8,6 +8,6 @@ "reown" ], "dependencies": { - "com.reown.core.common": "1.1.2" + "com.reown.core.common": "1.1.3" } -} +} \ No newline at end of file diff --git a/src/Reown.Core.Storage/package.json b/src/Reown.Core.Storage/package.json index a6b2aaa..29a9736 100644 --- a/src/Reown.Core.Storage/package.json +++ b/src/Reown.Core.Storage/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.core.storage", - "version": "1.1.2", + "version": "1.1.3", "displayName": "Reown.Core.Storage", "unity": "2022.3", "author": "Reown", @@ -8,6 +8,6 @@ "reown" ], "dependencies": { - "com.reown.core.common": "1.1.2" + "com.reown.core.common": "1.1.3" } -} +} \ No newline at end of file diff --git a/src/Reown.Core/package.json b/src/Reown.Core/package.json index f8c9d82..23a2ac6 100644 --- a/src/Reown.Core/package.json +++ b/src/Reown.Core/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.core", - "version": "1.1.2", + "version": "1.1.3", "displayName": "Reown.Core", "unity": "2022.3", "author": "Reown", @@ -8,10 +8,10 @@ "reown" ], "dependencies": { - "com.reown.core.common": "1.1.2", - "com.reown.core.network": "1.1.2", - "com.reown.core.storage": "1.1.2", - "com.reown.core.crypto": "1.1.2", - "com.reown.unity.dependencies": "1.1.2" + "com.reown.core.common": "1.1.3", + "com.reown.core.network": "1.1.3", + "com.reown.core.storage": "1.1.3", + "com.reown.core.crypto": "1.1.3", + "com.reown.unity.dependencies": "1.1.3" } -} +} \ No newline at end of file diff --git a/src/Reown.Sign.Nethereum.Unity/package.json b/src/Reown.Sign.Nethereum.Unity/package.json index be95b6f..940a3c7 100644 --- a/src/Reown.Sign.Nethereum.Unity/package.json +++ b/src/Reown.Sign.Nethereum.Unity/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.sign.nethereum.unity", - "version": "1.1.2", + "version": "1.1.3", "displayName": "Reown.Sign.Nethereum.Unity", "unity": "2022.3", "author": "Reown", @@ -9,7 +9,7 @@ "walletconnect" ], "dependencies": { - "com.reown.sign.nethereum": "1.1.2", - "com.reown.sign.unity": "1.1.2" + "com.reown.sign.nethereum": "1.1.3", + "com.reown.sign.unity": "1.1.3" } -} +} \ No newline at end of file diff --git a/src/Reown.Sign.Nethereum/package.json b/src/Reown.Sign.Nethereum/package.json index cd9e0aa..7cc3639 100644 --- a/src/Reown.Sign.Nethereum/package.json +++ b/src/Reown.Sign.Nethereum/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.sign.nethereum", - "version": "1.1.2", + "version": "1.1.3", "displayName": "Reown.Sign.Nethereum", "unity": "2022.3", "author": "Reown", @@ -9,7 +9,7 @@ "walletconnect" ], "dependencies": { - "com.reown.sign": "1.1.2", + "com.reown.sign": "1.1.3", "com.nethereum.unity": "4.26.0" } -} +} \ No newline at end of file diff --git a/src/Reown.Sign.Unity/Runtime/SignMetadata.cs b/src/Reown.Sign.Unity/Runtime/SignMetadata.cs index 3c0faef..c998ddd 100644 --- a/src/Reown.Sign.Unity/Runtime/SignMetadata.cs +++ b/src/Reown.Sign.Unity/Runtime/SignMetadata.cs @@ -1,10 +1,10 @@ -using Reown.Core.Common.Utils; - -namespace Reown.Sign.Unity -{ - public class SignMetadata - { - [VersionMarker] - public const string Version = "v1.1.2"; - } +using Reown.Core.Common.Utils; + +namespace Reown.Sign.Unity +{ + public class SignMetadata + { + [VersionMarker] + public const string Version = "v1.1.3"; + } } \ No newline at end of file diff --git a/src/Reown.Sign.Unity/package.json b/src/Reown.Sign.Unity/package.json index e60a748..5447068 100644 --- a/src/Reown.Sign.Unity/package.json +++ b/src/Reown.Sign.Unity/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.sign.unity", - "version": "1.1.2", + "version": "1.1.3", "displayName": "Reown.Sign.Unity", "unity": "2022.3", "author": "Reown", @@ -9,6 +9,6 @@ "walletconnect" ], "dependencies": { - "com.reown.sign": "1.1.2" + "com.reown.sign": "1.1.3" } -} +} \ No newline at end of file diff --git a/src/Reown.Sign/package.json b/src/Reown.Sign/package.json index aa6fceb..e52aaf0 100644 --- a/src/Reown.Sign/package.json +++ b/src/Reown.Sign/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.sign", - "version": "1.1.2", + "version": "1.1.3", "displayName": "Reown.Sign", "unity": "2022.3", "author": "Reown", @@ -8,6 +8,6 @@ "reown" ], "dependencies": { - "com.reown.core": "1.1.2" + "com.reown.core": "1.1.3" } -} +} \ No newline at end of file diff --git a/src/Reown.Unity.Dependencies/package.json b/src/Reown.Unity.Dependencies/package.json index 0c8cbc5..0d0de50 100644 --- a/src/Reown.Unity.Dependencies/package.json +++ b/src/Reown.Unity.Dependencies/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.unity.dependencies", - "version": "1.1.2", + "version": "1.1.3", "displayName": "Reown.Unity.Dependencies", "unity": "2022.3", "author": "Reown", @@ -10,4 +10,4 @@ "dependencies": { "com.unity.nuget.newtonsoft-json": "3.2.1" } -} +} \ No newline at end of file From 2336e79366241612c359825777121ce9e75abdae Mon Sep 17 00:00:00 2001 From: skibitsky Date: Fri, 20 Dec 2024 14:30:49 +0200 Subject: [PATCH 08/11] Preserve trivia during code generation --- .github/scripts/sync-unity-version.csx | 31 ++- src/Directory.Build.props | 2 +- src/Reown.AppKit.Unity/Runtime/AppKit.cs | 224 +++++++++++-------- src/Reown.Sign.Unity/Runtime/SignMetadata.cs | 18 +- 4 files changed, 157 insertions(+), 118 deletions(-) diff --git a/.github/scripts/sync-unity-version.csx b/.github/scripts/sync-unity-version.csx index 5a5d978..124a4c9 100755 --- a/.github/scripts/sync-unity-version.csx +++ b/.github/scripts/sync-unity-version.csx @@ -116,31 +116,28 @@ async Task UpdateVersionAsync(string filePath, string fieldName, string newVersi var currentValue = literal.Token.ValueText; var newValue = UpdateVersionString(currentValue, newVersion); - // Create new string literal + // Create new string literal while preserving trivia var newLiteral = SyntaxFactory.LiteralExpression( SyntaxKind.StringLiteralExpression, - SyntaxFactory.Literal(newValue) - ); + SyntaxFactory.Literal(literal.Token.LeadingTrivia, $"\"{newValue}\"", newValue, literal.Token.TrailingTrivia) + ).WithTriviaFrom(literal); - // Create new variable with updated initializer - var newVariable = variable.WithInitializer( - SyntaxFactory.EqualsValueClause(newLiteral) - ); + // Create new variable with updated initializer, preserving trivia + var newVariable = variable + .WithInitializer(variable.Initializer.WithValue(newLiteral)) + .WithTriviaFrom(variable); - // Create new field declaration - var newField = fieldToUpdate.WithDeclaration( - fieldToUpdate.Declaration.WithVariables( - SyntaxFactory.SingletonSeparatedList(newVariable) - ) - ); + // Create new field declaration preserving trivia + var newField = fieldToUpdate + .WithDeclaration(fieldToUpdate.Declaration.WithVariables( + SyntaxFactory.SingletonSeparatedList(newVariable))) + .WithTriviaFrom(fieldToUpdate); // Replace the old field with the new one var newRoot = root.ReplaceNode(fieldToUpdate, newField); - // Preserve original formatting - var formattedRoot = newRoot.NormalizeWhitespace(); - - await File.WriteAllTextAsync(filePath, formattedRoot.ToFullString()); + // Write back preserving original encoding and line endings + await File.WriteAllTextAsync(filePath, newRoot.ToFullString()); } } diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 39ed27b..9bf0adf 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@ - 1.1.3 + 1.1.4 net7.0;net8.0;netstandard2.1; reown inc. https://reown.com/ diff --git a/src/Reown.AppKit.Unity/Runtime/AppKit.cs b/src/Reown.AppKit.Unity/Runtime/AppKit.cs index f27fc87..ced3208 100644 --- a/src/Reown.AppKit.Unity/Runtime/AppKit.cs +++ b/src/Reown.AppKit.Unity/Runtime/AppKit.cs @@ -1,92 +1,134 @@ -using System; -using System.Threading.Tasks; -using Reown.Core.Common.Utils; -using Reown.Sign.Models; -using Reown.Sign.Unity; -using UnityEngine; - -namespace Reown.AppKit.Unity -{ - public abstract class AppKit : MonoBehaviour - { - [VersionMarker] - public const string Version = "unity-appkit-v1.1.3"; - public static AppKit Instance { get; protected set; } - public static ModalController ModalController { get; protected set; } - public static AccountController AccountController { get; protected set; } - public static ConnectorController ConnectorController { get; protected set; } - public static ApiController ApiController { get; protected set; } - public static BlockchainApiController BlockchainApiController { get; protected set; } - public static NotificationController NotificationController { get; protected set; } - public static NetworkController NetworkController { get; protected set; } - public static EventsController EventsController { get; protected set; } - public static SiweController SiweController { get; protected set; } - public static EvmService Evm { get; protected set; } - public static AppKitConfig Config { get; private set; } - public SignClientUnity SignClient { get; protected set; } - public static bool IsInitialized { get; private set; } - public static bool IsAccountConnected { get => ConnectorController.IsAccountConnected; } - public static bool IsModalOpen { get => ModalController.IsOpen; } - - public static event EventHandler Initialized; - public static event EventHandler AccountConnected { add => ConnectorController.AccountConnected += value; remove => ConnectorController.AccountConnected -= value; } - - public static event EventHandler AccountDisconnected { add => ConnectorController.AccountDisconnected += value; remove => ConnectorController.AccountDisconnected -= value; } - - public static event EventHandler AccountChanged { add => ConnectorController.AccountChanged += value; remove => ConnectorController.AccountChanged -= value; } - - public static event EventHandler ChainChanged { add => NetworkController.ChainChanged += value; remove => NetworkController.ChainChanged -= value; } - - public static async Task InitializeAsync(AppKitConfig config) - { - if (Instance == null) - throw new Exception("Instance not set"); - if (IsInitialized) - throw new Exception("Already initialized"); // TODO: use custom ex type - Config = config ?? throw new ArgumentNullException(nameof(config)); - await Instance.InitializeAsyncCore(); - IsInitialized = true; - Initialized?.Invoke(null, new InitializeEventArgs()); - } - - public static void OpenModal(ViewType viewType = ViewType.None) - { - if (!IsInitialized) - throw new Exception("AppKit not initialized"); // TODO: use custom ex type - Instance.OpenModalCore(viewType); - } - - public static void CloseModal() - { - if (!IsModalOpen) - return; - Instance.CloseModalCore(); - } - - public static Task GetAccountAsync() - { - return ConnectorController.GetAccountAsync(); - } - - public static Task DisconnectAsync() - { - if (!IsInitialized) - throw new Exception("AppKit not initialized"); // TODO: use custom ex type - if (!IsAccountConnected) - throw new Exception("No account connected"); // TODO: use custom ex type - return Instance.DisconnectAsyncCore(); - } - - protected abstract Task InitializeAsyncCore(); - protected abstract void OpenModalCore(ViewType viewType = ViewType.None); - protected abstract void CloseModalCore(); - protected abstract Task DisconnectAsyncCore(); - public class InitializeEventArgs : EventArgs - { - [Preserve] - public InitializeEventArgs() - { - } - } - } +using System; +using System.Threading.Tasks; +using Reown.Core.Common.Utils; +using Reown.Sign.Models; +using Reown.Sign.Unity; +using UnityEngine; + +namespace Reown.AppKit.Unity +{ + public abstract class AppKit : MonoBehaviour + { + [VersionMarker] + public const string Version = "unity-appkit-v1.1.2"; + + public static AppKit Instance { get; protected set; } + + public static ModalController ModalController { get; protected set; } + public static AccountController AccountController { get; protected set; } + public static ConnectorController ConnectorController { get; protected set; } + public static ApiController ApiController { get; protected set; } + public static BlockchainApiController BlockchainApiController { get; protected set; } + public static NotificationController NotificationController { get; protected set; } + public static NetworkController NetworkController { get; protected set; } + public static EventsController EventsController { get; protected set; } + public static SiweController SiweController { get; protected set; } + + public static EvmService Evm { get; protected set; } + + public static AppKitConfig Config { get; private set; } + + public SignClientUnity SignClient { get; protected set; } + + public static bool IsInitialized { get; private set; } + + public static bool IsAccountConnected + { + get => ConnectorController.IsAccountConnected; + } + + public static bool IsModalOpen + { + get => ModalController.IsOpen; + } + + public static event EventHandler Initialized; + + public static event EventHandler AccountConnected + { + add => ConnectorController.AccountConnected += value; + remove => ConnectorController.AccountConnected -= value; + } + + public static event EventHandler AccountDisconnected + { + add => ConnectorController.AccountDisconnected += value; + remove => ConnectorController.AccountDisconnected -= value; + } + + public static event EventHandler AccountChanged + { + add => ConnectorController.AccountChanged += value; + remove => ConnectorController.AccountChanged -= value; + } + + public static event EventHandler ChainChanged + { + add => NetworkController.ChainChanged += value; + remove => NetworkController.ChainChanged -= value; + } + + public static async Task InitializeAsync(AppKitConfig config) + { + if (Instance == null) + throw new Exception("Instance not set"); + if (IsInitialized) + throw new Exception("Already initialized"); // TODO: use custom ex type + + Config = config ?? throw new ArgumentNullException(nameof(config)); + + await Instance.InitializeAsyncCore(); + + IsInitialized = true; + Initialized?.Invoke(null, new InitializeEventArgs()); + } + + public static void OpenModal(ViewType viewType = ViewType.None) + { + if (!IsInitialized) + throw new Exception("AppKit not initialized"); // TODO: use custom ex type + + Instance.OpenModalCore(viewType); + } + + public static void CloseModal() + { + if (!IsModalOpen) + return; + + Instance.CloseModalCore(); + } + + public static Task GetAccountAsync() + { + return ConnectorController.GetAccountAsync(); + } + + public static Task DisconnectAsync() + { + if (!IsInitialized) + throw new Exception("AppKit not initialized"); // TODO: use custom ex type + + if (!IsAccountConnected) + throw new Exception("No account connected"); // TODO: use custom ex type + + return Instance.DisconnectAsyncCore(); + } + + protected abstract Task InitializeAsyncCore(); + + protected abstract void OpenModalCore(ViewType viewType = ViewType.None); + + protected abstract void CloseModalCore(); + + protected abstract Task DisconnectAsyncCore(); + + public class InitializeEventArgs : EventArgs + { + [Preserve] + public InitializeEventArgs() + { + } + } + } } \ No newline at end of file diff --git a/src/Reown.Sign.Unity/Runtime/SignMetadata.cs b/src/Reown.Sign.Unity/Runtime/SignMetadata.cs index c998ddd..3c0faef 100644 --- a/src/Reown.Sign.Unity/Runtime/SignMetadata.cs +++ b/src/Reown.Sign.Unity/Runtime/SignMetadata.cs @@ -1,10 +1,10 @@ -using Reown.Core.Common.Utils; - -namespace Reown.Sign.Unity -{ - public class SignMetadata - { - [VersionMarker] - public const string Version = "v1.1.3"; - } +using Reown.Core.Common.Utils; + +namespace Reown.Sign.Unity +{ + public class SignMetadata + { + [VersionMarker] + public const string Version = "v1.1.2"; + } } \ No newline at end of file From ed26783e3d21520b10293a09f6cfeb33110e5cd1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 20 Dec 2024 12:31:47 +0000 Subject: [PATCH 09/11] Sync Unity Package Versions --- .../Packages/packages-lock.json | 40 +++++++++---------- .../ProjectSettings/ProjectSettings.asset | 2 +- src/Reown.AppKit.Unity/Runtime/AppKit.cs | 2 +- src/Reown.AppKit.Unity/package.json | 10 ++--- src/Reown.Core.Common/package.json | 2 +- src/Reown.Core.Crypto/package.json | 10 ++--- src/Reown.Core.Network/package.json | 4 +- src/Reown.Core.Storage/package.json | 4 +- src/Reown.Core/package.json | 12 +++--- src/Reown.Sign.Nethereum.Unity/package.json | 6 +-- src/Reown.Sign.Nethereum/package.json | 4 +- src/Reown.Sign.Unity/Runtime/SignMetadata.cs | 2 +- src/Reown.Sign.Unity/package.json | 4 +- src/Reown.Sign/package.json | 4 +- src/Reown.Unity.Dependencies/package.json | 2 +- 15 files changed, 54 insertions(+), 54 deletions(-) diff --git a/sample/Reown.AppKit.Unity/Packages/packages-lock.json b/sample/Reown.AppKit.Unity/Packages/packages-lock.json index d28efa2..d955a2c 100644 --- a/sample/Reown.AppKit.Unity/Packages/packages-lock.json +++ b/sample/Reown.AppKit.Unity/Packages/packages-lock.json @@ -26,10 +26,10 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.sign.nethereum.unity": "1.1.3", - "com.reown.sign.unity": "1.1.3", - "com.reown.core": "1.1.3", - "com.reown.unity.dependencies": "1.1.3", + "com.reown.sign.nethereum.unity": "1.1.4", + "com.reown.sign.unity": "1.1.4", + "com.reown.core": "1.1.4", + "com.reown.unity.dependencies": "1.1.4", "com.unity.vectorgraphics": "2.0.0-preview.24" } }, @@ -38,11 +38,11 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.core.common": "1.1.3", - "com.reown.core.network": "1.1.3", - "com.reown.core.storage": "1.1.3", - "com.reown.core.crypto": "1.1.3", - "com.reown.unity.dependencies": "1.1.3" + "com.reown.core.common": "1.1.4", + "com.reown.core.network": "1.1.4", + "com.reown.core.storage": "1.1.4", + "com.reown.core.crypto": "1.1.4", + "com.reown.unity.dependencies": "1.1.4" } }, "com.reown.core.common": { @@ -58,10 +58,10 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.core.common": "1.1.3", - "com.reown.core.network": "1.1.3", - "com.reown.core.storage": "1.1.3", - "com.reown.unity.dependencies": "1.1.3" + "com.reown.core.common": "1.1.4", + "com.reown.core.network": "1.1.4", + "com.reown.core.storage": "1.1.4", + "com.reown.unity.dependencies": "1.1.4" } }, "com.reown.core.network": { @@ -69,7 +69,7 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.core.common": "1.1.3" + "com.reown.core.common": "1.1.4" } }, "com.reown.core.storage": { @@ -77,7 +77,7 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.core.common": "1.1.3" + "com.reown.core.common": "1.1.4" } }, "com.reown.sign": { @@ -85,7 +85,7 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.core": "1.1.3" + "com.reown.core": "1.1.4" } }, "com.reown.sign.nethereum": { @@ -93,7 +93,7 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.sign": "1.1.3", + "com.reown.sign": "1.1.4", "com.nethereum.unity": "4.26.0" } }, @@ -102,8 +102,8 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.sign.nethereum": "1.1.3", - "com.reown.sign.unity": "1.1.3" + "com.reown.sign.nethereum": "1.1.4", + "com.reown.sign.unity": "1.1.4" } }, "com.reown.sign.unity": { @@ -111,7 +111,7 @@ "depth": 0, "source": "local", "dependencies": { - "com.reown.sign": "1.1.3" + "com.reown.sign": "1.1.4" } }, "com.reown.unity.dependencies": { diff --git a/sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset b/sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset index 6921cf0..930e0a8 100644 --- a/sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset +++ b/sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset @@ -140,7 +140,7 @@ PlayerSettings: loadStoreDebugModeEnabled: 0 visionOSBundleVersion: 1.0 tvOSBundleVersion: 1.0 - bundleVersion: 1.1.3 + bundleVersion: 1.1.4 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 diff --git a/src/Reown.AppKit.Unity/Runtime/AppKit.cs b/src/Reown.AppKit.Unity/Runtime/AppKit.cs index ced3208..100d5a9 100644 --- a/src/Reown.AppKit.Unity/Runtime/AppKit.cs +++ b/src/Reown.AppKit.Unity/Runtime/AppKit.cs @@ -10,7 +10,7 @@ namespace Reown.AppKit.Unity public abstract class AppKit : MonoBehaviour { [VersionMarker] - public const string Version = "unity-appkit-v1.1.2"; + public const string Version = "unity-appkit-v1.1.4"; public static AppKit Instance { get; protected set; } diff --git a/src/Reown.AppKit.Unity/package.json b/src/Reown.AppKit.Unity/package.json index c018863..c589cf0 100644 --- a/src/Reown.AppKit.Unity/package.json +++ b/src/Reown.AppKit.Unity/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.appkit.unity", - "version": "1.1.3", + "version": "1.1.4", "displayName": "Reown.AppKit.Unity", "unity": "2022.3", "author": "Reown", @@ -12,10 +12,10 @@ "web3" ], "dependencies": { - "com.reown.sign.nethereum.unity": "1.1.3", - "com.reown.sign.unity": "1.1.3", - "com.reown.core": "1.1.3", - "com.reown.unity.dependencies": "1.1.3", + "com.reown.sign.nethereum.unity": "1.1.4", + "com.reown.sign.unity": "1.1.4", + "com.reown.core": "1.1.4", + "com.reown.unity.dependencies": "1.1.4", "com.unity.vectorgraphics": "2.0.0-preview.24" } } \ No newline at end of file diff --git a/src/Reown.Core.Common/package.json b/src/Reown.Core.Common/package.json index 6b01496..bf848cb 100644 --- a/src/Reown.Core.Common/package.json +++ b/src/Reown.Core.Common/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.core.common", - "version": "1.1.3", + "version": "1.1.4", "displayName": "Reown.Core.Common", "unity": "2022.3", "author": "Reown", diff --git a/src/Reown.Core.Crypto/package.json b/src/Reown.Core.Crypto/package.json index f90cd5c..9fb5769 100644 --- a/src/Reown.Core.Crypto/package.json +++ b/src/Reown.Core.Crypto/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.core.crypto", - "version": "1.1.3", + "version": "1.1.4", "displayName": "Reown.Core.Crypto", "unity": "2022.3", "author": "Reown", @@ -8,9 +8,9 @@ "reown" ], "dependencies": { - "com.reown.core.common": "1.1.3", - "com.reown.core.network": "1.1.3", - "com.reown.core.storage": "1.1.3", - "com.reown.unity.dependencies": "1.1.3" + "com.reown.core.common": "1.1.4", + "com.reown.core.network": "1.1.4", + "com.reown.core.storage": "1.1.4", + "com.reown.unity.dependencies": "1.1.4" } } \ No newline at end of file diff --git a/src/Reown.Core.Network/package.json b/src/Reown.Core.Network/package.json index 73c6cc5..4f638ed 100644 --- a/src/Reown.Core.Network/package.json +++ b/src/Reown.Core.Network/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.core.network", - "version": "1.1.3", + "version": "1.1.4", "displayName": "Reown.Core.Network", "unity": "2022.3", "author": "Reown", @@ -8,6 +8,6 @@ "reown" ], "dependencies": { - "com.reown.core.common": "1.1.3" + "com.reown.core.common": "1.1.4" } } \ No newline at end of file diff --git a/src/Reown.Core.Storage/package.json b/src/Reown.Core.Storage/package.json index 29a9736..33ced34 100644 --- a/src/Reown.Core.Storage/package.json +++ b/src/Reown.Core.Storage/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.core.storage", - "version": "1.1.3", + "version": "1.1.4", "displayName": "Reown.Core.Storage", "unity": "2022.3", "author": "Reown", @@ -8,6 +8,6 @@ "reown" ], "dependencies": { - "com.reown.core.common": "1.1.3" + "com.reown.core.common": "1.1.4" } } \ No newline at end of file diff --git a/src/Reown.Core/package.json b/src/Reown.Core/package.json index 23a2ac6..e98d350 100644 --- a/src/Reown.Core/package.json +++ b/src/Reown.Core/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.core", - "version": "1.1.3", + "version": "1.1.4", "displayName": "Reown.Core", "unity": "2022.3", "author": "Reown", @@ -8,10 +8,10 @@ "reown" ], "dependencies": { - "com.reown.core.common": "1.1.3", - "com.reown.core.network": "1.1.3", - "com.reown.core.storage": "1.1.3", - "com.reown.core.crypto": "1.1.3", - "com.reown.unity.dependencies": "1.1.3" + "com.reown.core.common": "1.1.4", + "com.reown.core.network": "1.1.4", + "com.reown.core.storage": "1.1.4", + "com.reown.core.crypto": "1.1.4", + "com.reown.unity.dependencies": "1.1.4" } } \ No newline at end of file diff --git a/src/Reown.Sign.Nethereum.Unity/package.json b/src/Reown.Sign.Nethereum.Unity/package.json index 940a3c7..323c1f4 100644 --- a/src/Reown.Sign.Nethereum.Unity/package.json +++ b/src/Reown.Sign.Nethereum.Unity/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.sign.nethereum.unity", - "version": "1.1.3", + "version": "1.1.4", "displayName": "Reown.Sign.Nethereum.Unity", "unity": "2022.3", "author": "Reown", @@ -9,7 +9,7 @@ "walletconnect" ], "dependencies": { - "com.reown.sign.nethereum": "1.1.3", - "com.reown.sign.unity": "1.1.3" + "com.reown.sign.nethereum": "1.1.4", + "com.reown.sign.unity": "1.1.4" } } \ No newline at end of file diff --git a/src/Reown.Sign.Nethereum/package.json b/src/Reown.Sign.Nethereum/package.json index 7cc3639..2b06040 100644 --- a/src/Reown.Sign.Nethereum/package.json +++ b/src/Reown.Sign.Nethereum/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.sign.nethereum", - "version": "1.1.3", + "version": "1.1.4", "displayName": "Reown.Sign.Nethereum", "unity": "2022.3", "author": "Reown", @@ -9,7 +9,7 @@ "walletconnect" ], "dependencies": { - "com.reown.sign": "1.1.3", + "com.reown.sign": "1.1.4", "com.nethereum.unity": "4.26.0" } } \ No newline at end of file diff --git a/src/Reown.Sign.Unity/Runtime/SignMetadata.cs b/src/Reown.Sign.Unity/Runtime/SignMetadata.cs index 3c0faef..574f020 100644 --- a/src/Reown.Sign.Unity/Runtime/SignMetadata.cs +++ b/src/Reown.Sign.Unity/Runtime/SignMetadata.cs @@ -5,6 +5,6 @@ namespace Reown.Sign.Unity public class SignMetadata { [VersionMarker] - public const string Version = "v1.1.2"; + public const string Version = "v1.1.4"; } } \ No newline at end of file diff --git a/src/Reown.Sign.Unity/package.json b/src/Reown.Sign.Unity/package.json index 5447068..e8e9d0a 100644 --- a/src/Reown.Sign.Unity/package.json +++ b/src/Reown.Sign.Unity/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.sign.unity", - "version": "1.1.3", + "version": "1.1.4", "displayName": "Reown.Sign.Unity", "unity": "2022.3", "author": "Reown", @@ -9,6 +9,6 @@ "walletconnect" ], "dependencies": { - "com.reown.sign": "1.1.3" + "com.reown.sign": "1.1.4" } } \ No newline at end of file diff --git a/src/Reown.Sign/package.json b/src/Reown.Sign/package.json index e52aaf0..3313360 100644 --- a/src/Reown.Sign/package.json +++ b/src/Reown.Sign/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.sign", - "version": "1.1.3", + "version": "1.1.4", "displayName": "Reown.Sign", "unity": "2022.3", "author": "Reown", @@ -8,6 +8,6 @@ "reown" ], "dependencies": { - "com.reown.core": "1.1.3" + "com.reown.core": "1.1.4" } } \ No newline at end of file diff --git a/src/Reown.Unity.Dependencies/package.json b/src/Reown.Unity.Dependencies/package.json index 0d0de50..a12dd6f 100644 --- a/src/Reown.Unity.Dependencies/package.json +++ b/src/Reown.Unity.Dependencies/package.json @@ -1,6 +1,6 @@ { "name": "com.reown.unity.dependencies", - "version": "1.1.3", + "version": "1.1.4", "displayName": "Reown.Unity.Dependencies", "unity": "2022.3", "author": "Reown", From 63530c0e6eb830e8fa069f3cfb4c285cf0ce6d38 Mon Sep 17 00:00:00 2001 From: skibitsky Date: Fri, 20 Dec 2024 15:07:53 +0200 Subject: [PATCH 10/11] Unity packages release job --- .github/scripts/get-unity-package-names.csx | 21 ++++ .github/workflows/dotnet-build-test.yml | 5 +- .github/workflows/release.yml | 101 ++++++++++++++++++-- 3 files changed, 116 insertions(+), 11 deletions(-) create mode 100644 .github/scripts/get-unity-package-names.csx diff --git a/.github/scripts/get-unity-package-names.csx b/.github/scripts/get-unity-package-names.csx new file mode 100644 index 0000000..7236928 --- /dev/null +++ b/.github/scripts/get-unity-package-names.csx @@ -0,0 +1,21 @@ +#!/usr/bin/env dotnet-script + +#r "nuget: Newtonsoft.Json, 13.0.0" + +using Newtonsoft.Json.Linq; + +var srcPath = Path.GetFullPath("src"); +var packages = Directory.EnumerateFiles(srcPath, "package.json", SearchOption.AllDirectories) + .Select(file => + { + var content = File.ReadAllText(file); + var json = JObject.Parse(content); + return json["name"]?.ToString(); + }) + .Where(name => !string.IsNullOrEmpty(name)) + .ToList(); + +foreach (var package in packages) +{ + Console.WriteLine(package); +} \ No newline at end of file diff --git a/.github/workflows/dotnet-build-test.yml b/.github/workflows/dotnet-build-test.yml index 7e10857..32320b8 100644 --- a/.github/workflows/dotnet-build-test.yml +++ b/.github/workflows/dotnet-build-test.yml @@ -2,7 +2,7 @@ name: .NET Build & Test on: push: - branches: [ main ] + branches: [ develop ] pull_request: workflow_dispatch: @@ -10,7 +10,8 @@ jobs: test: strategy: matrix: - os: [ubuntu-latest, windows-latest] + # os: [ubuntu-latest, windows-latest] + os: [windows-latest] dotnet-version: [8.0.x] test-type: [unit-tests, integration-tests] runs-on: ${{ matrix.os }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1ef256f..0119e29 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,13 +1,48 @@ name: Release on: - release: - types: [published] + push: + branches: + - main + paths-ignore: + - '**.md' + - '.gitignore' + - '.editorconfig' workflow_dispatch: - pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + + - name: Run unit tests + uses: ./.github/actions/test-dotnet + with: + type: unit-tests + project-id: ${{ secrets.PROJECT_ID }} + dotnet-version: '8.0' + + - name: Run integration tests + uses: ./.github/actions/test-dotnet + with: + type: integration-tests + project-id: ${{ secrets.PROJECT_ID }} + dotnet-version: '8.0' + nuget: + needs: test runs-on: ubuntu-latest timeout-minutes: 15 steps: @@ -20,17 +55,19 @@ jobs: dotnet-version: | 8.0.x + - name: Install dotnet-script + run: | + dotnet tool install -g dotnet-script + echo "$HOME/.dotnet/tools" >> $GITHUB_PATH + - name: Build Release run: dotnet build Reown.NoUnity.slnf -c Release --restore - name: Pack nugets run: dotnet pack Reown.NoUnity.slnf -c Release --no-build --output . - - - name: List files - run: tree -L 3 -# - name: Push to NuGet -# run: dotnet nuget push "*.nupkg" --api-key ${{secrets.nuget_api_key}} --source https://api.nuget.org/v3/index.json + - name: Push to NuGet + run: dotnet nuget push "*.nupkg" --api-key ${{secrets.nuget_api_key}} --source https://api.nuget.org/v3/index.json - name: Upload build artifacts uses: actions/upload-artifact@v3 @@ -38,4 +75,50 @@ jobs: name: build-artifacts path: | **/bin/**/*.dll - !**/Tests/**/bin/**/*.dll \ No newline at end of file + !**/test/**/bin/**/*.dll + + unity: + needs: test + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 8.0.x + + - name: Install dotnet-script + run: | + dotnet tool install -g dotnet-script + echo "$HOME/.dotnet/tools" >> $GITHUB_PATH + + - name: Configure Git + run: | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + + - name: Create git tags + run: | + set -e + VERSION=$(dotnet-script ./.github/scripts/get-version.csx) + if [ -z "$VERSION" ]; then + echo "Error: Version script returned empty value" + exit 1 + fi + echo "Creating tags for version $VERSION" + + dotnet-script ./.github/scripts/get-unity-package-names.csx | while read -r package; do + TAG="$package/$VERSION" + echo "Creating tag $TAG" + git tag -a "$TAG" -m "Release $package version $VERSION" + done + + - name: Push tags + run: git push origin --tags \ No newline at end of file From 110f4d8cc7f5b1215e64b890ac431982deedb7f7 Mon Sep 17 00:00:00 2001 From: skibitsky Date: Fri, 20 Dec 2024 15:15:01 +0200 Subject: [PATCH 11/11] Fix failing unity version sync workflow --- .github/workflows/sync-unity-package-version.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/sync-unity-package-version.yml b/.github/workflows/sync-unity-package-version.yml index c948169..2137445 100644 --- a/.github/workflows/sync-unity-package-version.yml +++ b/.github/workflows/sync-unity-package-version.yml @@ -35,7 +35,13 @@ jobs: - name: Sync Unity Package Version run: dotnet-script ./.github/scripts/sync-unity-version.csx + - name: Check for changes + id: git-check + run: | + git diff --quiet || echo "changes=true" >> $GITHUB_OUTPUT + - name: Commit changes + if: steps.git-check.outputs.changes == 'true' run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com'