示例#1
0
        internal static void Pack(PackageManifest manifest)
        {
            try
            {
                // Make sure the version information is updated before publishing
                VersionMaintainer.UpdateVersionInformation(true);

                CopySamples(manifest);
                manifest.OnAfterDeserialize();
                string packageFolder = Path.Combine(AssetDatabaseUtilities.GetRelativeToProjectRoot(Paths.PackagesFolder), manifest.package_name);


                string folder = FileUtil.GetUniqueTempPathInProject();


                try
                {
                    string tarballPath = PackageTarball.Create(packageFolder, folder);
                    EditorUtility.RevealInFinder(tarballPath);
                }
                catch (Exception e)
                {
                    EditorUtility.DisplayDialog("Failure", e.Message, "OK");
                }
            }
            finally
            {
                EmptySamplesDirectory(manifest);
            }
        }
        internal static void SetGroupVersion(string version)
        {
            if (!IsValidVersion(version))
            {
                throw new System.Exception("Invalid semantic version (major.minor.patch) format");
            }

            PackageGroupConfigurationDescription desc = new PackageGroupConfigurationDescription();

            desc.groupVersion    = version;
            desc.useGroupVersion = true;

            File.WriteAllText(GetGroupConfigFile(), JsonUtility.ToJson(desc));

            VersionMaintainer.UpdateVersionInformation(true);
        }
示例#3
0
        void Publish()
        {
            if (PackagesToPublish != null)
            {
                // Make sure the version information is updated before publishing
                VersionMaintainer.UpdateVersionInformation(true);

                int packagesToPublish = 0;
                foreach (var packageView in PackagesToPublish)
                {
                    if (packageView.publish)
                    {
                        packagesToPublish++;
                    }
                }

                if (packagesToPublish == 0)
                {
                    EditorUtility.DisplayDialog("Error", "No packages to publish selected.", "OK");
                    return;
                }



                EditorUtility.DisplayProgressBar("Publishing package", "Publishing packages", 0f);

                string result         = "";
                int    currentPackage = 0;
                bool   failures       = false;
                try
                {
                    foreach (var packageView in PackagesToPublish)
                    {
                        if (packageView.publish)
                        {
                            EditorUtility.DisplayProgressBar("Publishing package", "Publishing packages " + packageView.package.displayName + " to " + packageView.registry, (float)currentPackage / (float)packagesToPublish);

                            if (string.IsNullOrEmpty(packageView.registry))
                            {
                                failures = true;
                                result  += "[Error] No registry set for " + packageView.package.displayName + Environment.NewLine;
                            }
                            else
                            {
                                try
                                {
                                    PublicationController.Publish(packageView.package, packageView.registry);
                                    result += "[Success] Publishing " + packageView.package.displayName + " succeeded." + Environment.NewLine;
                                }
                                catch (System.Exception e)
                                {
                                    failures = true;
                                    result  += "[Error] Publishing " + packageView.package.displayName + " failed with error:" + Environment.NewLine + "\t" + e.Message + Environment.NewLine;
                                }
                            }

                            currentPackage++;
                        }
                    }
                }
                finally
                {
                    EditorUtility.ClearProgressBar();
                }
                string message;
                if (failures)
                {
                    message = "Published with errors." + Environment.NewLine + result;
                }
                else
                {
                    message = "Published all packages. " + Environment.NewLine + result;
                }
                EditorUtility.DisplayDialog("Publishing finished", message, "OK");
            }
        }