summaryrefslogtreecommitdiff
path: root/tools/make_release.py
blob: 65226834f09a02068ce59d86caf11b035102bcc7 (plain)
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
#!/usr/bin/env python3
import re
import gen_doc
import gen_presets

version = '0.21.0'

print('version {}'.format(version))
ver_id = version.split('.')

###################
# src/tusb_option.h
###################
f_option_h = 'src/tusb_option.h'
with open(f_option_h) as f:
    fdata = f.read()
    fdata = re.sub(r'(#define TUSB_VERSION_MAJOR *) \d+', r"\1 {}".format(ver_id[0]), fdata)
    fdata = re.sub(r'(#define TUSB_VERSION_MINOR *) \d+', r"\1 {}".format(ver_id[1]), fdata)
    fdata = re.sub(r'(#define TUSB_VERSION_REVISION *) \d+', r"\1 {}".format(ver_id[2]), fdata)

# Write the file out again
with open(f_option_h, 'w') as f:
    f.write(fdata)

###################
# repository.yml
###################
f_repository_yml = 'repository.yml'
with open(f_repository_yml) as f:
    fdata = f.read()

if fdata.find(version) < 0:
    fdata = re.sub(r'("0-latest"): "\d+\.\d+\.\d+"', r'"{}": "{}"\n    \1: "{}"'.format(version, version, version), fdata)
    with open(f_repository_yml, 'w') as f:
        f.write(fdata)

###################
# library.json
###################
f_library_json = 'library.json'
with open(f_library_json) as f:
    fdata = f.read()
    fdata = re.sub(r'( {4}"version":) "\d+\.\d+\.\d+"', rf'\1 "{version}"', fdata)

with open(f_library_json, 'w') as f:
    f.write(fdata)

###################
# sonar-project.properties
###################
f_sonar_properties = 'sonar-project.properties'
with open(f_sonar_properties) as f:
    fdata = f.read()
fdata = re.sub(r'(sonar\.projectVersion=)\d+\.\d+\.\d+', r'\g<1>{}'.format(version), fdata)

with open(f_sonar_properties, 'w') as f:
    f.write(fdata)

# gen docs
gen_doc.gen_deps_doc()
gen_doc.gen_boards_doc()

# gen presets
gen_presets.main()

###################
# docs/changelog/
###################
print("Add docs/changelog/{}.md and list it at the top of docs/changelog/index.rst".format(version))