Add script to zip up release builds.

This commit is contained in:
Pieter-Jan Briers
2017-08-06 23:15:39 +02:00
parent 486bb9f0ef
commit 4454525e6d
4 changed files with 69 additions and 6 deletions

View File

@@ -33,7 +33,6 @@
<OutputPath>..\bin\Content.Client\</OutputPath> <OutputPath>..\bin\Content.Client\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
@@ -82,7 +81,7 @@
if not exist "..\Client\Assemblies" ( if not exist "..\Client\Assemblies" (
mkdir ..\Client\Assemblies\ mkdir ..\Client\Assemblies\
) )
copy Content.* ..\Client\Assemblies\ copy Content.* ..\Client\Assemblies\ > NUL
</PostBuildEvent> </PostBuildEvent>
</PropertyGroup> </PropertyGroup>
</When> </When>

View File

@@ -33,7 +33,6 @@
<OutputPath>..\bin\Content.Server\</OutputPath> <OutputPath>..\bin\Content.Server\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
@@ -78,7 +77,7 @@
if not exist "..\Server\Assemblies" ( if not exist "..\Server\Assemblies" (
mkdir ..\Server\Assemblies\ mkdir ..\Server\Assemblies\
) )
copy Content.* ..\Server\Assemblies\ copy Content.* ..\Server\Assemblies\ > NUL
</PostBuildEvent> </PostBuildEvent>
</PropertyGroup> </PropertyGroup>
</When> </When>

View File

@@ -25,7 +25,6 @@
<OutputPath>bin\x86\Release\</OutputPath> <OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
@@ -55,4 +54,4 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

66
package_release_build.py Normal file
View File

@@ -0,0 +1,66 @@
#!/usr/bin/env python3
# Packages a full release build that can be unzipped and you'll have your SS14 client and server.
import os
import shutil
import subprocess
import zipfile
try:
from colorama import init, Fore, Back, Style
init()
except ImportError:
# Just give an empty string for everything, no colored logging.
class ColorDummy(object):
def __getattr__(self, name):
return ""
Fore = ColorDummy()
Style = ColorDummy()
Back = ColorDummy()
def main():
# Wipe out old build directory.
print(Fore.BLUE + Style.DIM + "Clearing old build artifacts..." + Style.RESET_ALL)
shutil.rmtree("bin")
build_windows()
def build_windows():
# Run a full build.
print(Fore.GREEN + "Building project for Windows x86..." + Style.RESET_ALL)
subprocess.run(["msbuild", "SpaceStation14Content.sln", "/m", "/p:Configuration=Release", "/p:Platform=x86", "/nologo", "/v:m"], check=True)
# Package client.
print(Fore.GREEN + "Packaging Windows x86 client..." + Style.RESET_ALL)
package_zip(os.path.join("bin", "Client"), os.path.join("bin", "SS14.Client_windows_x86.zip"))
print(Fore.GREEN + "Packaging Windows x86 server..." + Style.RESET_ALL)
package_zip(os.path.join("bin", "Server"), os.path.join("bin", "SS14.Server_windows_x86.zip"))
def package_zip(directory, zipname):
with zipfile.ZipFile(zipname, "w") as f:
for dir, _, files in os.walk(directory):
relpath = os.path.relpath(dir, directory)
if relpath != ".":
# Write directory node except for root level.
f.write(dir, relpath)
for filename in files:
zippath = os.path.join(relpath, filename)
filepath = os.path.join(dir, filename)
print(Fore.CYAN + "{dim}{diskroot}{sep}{zipfile}{dim} -> {ziproot}{sep}{zipfile}"
.format(
sep = os.sep + Style.NORMAL,
dim = Style.DIM,
diskroot = directory,
ziproot = zipname,
zipfile = os.path.normpath(zippath)
) + Style.RESET_ALL)
f.write(filepath, zippath)
if __name__ == '__main__':
main()