-
Notifications
You must be signed in to change notification settings - Fork 5
/
create-zammad-extension.py
85 lines (77 loc) · 2.72 KB
/
create-zammad-extension.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import os
import base64
import json
import datetime
version = '1.0.0'
buildtime = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
if 'GITHUB_REF' in os.environ:
version = os.environ['GITHUB_REF']
print('using GITHUB_REF: %s' % (os.environ['GITHUB_REF']))
# refs/tags/
version = version.replace('refs/tags', '')
template = '''{
"name": "RocketChat for Zammad",
"version": "%s",
"vendor": "GenOuest",
"license": "MIT",
"url": "https://www.genouest.org",
"buildhost": "github-ci",
"builddate": "%s",
"change_log": %s,
"description": [
{
"language": "en",
"text": "Adding Zammad to RocketChat notifications and mentions"
}
],
"files": [
%s
]
}'''
files = [
'app/assets/javascripts/app/controllers/_integration/rocketchat.coffee',
'app/models/transaction/rocketchat.rb',
'app/views/rocketchat/application.md.erb',
'app/views/rocketchat/ticket_create/en.md.erb',
'app/views/rocketchat/ticket_create/pt-br.md.erb',
'app/views/rocketchat/ticket_create/zh-cn.md.erb',
'app/views/rocketchat/ticket_create/zh-tw.md.erb',
'app/views/rocketchat/ticket_escalation/en.md.erb',
'app/views/rocketchat/ticket_escalation/pt-br.md.erb',
'app/views/rocketchat/ticket_escalation/zh-cn.md.erb',
'app/views/rocketchat/ticket_escalation/zh-tw.md.erb',
'app/views/rocketchat/ticket_escalation_warning/en.md.erb',
'app/views/rocketchat/ticket_escalation_warning/pt-br.md.erb',
'app/views/rocketchat/ticket_escalation_warning/zh-cn.md.erb',
'app/views/rocketchat/ticket_escalation_warning/zh-tw.md.erb',
'app/views/rocketchat/ticket_mentioned/en.md.erb',
'app/views/rocketchat/ticket_reminder_reached/en.md.erb',
'app/views/rocketchat/ticket_reminder_reached/pt-br.md.erb',
'app/views/rocketchat/ticket_reminder_reached/zh-cn.md.erb',
'app/views/rocketchat/ticket_reminder_reached/zh-tw.md.erb',
'app/views/rocketchat/ticket_update/en.md.erb',
'app/views/rocketchat/ticket_update/pt-br.md.erb',
'app/views/rocketchat/ticket_update/zh-cn.md.erb',
'app/views/rocketchat/ticket_update/zh-tw.md.erb',
'lib/notification_factory/rocketchat.rb',
'spec/lib/notification_factory/rocketchat_spec.rb',
'db/seeds/rocket.rb'
]
tplfile = '''{
"location": "%s",
"permission": 644,
"encode": "base64",
"content": "%s"
}
'''
tplfiles = []
for f in files:
with open(f) as t:
content = t.read()
b64 = base64.b64encode(str.encode(content))
tplfiles.append(tplfile % (f, b64.decode()))
changelog = []
with open('CHANGELOG') as ch:
changelog = json.load(ch)
with open('zammad-rocketchat.szpm', 'w') as f:
f.write(template % (version, buildtime, json.dumps(changelog), ','.join(tplfiles)))