From d98b2d9d3917b5fe8b913e8df963dfca876ec71a Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 2 Feb 2023 18:02:51 -0500 Subject: [PATCH] TEST: Add repo type --- .../nuget_publishing_with_repo_support.py | 29 +++++++++++++------ .../NugetPublishing/DebugConfig.yaml | 1 + .../NugetPublishing/ReleaseConfig.yaml | 1 + .../NugetPublishing/DebugConfig.yaml | 1 + .../NugetPublishing/ReleaseConfig.yaml | 1 + 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Platforms/QemuQ35Pkg/.azurepipelines/nuget_publishing_with_repo_support.py b/Platforms/QemuQ35Pkg/.azurepipelines/nuget_publishing_with_repo_support.py index 41ae7bca4c..de06815284 100644 --- a/Platforms/QemuQ35Pkg/.azurepipelines/nuget_publishing_with_repo_support.py +++ b/Platforms/QemuQ35Pkg/.azurepipelines/nuget_publishing_with_repo_support.py @@ -114,9 +114,9 @@ def FromConfigfile(self, filepath): with open(self.Config, "r") as c: self.ConfigData = yaml.safe_load(c) - def SetBasicData(self, authors, license, project, description, server, - copyright, repositoryUrl=None, repositoryBranch=None, - repositoryCommit=None): + def SetBasicData(self, authors, license, project, description, server, copyright, + repositoryType=None, repositoryUrl=None, repositoryBranch=None, + repositoryCommit=None): """Set basic data in the config data.""" self.ConfigData["author_string"] = authors if license: @@ -124,6 +124,8 @@ def SetBasicData(self, authors, license, project, description, server, self.ConfigData["project_url"] = project self.ConfigData["description_string"] = description self.ConfigData["server_url"] = server + if repositoryType: + self.ConfigData["repository_type"] = repositoryType if repositoryUrl: self.ConfigData["repository_url"] = repositoryUrl if repositoryBranch: @@ -174,8 +176,11 @@ def UpdateTags(self, tags=[]): self.ConfigData["tags_string"] = " ".join(tags) self.ConfigChanged = True - def UpdateRepositoryInfo(self, url=None, branch=None, commit=None): + def UpdateRepositoryInfo(self, type=None, url=None, branch=None, commit=None): """Update repository information.""" + if type: + self.ConfigData["repository_type"] = type + self.ConfigChanged = True if url: self.ConfigData["repository_url"] = url self.ConfigChanged = True @@ -237,9 +242,11 @@ def _MakeNuspecXml(self, ContentDir, ReleaseNotesText=None): meta.find("version").text = self.NewVersion meta.find("authors").text = self.ConfigData["author_string"] meta.find("projectUrl").text = self.ConfigData["project_url"] - if "repository" in self.ConfigData: + repository_item_present = bool([k for k in self.ConfigData.keys() if "repository_" in k.lower()]) + if repository_item_present: r = meta.find("repository") - r.set("type", "git") + if "repository_type" in self.ConfigData: + r.set("type", self.ConfigData["repository_type"]) if "repository_url" in self.ConfigData: r.set("url", self.ConfigData["repository_url"]) if "repository_branch" in self.ConfigData: @@ -332,7 +339,7 @@ def Pack(self, version, OutputDirectory, ContentDir, RelNotesText=None): ret = RunCmd(cmd[0], " ".join(cmd[1:])) if (ret != 0): - logging.error("Failed on nuget commend. RC = 0x%x" % ret) + logging.error("Failed on nuget command. RC = 0x%x" % ret) return ret self.NuPackageFile = os.path.join(OutputDirectory, self._GetNuPkgFileName(self.NewVersion)) @@ -368,7 +375,7 @@ def Push(self, nuPackage, apikey): logging.critical("API key is invalid. Please use --ApiKey to provide a valid key.") # Generic error. - logging.error("Failed on nuget commend. RC = 0x%x" % ret) + logging.error("Failed on nuget command. RC = 0x%x" % ret) return ret @@ -397,6 +404,7 @@ def GatherArguments(): required=True) parser.add_argument('--Author', dest="Author", help=" Author string for publishing", required=True) parser.add_argument("--ProjectUrl", dest="Project", help=" Project Url", required=True) + parser.add_argument("--RepositoryType", dest="RepositoryType", help=" Repository Type", required=False) parser.add_argument("--RepositoryUrl", dest="RepositoryUrl", help=" Repository Url", required=False) parser.add_argument("--RepositoryBranch", dest="RepositoryBranch", help=" Repository Branch", required=False) parser.add_argument("--RepositoryCommit", dest="RepositoryCommit", help=" Repository Commit", required=False) @@ -427,6 +435,7 @@ def GatherArguments(): parser.add_argument('--CustomLicensePath', dest="CustomLicensePath", default=None, help=" If CustomLicense set in `new` phase, provide absolute path of License \ File to pack. Does not override existing valid license.") + parser.add_argument("--RepositoryType", dest="RepositoryType", help=" Repository Type", required=False) parser.add_argument("--RepositoryUrl", dest="RepositoryUrl", help=" Change the repository Url", required=False) parser.add_argument("--RepositoryBranch", dest="RepositoryBranch", help=" Change the repository branch", required=False) parser.add_argument("--RepositoryCommit", dest="RepositoryCommit", help=" Change the repository commit", required=False) @@ -499,6 +508,7 @@ def main(): args.Description, args.FeedUrl, args.Copyright, + args.RepositoryType, args.RepositoryUrl, args.RepositoryBranch, args.RepositoryCommit) @@ -545,7 +555,8 @@ def main(): if (args.Copyright is not None): nu.UpdateCopyright(args.Copyright) - nu.UpdateRepositoryInfo(args.RepositoryUrl, args.RepositoryBranch, args.RepositoryCommit) + nu.UpdateRepositoryInfo(args.RepositoryType, args.RepositoryUrl, + args.RepositoryBranch, args.RepositoryCommit) if (len(args.Tags) > 0): tagListSet = set() diff --git a/Platforms/QemuQ35Pkg/NugetPublishing/DebugConfig.yaml b/Platforms/QemuQ35Pkg/NugetPublishing/DebugConfig.yaml index b93c7c977e..907be85f45 100644 --- a/Platforms/QemuQ35Pkg/NugetPublishing/DebugConfig.yaml +++ b/Platforms/QemuQ35Pkg/NugetPublishing/DebugConfig.yaml @@ -3,6 +3,7 @@ copyright_string: Copyright (c) Microsoft Corporation. description_string: QEMU Q35 DEBUG Platform Firmware name: TEST.Mu.QemuQ35.FW.DEBUG project_url: https://microsoft.github.io/mu/ +repository_type: git repository_url: https://github.com/makubacki/mu_tiano_platforms server_url: https://nuget.pkg.github.com/makubacki/index.json tags_string: '' diff --git a/Platforms/QemuQ35Pkg/NugetPublishing/ReleaseConfig.yaml b/Platforms/QemuQ35Pkg/NugetPublishing/ReleaseConfig.yaml index cd37a56e00..37bdca7d2b 100644 --- a/Platforms/QemuQ35Pkg/NugetPublishing/ReleaseConfig.yaml +++ b/Platforms/QemuQ35Pkg/NugetPublishing/ReleaseConfig.yaml @@ -3,6 +3,7 @@ copyright_string: Copyright (c) Microsoft Corporation. description_string: QEMU Q35 RELEASE Platform Firmware name: TEST.Mu.QemuQ35.FW.RELEASE project_url: https://microsoft.github.io/mu/ +repository_type: git repository_url: https://github.com/makubacki/mu_tiano_platforms server_url: https://nuget.pkg.github.com/makubacki/index.json tags_string: '' \ No newline at end of file diff --git a/Platforms/QemuSbsaPkg/NugetPublishing/DebugConfig.yaml b/Platforms/QemuSbsaPkg/NugetPublishing/DebugConfig.yaml index e46cdccb5a..03730bda15 100644 --- a/Platforms/QemuSbsaPkg/NugetPublishing/DebugConfig.yaml +++ b/Platforms/QemuSbsaPkg/NugetPublishing/DebugConfig.yaml @@ -3,6 +3,7 @@ copyright_string: Copyright (c) Microsoft Corporation. description_string: QEMU Q35 SBSA DEBUG Platform Firmware name: TEST.Mu.QemuQ35SBSA.FW.DEBUG project_url: https://microsoft.github.io/mu/ +repository_type: git repository_url: https://github.com/makubacki/mu_tiano_platforms server_url: https://nuget.pkg.github.com/makubacki/index.json tags_string: '' diff --git a/Platforms/QemuSbsaPkg/NugetPublishing/ReleaseConfig.yaml b/Platforms/QemuSbsaPkg/NugetPublishing/ReleaseConfig.yaml index 18dd6c7dec..690dac1bd3 100644 --- a/Platforms/QemuSbsaPkg/NugetPublishing/ReleaseConfig.yaml +++ b/Platforms/QemuSbsaPkg/NugetPublishing/ReleaseConfig.yaml @@ -3,6 +3,7 @@ copyright_string: Copyright (c) Microsoft Corporation. description_string: QEMU Q35 SBSA RELEASE Platform Firmware name: TEST.Mu.QemuQ35SBSA.FW.RELEASE project_url: https://microsoft.github.io/mu/ +repository_type: git repository_url: https://github.com/makubacki/mu_tiano_platforms server_url: https://nuget.pkg.github.com/makubacki/index.json tags_string: '' \ No newline at end of file