def VerifyStripping() -> None: print("Verifying stripping.") print("Verifying environment file stripping.") environmentIncludedPaths = GetIncludedPaths( Paths.StrippingEnvironmentFilePath, Paths.RootPath) # type: typing.List[str] _VerifyStripped(Paths.RootPath, environmentIncludedPaths) for modName in Mods.GetAllModNames(): # type: str print("Verifying mod '" + modName + "' file stripping.") modPath = Mods.GetModPath(modName) # type: str modIncludedPaths = GetIncludedPaths(Paths.StrippingModsFilePath, modPath) _VerifyStripped(modPath, modIncludedPaths) for siteName in Sites.GetAllSiteNames(): # type: str print("Verifying site '" + siteName + "' file stripping.") sitePath = Sites.GetSitePath(siteName) # type: str siteIncludedPaths = GetIncludedPaths(Paths.StrippingSitesFilePath, sitePath) _VerifyStripped(sitePath, siteIncludedPaths)
def PublishModRelease(modNamespace: str) -> None: print("Publishing mod '" + modNamespace + "' as a release.") if Paths.DistributionReleasesPath is None: raise Exception( "No distribution release path has been specified via automation settings." ) mod = Mods.GetMod(modNamespace) # type: Mods.Mod modDirectoryPath = Mods.GetModPath(modNamespace) # type: str version = mod.GetVersion() # type: typing.Optional[str] installerFilePath = mod.GetInstallerFilePath( ) # type: typing.Optional[str] filesFilePath = mod.GetFilesFilePath() # type: typing.Optional[str] sourcesFileName = mod.GetSourcesFileName() # type: typing.Optional[str] if version is None: raise Exception( "Couldn't get the current version number for this mod.") if installerFilePath is None: raise Exception( "Couldn't get the current installer file path for this mod.") if filesFilePath is None: raise Exception( "Couldn't get the current files file path for this mod.") if sourcesFileName is None: raise Exception( "Couldn't get the current sources file name for this mod.") distributionVersionDirectoryPath = os.path.join( Paths.DistributionReleasesPath, modNamespace.lower(), version) # type: str distributionInstallerDirectoryPath = os.path.join( distributionVersionDirectoryPath, "installer") # type: str distributionFilesDirectoryPath = os.path.join( distributionVersionDirectoryPath, "files") # type: str distributionSourcesDirectoryPath = os.path.join( distributionVersionDirectoryPath, "sources") # type: str if os.path.exists(distributionVersionDirectoryPath): dir_util.remove_tree(distributionVersionDirectoryPath, verbose=1) os.makedirs(distributionInstallerDirectoryPath) os.makedirs(distributionFilesDirectoryPath) os.makedirs(distributionSourcesDirectoryPath) file_util.copy_file(installerFilePath, distributionInstallerDirectoryPath, preserve_times=0) file_util.copy_file(filesFilePath, distributionFilesDirectoryPath, preserve_times=0) sourcesIncludedPaths = GetIncludedPaths( Paths.StrippingModsFilePath, Mods.GetModPath(modNamespace)) # type: typing.List[str] archiveFile = zipfile.ZipFile( os.path.join(distributionSourcesDirectoryPath, sourcesFileName), mode="w", compression=zipfile.ZIP_DEFLATED) # type: zipfile.ZipFile for sourcesIncludedPath in sourcesIncludedPaths: # type: str archiveFile.write(os.path.join(modDirectoryPath, sourcesIncludedPath), arcname=sourcesIncludedPath) archiveFile.close() with open( os.path.join(distributionVersionDirectoryPath, "information.json"), "w+") as versionInformationFile: versionInformationFile.write( encoder.JSONEncoder(indent="\t").encode({ "Game Version": S4.Version, "Release Date": datetime.datetime.now().date().isoformat() }))