forked from KapuKapu/bimiTool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_release.py
executable file
·54 lines (47 loc) · 2.5 KB
/
make_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
#!/usr/bin/env python3
# -*- coding: utf-8, vim: expandtab:ts=4 -*-
# ----------------------------------------------------------------------------#
# Copyright 2012 Julian Weitz #
# Copyright 2022 András Németh #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# ----------------------------------------------------------------------------#
import argparse
from datetime import date
import os
import subprocess
import sys
git_rm_files = ['test_bimibase.py',
'run_unittest.py',
'make_release.py',
'session.vim']
version_subs_files = ['CHANGELOG',
'README']
# Parse arguments
parser = argparse.ArgumentParser(add_help=True, description='Readies code base for realease')
parser.add_argument('version_number',
default=None,
help='Version number for substitution',
type=str)
options = parser.parse_args()
script_dir = os.path.realpath(os.path.dirname(sys.argv[0]))
# Substitute version tag with given string
for item in version_subs_files:
item = os.path.join(script_dir, item)
subprocess.call(['sed', '-i', 's:\$version\$:' + options.version_number + ':', item])
subprocess.call(['sed', '-i', 's:\$date\$:' + str(date.today()) + ':', item])
# Remove files from git
for item in git_rm_files:
with subprocess.Popen(['git', 'rm', item], stdout=subprocess.PIPE) as process:
sys.stdout.write(process.communicate()[0])