diff --git a/.github/workflows/build-debug.yml b/.github/workflows/build-debug.yml new file mode 100644 index 0000000..c558169 --- /dev/null +++ b/.github/workflows/build-debug.yml @@ -0,0 +1,65 @@ +name: Build-Debug + +on: + push: + branches: + - "master" + tags: + - "!*" # not a tag push + pull_request: + branches: + - master + +jobs: + build-dotnet: + runs-on: ubuntu-latest + env: + DOTNET_SDK_VERSION: "6.0.x" + DOTNET_INCLUDE_PRERELEASE: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + NUGET_XMLDOC_MODE: skip + steps: + - uses: actions/checkout@v2 + - run: dotnet build -c Debug + - run: dotnet test -c Debug --no-build < /dev/null + + build-unity: + if: "((github.event_name == 'push' && github.repository_owner == 'Cysharp') || startsWith(github.event.pull_request.head.label, 'Cysharp:'))" + strategy: + matrix: + unity: ["2020.1.0a3"] + include: + - unity: 2020.1.0a3 + license: UNITY_LICENSE_2020 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + # Execute scripts: Export Package + # /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export + - name: Export unitypackage + uses: game-ci/unity-builder@v2.0-alpha-6 + env: + UNITY_LICENSE: ${{ secrets[matrix.license] }} + with: + projectPath: src/ObservableCollections.Unity + unityVersion: ${{ matrix.unity }} + targetPlatform: StandaloneLinux64 + buildMethod: PackageExporter.Export + versioning: None + + - name: check all .meta is commited + run: | + if git ls-files --others --exclude-standard -t | grep --regexp='[.]meta$'; then + echo "Detected .meta file generated. Do you forgot commit a .meta file?" + exit 1 + else + echo "Great, all .meta files are commited." + fi + working-directory: src/ObservableCollections.Unity + + # Store artifacts. + - uses: actions/upload-artifact@v2 + with: + name: ObservableCollections.unitypackage-${{ matrix.unity }}.zip + path: ./src/ObservableCollections.Unity/*.unitypackage \ No newline at end of file diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 0000000..c21e217 --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,251 @@ +name: build-release + +on: + workflow_dispatch: + inputs: + tag: + description: "tag: git tag you want create. (sample 1.0.0)" + required: true + dry_run: + description: "dry_run: true will never create relase/nuget." + required: true + default: "false" + +env: + GIT_TAG: ${{ github.event.inputs.tag }} + DRY_RUN: ${{ github.event.inputs.dry_run }} + DRY_RUN_BRANCH_PREFIX: "test_release" + +jobs: + update-packagejson: + runs-on: ubuntu-latest + env: + TARGET_FILE: ./src/MessagePipe.Unity/Assets/Plugins/MessagePipe/package.json + TARGET_FILE2: ./src/MessagePipe.Unity/Assets/Plugins/MessagePipe.VContainer/package.json + TARGET_FILE3: ./src/MessagePipe.Unity/Assets/Plugins/MessagePipe.Zenject/package.json + TARGET_FILE4: ./src/MessagePipe.Unity/Assets/Plugins/MessagePipe.Interprocess/package.json + outputs: + sha: ${{ steps.commit.outputs.sha }} + steps: + - uses: actions/checkout@v2 + - name: Output package.json (Before) + run: | + cat ${{ env.TARGET_FILE}} + cat ${{ env.TARGET_FILE2}} + cat ${{ env.TARGET_FILE3}} + cat ${{ env.TARGET_FILE4}} + + - name: Update package.json to version ${{ env.GIT_TAG }} + run: | + sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ env.GIT_TAG }}\",/" ${{ env.TARGET_FILE }} + sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ env.GIT_TAG }}\",/" ${{ env.TARGET_FILE2 }} + sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ env.GIT_TAG }}\",/" ${{ env.TARGET_FILE3 }} + sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ env.GIT_TAG }}\",/" ${{ env.TARGET_FILE4 }} + + - name: Check update + id: check_update + run: | + cat ${{ env.TARGET_FILE}} + cat ${{ env.TARGET_FILE2}} + cat ${{ env.TARGET_FILE3}} + cat ${{ env.TARGET_FILE4}} + git diff --exit-code || echo "::set-output name=changed::1" + + - name: Commit files + id: commit + if: steps.check_update.outputs.changed == '1' + run: | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git commit -m "feat: Update package.json to ${{ env.GIT_TAG }}" -a + echo "::set-output name=sha::$(git rev-parse HEAD)" + + - name: Check sha + run: echo "SHA ${SHA}" + env: + SHA: ${{ steps.commit.outputs.sha }} + + - name: Create Tag + if: steps.check_update.outputs.changed == '1' + run: git tag ${{ env.GIT_TAG }} + + - name: Push changes + if: env.DRY_RUN == 'false' && steps.check_update.outputs.changed == '1' + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} + tags: true + + - name: Push changes (dry_run) + if: env.DRY_RUN == 'true' && steps.check_update.outputs.changed == '1' + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ env.DRY_RUN_BRANCH_PREFIX }}-${{ env.GIT_TAG }} + tags: false + + build-dotnet: + needs: [update-packagejson] + runs-on: ubuntu-latest + timeout-minutes: 10 + env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + NUGET_XMLDOC_MODE: skip + services: + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 6379:6379 + steps: + - run: echo ${{ needs.update-packagejson.outputs.sha }} + - uses: actions/checkout@v2 + with: + ref: ${{ needs.update-packagejson.outputs.sha }} + # build and pack + - run: dotnet build ./tools/PostBuildUtility/ -c Release + - run: dotnet build -c Release -p:Version=${{ env.GIT_TAG }} + - run: dotnet test -c Release --no-build + - run: dotnet pack ./src/MessagePipe/MessagePipe.csproj -c Release --no-build -p:Version=${{ env.GIT_TAG }} -o ./publish + - run: dotnet pack ./src/MessagePipe.Analyzer/MessagePipe.Analyzer.csproj -c Release --no-build -p:Version=${{ env.GIT_TAG }} -o ./publish + - run: dotnet pack ./src/MessagePipe.Redis/MessagePipe.Redis.csproj -c Release --no-build -p:Version=${{ env.GIT_TAG }} -o ./publish + - run: dotnet pack ./src/MessagePipe.Interprocess/MessagePipe.Interprocess.csproj -c Release --no-build -p:Version=${{ env.GIT_TAG }} -o ./publish + # Store artifacts. + - uses: actions/upload-artifact@v2 + with: + name: nuget + path: ./publish/ + if-no-files-found: error + # Upload analyzer. + - uses: actions/upload-artifact@v2 + with: + name: MessagePipe.Analyzer + path: ./src/MessagePipe.Analyzer/bin/Release/netstandard2.0/MessagePipe.Analyzer.dll + + build-unity: + needs: [update-packagejson] + strategy: + matrix: + unity: ["2019.3.9f1"] + include: + - unity: 2019.3.9f1 + license: UNITY_LICENSE_2019 + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - run: echo ${{ needs.update-packagejson.outputs.sha }} + - uses: actions/checkout@v2 + with: + ref: ${{ needs.update-packagejson.outputs.sha }} + # Execute scripts: Export Package + # /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export + - name: Export unitypackage + uses: game-ci/unity-builder@v2.0-alpha-6 + env: + UNITY_LICENSE: ${{ secrets[matrix.license] }} + with: + projectPath: src/MessagePipe.Unity + unityVersion: ${{ matrix.unity }} + targetPlatform: StandaloneLinux64 + buildMethod: PackageExporter.Export + versioning: None + + - name: check all .meta is commited + run: | + if git ls-files --others --exclude-standard -t | grep --regexp='[.]meta$'; then + echo "Detected .meta file generated. Do you forgot commit a .meta file?" + exit 1 + else + echo "Great, all .meta files are commited." + fi + working-directory: src/MessagePipe.Unity + + # Store artifacts. + - uses: actions/upload-artifact@v2 + with: + name: MessagePipe.Unity.${{ env.GIT_TAG }}.unitypackage + path: ./src/MessagePipe.Unity/MessagePipe*.${{ env.GIT_TAG }}.unitypackage + if-no-files-found: error + + create-release: + if: github.event.inputs.dry_run == 'false' + needs: [update-packagejson, build-dotnet, build-unity] + runs-on: ubuntu-latest + env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + NUGET_XMLDOC_MODE: skip + steps: + # Create Releases + - uses: actions/create-release@v1 + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.GIT_TAG }} + release_name: Ver.${{ env.GIT_TAG }} + commitish: ${{ needs.update-packagejson.outputs.sha }} + draft: true + prerelease: false + # Download(All) Artifacts to current directory + - uses: actions/download-artifact@v2 + # Upload to NuGet + - run: dotnet nuget push "./nuget/*.nupkg" --skip-duplicate -s https://www.nuget.org/api/v2/package -k ${{ secrets.NUGET_KEY }} + # Upload to Releases(unitypackage) + - uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./MessagePipe.Analyzer/MessagePipe.Analyzer.dll + asset_name: MessagePipe.Analyzer.dll + asset_content_type: application/octet-stream + - uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./MessagePipe.Unity.${{ env.GIT_TAG }}.unitypackage/MessagePipe.${{ env.GIT_TAG }}.unitypackage + asset_name: MessagePipe.${{ env.GIT_TAG }}.unitypackage + asset_content_type: application/octet-stream + - uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./MessagePipe.Unity.${{ env.GIT_TAG }}.unitypackage/MessagePipe.VContainer.${{ env.GIT_TAG }}.unitypackage + asset_name: MessagePipe.VContainer.${{ env.GIT_TAG }}.unitypackage + asset_content_type: application/octet-stream + - uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./MessagePipe.Unity.${{ env.GIT_TAG }}.unitypackage/MessagePipe.Zenject.${{ env.GIT_TAG }}.unitypackage + asset_name: MessagePipe.Zenject.${{ env.GIT_TAG }}.unitypackage + asset_content_type: application/octet-stream + - uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./MessagePipe.Unity.${{ env.GIT_TAG }}.unitypackage/MessagePipe.Interprocess.${{ env.GIT_TAG }}.unitypackage + asset_name: MessagePipe.Interprocess.${{ env.GIT_TAG }}.unitypackage + asset_content_type: application/octet-stream + + cleanup: + if: github.event.inputs.dry_run == 'true' + needs: [build-dotnet, build-unity] + runs-on: ubuntu-latest + steps: + - name: Delete branch + uses: dawidd6/action-delete-branch@v3 + with: + github_token: ${{ github.token }} + branches: ${{ env.DRY_RUN_BRANCH_PREFIX }}-${{ env.GIT_TAG }} diff --git a/src/ObservableCollections.Unity/Assets/Editor.meta b/src/ObservableCollections.Unity/Assets/Editor.meta new file mode 100644 index 0000000..1549767 --- /dev/null +++ b/src/ObservableCollections.Unity/Assets/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 23bde05b5e9d4d049a38c4edf79f9ac6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/ObservableCollections.Unity/Assets/Editor/PackageExporter.cs b/src/ObservableCollections.Unity/Assets/Editor/PackageExporter.cs new file mode 100644 index 0000000..c262edc --- /dev/null +++ b/src/ObservableCollections.Unity/Assets/Editor/PackageExporter.cs @@ -0,0 +1,78 @@ +#if UNITY_EDITOR + +using System; +using System.IO; +using System.Linq; +using UnityEditor; +using UnityEngine; + +public static class PackageExporter +{ + [MenuItem("Tools/Export Unitypackage")] + public static void Export() + { + var roots = new[] { "Plugins/ObservableCollections" }; + + foreach (var root in roots) + { + var version = GetVersion(root); + var fn = root.Split('/').Last(); + + var fileName = string.IsNullOrEmpty(version) ? $"{fn}.unitypackage" : $"{fn}.{version}.unitypackage"; + var exportPath = "./" + fileName; + + var path = Path.Combine(Application.dataPath, root); + var assets = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories) + .Where(x => Path.GetExtension(x) == ".cs" || Path.GetExtension(x) == ".asmdef" || Path.GetExtension(x) == ".json" || Path.GetExtension(x) == ".meta") + .Select(x => "Assets" + x.Replace(Application.dataPath, "").Replace(@"\", "/")) + .ToArray(); + + UnityEngine.Debug.Log("Export below files" + Environment.NewLine + string.Join(Environment.NewLine, assets)); + + AssetDatabase.ExportPackage( + assets, + exportPath, + ExportPackageOptions.Default); + + UnityEngine.Debug.Log("Export complete: " + Path.GetFullPath(exportPath)); + } + } + + static string GetVersion(string root) + { + var version = Environment.GetEnvironmentVariable("UNITY_PACKAGE_VERSION"); + var versionJson = Path.Combine(Application.dataPath, root, "package.json"); + + if (File.Exists(versionJson)) + { + var v = JsonUtility.FromJson(File.ReadAllText(versionJson)); + + if (!string.IsNullOrEmpty(version)) + { + if (v.version != version) + { + var msg = $"package.json and env version are mismatched. UNITY_PACKAGE_VERSION:{version}, package.json:{v.version}"; + + if (Application.isBatchMode) + { + Console.WriteLine(msg); + Application.Quit(1); + } + + throw new Exception("package.json and env version are mismatched."); + } + } + + version = v.version; + } + + return version; + } + + public class Version + { + public string version; + } +} + +#endif \ No newline at end of file diff --git a/src/ObservableCollections.Unity/Assets/Editor/PackageExporter.cs.meta b/src/ObservableCollections.Unity/Assets/Editor/PackageExporter.cs.meta new file mode 100644 index 0000000..6933413 --- /dev/null +++ b/src/ObservableCollections.Unity/Assets/Editor/PackageExporter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 34885e00b06e4c847b8e2958ebb2d26b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/ObservableCollections.Unity/Assets/Plugins/ObservableCollections/Runtime/ObservableCollections.asmdef b/src/ObservableCollections.Unity/Assets/Plugins/ObservableCollections/Runtime/ObservableCollections.asmdef new file mode 100644 index 0000000..d241352 --- /dev/null +++ b/src/ObservableCollections.Unity/Assets/Plugins/ObservableCollections/Runtime/ObservableCollections.asmdef @@ -0,0 +1,18 @@ +{ + "name": "ObservableCollections", + "rootNamespace": "ObservableCollections", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "System.Memory.dll", + "System.Buffers.dll", + "System.Runtime.CompilerServices.Unsafe.dll" + ], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": true +} \ No newline at end of file diff --git a/src/ObservableCollections.Unity/Assets/Plugins/ObservableCollections/Runtime/ObservableCollections.asmdef.meta b/src/ObservableCollections.Unity/Assets/Plugins/ObservableCollections/Runtime/ObservableCollections.asmdef.meta new file mode 100644 index 0000000..c0b1250 --- /dev/null +++ b/src/ObservableCollections.Unity/Assets/Plugins/ObservableCollections/Runtime/ObservableCollections.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a25f8e99c4faa4b4a8c38f41a406f5d3 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/ObservableCollections.Unity/Assets/Plugins/ObservableCollections/package.json b/src/ObservableCollections.Unity/Assets/Plugins/ObservableCollections/package.json new file mode 100644 index 0000000..31da102 --- /dev/null +++ b/src/ObservableCollections.Unity/Assets/Plugins/ObservableCollections/package.json @@ -0,0 +1,12 @@ +{ + "name": "com.cysharp.observablecollections", + "displayName": "ObservableCollections", + "author": { "name": "Cysharp, Inc.", "url": "https://cysharp.co.jp/en/" }, + "version": "1.0.0", + "unity": "2018.4", + "description": "High performance observable collections and synchronized views.", + "keywords": [ "Scripting", "DI" ], + "license": "MIT", + "category": "Scripting", + "dependencies": {} +} diff --git a/src/ObservableCollections.Unity/Assets/Plugins/ObservableCollections/package.json.meta b/src/ObservableCollections.Unity/Assets/Plugins/ObservableCollections/package.json.meta new file mode 100644 index 0000000..d6013ef --- /dev/null +++ b/src/ObservableCollections.Unity/Assets/Plugins/ObservableCollections/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 142803aeb06678d4faef8b76468c110b +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: