-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.py
71 lines (56 loc) · 2.19 KB
/
release.py
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
#! python
from subprocess import call
import subprocess
import fileinput
import re
import os
import sys
import getopt
origPath = os.getcwd();
def safeProcess( cmd ):
"Run command, return boolean for success"
print(cmd);
try:
out = subprocess.check_output(cmd, shell=True)
print(out.decode("utf-8").replace("\\\n", "\n"))
return True;
except subprocess.CalledProcessError as e:
print("Status : FAIL", e.returncode, e.output)
return False;
def safeExit():
print ("Exiting...")
os.chdir(origPath)
sys.exit(1)
# safeProcess("git reset --hard head")
def get_version(filename):
pattern = re.compile("\[assembly:\s*AssemblyVersion\(\"(\d*.\d*.\d*)\"\)\]")
for line in fileinput.input(filename):
if re.search(pattern, line):
version = pattern.search(line).groups()[0]
return version
return None;
# Don't continue if working copy is dirty
if not safeProcess('git diff-index --quiet HEAD --'):
print( "Cannot build, git working copy dirty")
safeExit()
# Build main project
# FYI if you're running this directly in git bash, you need to escape the forward slashes in the options (e.g. //Project)
eyemine = 'src/JuliusSweetland.OptiKey.EyeMine/JuliusSweetland.OptiKey.EyeMine.csproj'
build = 'devenv.com OptiKey.sln /Project {} /Rebuild "Release"'.format(eyemine)
if not safeProcess(build):
print("Error building project")
safeExit()
# Build installer
installer_file = "installer/EyeMine.aip"
buildInstall = "AdvancedInstaller.com /rebuild {}".format(installer_file)
if not safeProcess(buildInstall):
print("Error building installer")
safeExit()
# Discard local changes to InstallerStrings (these are a build artefact)
if not safeProcess("git checkout src/JuliusSweetland.OptiKey.InstallerActions/InstallerStrings.cs"):
print("Error checking out InstallerStrings.cs")
safeExit()
# Tag code by version
version_file = 'src/JuliusSweetland.OptiKey.EyeMine/Properties/AssemblyInfo.cs'
version = get_version(version_file)
safeProcess("git tag release/{}".format(version))