Exemplo n.º 1
0
        IEnumerator Distribute(BuildPath buildPath)
        {
            Debug.Log("ItchDistro: Pushing " + buildPath.target);

            var path = OptionHelper.GetBuildBasePath(buildPath.path);

            var channel = ChannelNames[buildPath.target];

            if (!string.IsNullOrEmpty(channelSuffix))
            {
                channel += "-" + channelSuffix;
            }

            var version = Application.version;

            var buildInfo = BuildInfo.FromPath(path);

            if (buildInfo != null)
            {
                if (!buildInfo.version.IsDefined)
                {
                    Debug.LogWarning("ItchDistro: build.json exists but contains no version.");
                }
                else
                {
                    version = buildInfo.version.MajorMinorPatchBuild;
                }
            }

            var args = string.Format(
                "push '{0}' '{1}:{2}' --userversion '{3}' --ignore='*.DS_Store' --ignore='build.json'",
                path, project, channel, Application.version
                );

            yield return(Execute(butlerPath, args));

            var exitcode = GetSubroutineResult <int>();

            yield return(exitcode == 0);
        }
Exemplo n.º 2
0
        async Task Distribute(BuildPath buildPath, TaskToken task)
        {
            task.Report(0, description: $"Pushing {buildPath.target}");

            var path = OptionHelper.GetBuildBasePath(buildPath.path);

            var channel = ChannelNames[buildPath.target];

            if (!string.IsNullOrEmpty(channelSuffix))
            {
                channel += "-" + channelSuffix;
            }

            var version = Application.version;

            var buildInfo = BuildInfo.FromPath(path);

            if (buildInfo != null)
            {
                if (!buildInfo.version.IsDefined)
                {
                    Debug.LogWarning("ItchDistro: build.json exists but contains no version.");
                }
                else
                {
                    version = buildInfo.version.MajorMinorPatchBuild;
                }
            }

            var args = string.Format(
                "push '{0}' '{1}:{2}' --userversion '{3}' --ignore='*.DS_Store' --ignore='build.json'",
                path, project, channel, Application.version
                );

            await Execute(new ExecutionArgs(butlerPath, args), task);
        }
Exemplo n.º 3
0
        protected IEnumerator Zip(BuildPath buildPath)
        {
            var target = buildPath.target;
            var path   = buildPath.path;

            if (!File.Exists(path) && !Directory.Exists(path))
            {
                Debug.LogError("ZipDistro: Path to compress does not exist: " + path);
                yield return(null); yield break;
            }

            if (ZipIgnorePatterns == null)
            {
                ZipIgnorePatterns = new Regex[ZipIgnore.Length];
                for (int i = 0; i < ZipIgnore.Length; i++)
                {
                    var regex = Regex.Escape(ZipIgnore[i]).Replace(@"\*", ".*").Replace(@"\?", ".");
                    ZipIgnorePatterns[i] = new Regex(regex);
                }
            }

            var sevenZPath = Get7ZipPath();

            if (sevenZPath == null)
            {
                yield return(null); yield break;
            }

            // Path can point to executable file but there might be files
            // in the containing directory we need as well
            var basePath = OptionHelper.GetBuildBasePath(path);

            // Check the files in containing directory
            var files = new List <string>(Directory.GetFileSystemEntries(basePath));

            for (int i = files.Count - 1; i >= 0; i--)
            {
                var filename = Path.GetFileName(files[i]);
                foreach (var pattern in ZipIgnorePatterns)
                {
                    if (pattern.IsMatch(filename))
                    {
                        files.RemoveAt(i);
                        goto ContinueOuter;
                    }
                }
                ContinueOuter :;
            }

            if (files.Count == 0)
            {
                Debug.LogError("ZipDistro: Nothing to ZIP in directory: " + basePath);
                yield return(null); yield break;
            }

            // Determine output path first to make it consistent and use absolute path
            // since the script will be run in a different working directory
            var prettyName = GetPrettyName(target);

            if (prettyName == null)
            {
                prettyName = Path.GetFileNameWithoutExtension(basePath);
            }

            var versionSuffix = "";

            if (appendVersion)
            {
                var buildInfo = BuildInfo.FromPath(path);
                if (buildInfo != null)
                {
                    if (!buildInfo.version.IsDefined)
                    {
                        Debug.LogWarning("ZipDistro: build.json exists but contains no version");
                    }
                    else
                    {
                        versionSuffix = " " + buildInfo.version.MajorMinorPatch;
                    }
                }

                if (versionSuffix.Length == 0)
                {
                    versionSuffix = " " + Application.version;
                }
            }

            var extension = FileExtensions[(int)format];
            var zipName   = prettyName + versionSuffix + extension;

            zipName = zipName.Replace(" ", "_");

            var outputPath = Path.Combine(Path.GetDirectoryName(basePath), zipName);

            outputPath = Path.GetFullPath(outputPath);

            // Delete existing archive, otherwise 7za will update it
            if (File.Exists(outputPath))
            {
                File.Delete(outputPath);
            }

            // In case it only contains a single file, just zip that file
            var singleFile = false;

            if (files.Count == 1)
            {
                singleFile = true;
                basePath   = files[0];
            }

            // Run 7za command to create ZIP file
            var excludes = "";

            foreach (var pattern in ZipIgnore)
            {
                excludes += @" -xr\!'" + pattern + "'";
            }

            var inputName = Path.GetFileName(basePath);
            var args      = string.Format(
                "a '{0}' '{1}' -r -mx{2} {3}",
                outputPath, inputName, (int)compression, excludes
                );

            var startInfo = new System.Diagnostics.ProcessStartInfo();

            startInfo.FileName         = sevenZPath;
            startInfo.Arguments        = args;
            startInfo.WorkingDirectory = Path.GetDirectoryName(basePath);

            Debug.Log("ZipDistro: Archiving " + inputName);
            yield return(Execute(startInfo));

            var exitcode = GetSubroutineResult <int>();

            if (exitcode != 0)
            {
                yield return(null); yield break;
            }

            if (!singleFile && prettyName != inputName)
            {
                yield return(RenameRoot(outputPath, inputName, prettyName));

                var success = GetSubroutineResult <bool>();
                if (!success)
                {
                    yield return(null); yield break;
                }
            }

            Debug.Log("ZipDistro: Archived to: " + outputPath);
            yield return(new BuildPath(target, outputPath));
        }