-
Notifications
You must be signed in to change notification settings - Fork 69
/
make_principia_release.ps1
122 lines (100 loc) · 3.79 KB
/
make_principia_release.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
$ErrorActionPreference = "Stop"
"Usage:"
"make_principia_release mathematician culture date primary_ksp_version"
" compatibility_ksp_versions [branch]"
""
" ARGUMENT EXAMPLE VALUES"
" mathematician 陈景润"
" culture zh-CN"
" date 2017111812"
" primary_ksp_version 1.3.1"
" compatibility_ksp_versions @('1.2.1', '1.3.0')"
" branch Grassmannian"
$mathematician = $args[0]
$culture = new-object CultureInfo $args[1]
$date = $args[2]
$primary_ksp_version = $args[3]
$compatibility_ksp_versions = $args[4]
$branch = $args[5]
if (!$branch) {
$branch = 'master'
}
if ($culture.lcid -eq 0x1000) {
write-error ("Culture $culture has LCID 0x1000.")
}
if (!($date -match '^\d{10}$')) {
write-error ("Argument $date should be the UT1 date of the new moon, " +
"rounded to the nearest hour, formatted yyyyMMddHH.")
exit 1
}
$msbuild = &".\find_msbuild.ps1" -strict
$7zip = "${Env:ProgramW6432}\7-Zip\7z.exe"
if (!(test-path -path $7zip)) {
write-error ("Could not find 7-Zip.")
}
$tag = "$date-$mathematician"
$remote = $(
git remote -v |
sls 'https://github.com/mockingbirdnest/Principia.git')[0].tostring().split()[0]
git fetch $remote
if ($tag -in $(git tag)) {
write-error ("Tag $tag already exists.")
}
if (test-path .\Release) {
rm .\Release -recurse
}
git checkout "$remote/$branch"
git tag $tag -m $mathematician
&$msbuild `
/t:Clean `
/property:Configuration=Release `
/property:Platform=x64 `
.\Principia.sln
&$msbuild `
"/t:ksp_plugin:Rebuild;ksp_plugin_adapter:Rebuild" `
/property:Configuration=Release `
/property:Platform=x64 `
.\Principia.sln
foreach ($ksp_version in $compatibility_ksp_versions) {
&$msbuild `
/t:ksp_plugin_adapter:Rebuild `
"/property:Configuration=Release KSP $ksp_version" `
/property:Platform=x64 `
.\Principia.sln
}
# Sanity check: the error message in the adapter should mention all supported
# versions.
if (!(sls ([regex]::escape(
[text.encoding]::ascii.getstring(
[text.encoding]::unicode.getbytes(
$primary_ksp_version)))) -encoding ASCII `
".\Release\GameData\Principia\ksp_plugin_adapter.dll")) {
write-error ("Configuration Release does not target $primary_ksp_version.")
}
foreach ($ksp_version in $compatibility_ksp_versions) {
if (!(sls ([regex]::escape(
[text.encoding]::ascii.getstring(
[text.encoding]::unicode.getbytes(
$ksp_version)))) -encoding ASCII `
(".\Release\$ksp_version Compatibility\GameData\Principia\" +
"ksp_plugin_adapter.dll"))) {
write-error ("Configuration Release KSP $ksp_version does not target " +
"$ksp_version.")
}
}
$lowercase_mathematician = $mathematician.tolower($culture)
&$7zip a "principia $lowercase_mathematician for $primary_ksp_version.zip" `
".\Release\GameData"
foreach ($ksp_version in $compatibility_ksp_versions) {
cp "principia $lowercase_mathematician for $primary_ksp_version.zip" `
"principia $lowercase_mathematician for $ksp_version.zip"
&$7zip a "principia $lowercase_mathematician for $ksp_version.zip" `
".\Release\$ksp_version Compatibility\GameData"
}
if ($mathematician.contains("TEST")) {
echo "Successfully built test release $tag. Run"
echo " git tag --delete $tag"
echo "to clean up."
} else {
git push $remote $tag
}