-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.py
38 lines (31 loc) · 1.08 KB
/
build.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
# -*- coding: utf-8 -*-
# Authors: Joe <xiaotu9639@gmail.com>
import os
import re
import zipfile
__version__ = '2.0.0'
if __name__ == '__main__':
# 获取新版本号
old_version = open('version', 'r').read()
old_version = re.sub(r'\s', '', old_version)
tail = int(old_version[-1]) + 1
confirm_version = old_version[:-1] + str(tail)
confirm = input('推荐新版本号为 %s (回车确认或输入指定版本号):' % confirm_version)
new_version = confirm if confirm else confirm_version
print(u'将使用新版本号 %s 构建发布包' % new_version)
# 新版本号写入 version 文件
with open('version', 'w') as v:
v.write(new_version)
# 构建发布包
if not os.path.exists('out'):
os.mkdir('out')
z = zipfile.ZipFile('out/yuque-%s.alfredworkflow' % new_version, 'w')
z.write('info.plist')
z.write('icon.png')
z.write('action.py')
z.write('yuque.py')
z.write('version')
z.write('readme.md')
for f in os.listdir('workflow'):
z.write(os.path.join('workflow', f))
print('Build completed.')