Commit 999fc704 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

update ci to write changelog from tag message

parent 71029a9c
Pipeline #7502 passed with stage
in 27 seconds
import pytest
import sys
import os
import subprocess
python <platform> [<configuration>] [push]
if __name__ == '__main__':
module = 'DTU_Controller'
sln = 'src/dtu_controller.sln'
dll_lst = ['src/dtu_we_controller/%s/%s/dtu_we_controller%s.dll','src/dtu_we_controller_bladed/%s/%s/dtu_we_controller_bladed%s.dll']
binary_folder = 'control-%s'
def run(cmd):
if os.system(cmd):
raise Exception("'%s' failed" % cmd)
def run_git_cmd(cmd):
git_repo_path = os.getcwd()
if not os.path.isdir(os.path.join(git_repo_path, ".git")):
raise Warning("'%s' does not appear to be a Git repository." % git_repo_path)
process = subprocess.Popen(cmd,
stdout, stderr = process.communicate()
if process.returncode != 0:
raise EnvironmentError("%s\n%s" % (stdout, stderr))
return stdout.strip()
except EnvironmentError as e:
raise e
raise Warning("unable to run git")
platform = sys.argv[1]
if len(sys.argv) == 3 and sys.argv[2].lower() != 'push':
conf = sys.argv[2]
......@@ -22,6 +44,8 @@ if __name__ == '__main__':
conf = 'Release'
push = sys.argv[-1] == 'push'
ext = ['', '_64'][platform.lower() == 'x64']
binary_folder = binary_folder%platform
print("Run ci")
print("- Platform: %s" % platform)
print("- Solution file: %s" % (sln))
......@@ -34,8 +58,19 @@ if __name__ == '__main__':
#if res:
# sys.exit(res)
run("git clone -b master --depth 1" % platform)
run("git clone -b master --depth 1" % binary_folder)
tag = "%-12s"%run_git_cmd("git describe --tags")
message = run_git_cmd("git tag -n99 %s"%tag).replace(tag, "").strip()
date = run_git_cmd('git log -1 --format=%%ai --tags %s'%tag)[:10].strip()
name = run_git_cmd('git log -1 --format="%%an" --tags %s'%tag).strip()
with open('%s/changelog.txt'%binary_folder,'a') as fid:
info = " ".join([tag, date, name, module])
message = ("\n"+" "*60).join([l.strip() for l in message.split("\n")])
fid.write("%-60s%s\n"%(info[:58], message))
for dll in dll_lst:
run("%s control-%s/ %s" % (sys.executable, platform, dll%(platform, conf, ext)))
run("%s %s/ %s" % (sys.executable, binary_folder, dll%(platform, conf, ext)))
if push:
run("%s control-%s/ push" % (sys.executable, platform))
run("%s %s/ push" % (sys.executable, binary_folder))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment