From 969518c47599f2efe7b55b874246d8d0a201c2a7 Mon Sep 17 00:00:00 2001 From: LexManos Date: Tue, 19 Jun 2012 21:32:19 -0700 Subject: [PATCH] Updated release script to automatically inject version info into .info file. --- forge/forge_common/mod_MinecraftForge.info | 2 +- forge/release.py | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/forge/forge_common/mod_MinecraftForge.info b/forge/forge_common/mod_MinecraftForge.info index e3e09ea87..2a9f1811b 100644 --- a/forge/forge_common/mod_MinecraftForge.info +++ b/forge/forge_common/mod_MinecraftForge.info @@ -2,7 +2,7 @@ { "modid" : "mod_MinecraftForge", "name" : "Minecraft Forge", - "version" : "v3.3.8", + "version" : "{version}", "url" : "http://MinecraftForge.net", "credits" : "Lots of people have contributed to MinecraftForge", "authors": [ diff --git a/forge/release.py b/forge/release.py index 03b58218d..e20b40560 100644 --- a/forge/release.py +++ b/forge/release.py @@ -1,6 +1,6 @@ import os, os.path, sys import shutil, fnmatch -import logging, zipfile +import logging, zipfile, re forge_dir = os.path.dirname(os.path.abspath(__file__)) mcp_dir = os.path.abspath('..') @@ -55,6 +55,8 @@ def main(): os.makedirs(out_folder) + update_info('forge_common/mod_MinecraftForge.info', version_str) + zip_start('minecraftforge-client-%s.zip' % version_str) zip_folder(client_dir, '', zip) zip_add('forge_common/mod_MinecraftForge.info', 'mod_MinecraftForge.info') @@ -101,6 +103,8 @@ def main(): zip_end() inject_version(os.path.join(forge_dir, 'forge_common', 'net', 'minecraft', 'src', 'forge', 'ForgeHooks.java'), 0) + shutil.move(os.path.join(forge_dir, 'file.backup'), os.path.join(forge_dir, 'forge_common/mod_MinecraftForge.info'.replace('/', os.sep))) + print '=================================== Release Finished %d =================================' % error_level sys.exit(error_level) @@ -153,6 +157,20 @@ def zip_end(): zip_name = None zip_base = None +def update_info(input, version): + input = os.path.join(forge_dir, input.replace('/', os.sep)) + temp = os.path.join(forge_dir, 'file.backup') + + shutil.move(input, temp) + + with open(temp, 'r') as fh: + buf = fh.read() + + buf = re.sub(r'{version}', version, buf) + + with open(input, 'w') as fh: + fh.write(buf) + def extract_fml_obfed(): fml_file = os.path.join(forge_dir, 'fml', 'difflist.txt') if not os.path.isfile(fml_file):