/
bumpVersion.groovy
33 lines (25 loc) · 1.08 KB
/
bumpVersion.groovy
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
import javax.swing.*
def prompt = { label, value ->
JFrame jframe = new JFrame()
String answer = JOptionPane.showInputDialog(jframe, label, value)
jframe.dispose()
answer
}
File version = new File(".version")
def oldVersion = version.exists() ? version.text : ''
def newVersion = prompt("Enter new version number:", oldVersion)
if (newVersion) {
version.text = newVersion
File quest = new File("Scripts/Source/User/LenARM/LenARM_Main.psc")
quest.text = quest.text.replaceAll(~/(?s)(string Function GetVersion\(\)[\r\n\t]+return ")[^"]*(")(\s*;[^\r\n]*)?/, "\$1${newVersion}\$2; ${new Date()}")
File mcm = new File("MCM/Config/RadMorphingRedux/config.header.tpl.json")
mcm.text = mcm.text.replaceAll(~/(?s)(<font[^>]+id='version'[^>]*>)[^<]*(<)/, "\$1v${newVersion}\$2")
File fomod = new File(".fomod/fomod/info.xml")
fomod.text = fomod.text.replaceAll(~/(?s)(<Version>)[^<]+(<)/, "\$1${newVersion}\$2")
def x = new createMCM()
x.main(null)
println "$oldVersion --> $newVersion"
println "compile scripts in CreationKit, then run copyToFomod"
} else {
println "no version change"
}