Skip to content

Instantly share code, notes, and snippets.

@lashtear
Created January 27, 2018 08:18
Show Gist options
  • Save lashtear/f93cb708551917bc28c0abb96fe05239 to your computer and use it in GitHub Desktop.
Save lashtear/f93cb708551917bc28c0abb96fe05239 to your computer and use it in GitHub Desktop.
#! /usr/bin/python3
# small helper script for bundling up factorio mods redistributable
# under BSD3 or MIT terms as desired
import json
import subprocess
with open("info.json") as info_file:
info = json.load(info_file)
with subprocess.Popen(['git', 'describe', '--dirty', '--tags'],
universal_newlines=True,
stdout=subprocess.PIPE) as git:
git_version = git.stdout.read().rstrip()
if git_version != info['version']:
print ("git reported version {} does not match info.json version {}, retag?"
.format(git_version,info['version']))
exit(1)
name = "{}_{}".format(info['name'], info['version'])
subprocess.run (['git', 'archive',
'--prefix', "{}/".format(name),
'--output', "{}.zip".format(name),
info['version']])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment