-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-release-notes.py
41 lines (33 loc) · 1.54 KB
/
create-release-notes.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
# raw note for file_path means to copy down draft release content generated by Github workflow
# this script helps add the URLs to all PR and have the right release note filename
# run by `python create-release-notes.py`, then input date, file_path ... as requested
import os
import sys
import fileinput
import re
link_prefix = "https://github.com/opensearch-project/index-management-dashboards-plugin/pull/"
searchExp = re.compile("([\(\[]).*?([\)\]])")
current_date = raw_input("what day is today (e.g. 2020-06-29): ")
file_path = raw_input("Path to raw note file (e.g., note.md): ")
plugin_name = "index-management-dashboards-plugin"
plugin_version = raw_input('Plugin version (x.x.x.x): ')
app = 'OpenSearch-Dashboards'
app_version = raw_input(app + ' compatibility version (x.x.x): ')
for line in fileinput.input(file_path, inplace=True):
# Add title and OpenSearch/OpenSearchDashboards compatibility
if fileinput.isfirstline():
line = "## Version " + plugin_version + " " + current_date + "\n\n" \
"Compatible with " + app + " " + app_version + "\n"
# Add link to PRs
if '*' in line:
start = line.find('#') + 1
end = line.find(')', start)
pr_num = line[start:end]
line = re.sub(searchExp, "([#" + pr_num +
"](" + link_prefix + pr_num + "))", line)
sys.stdout.write(line)
# Rename file to be consistent with ODFE standards
new_file_path = "opensearch-" + plugin_name + ".release-notes-" + \
plugin_version + ".md"
os.rename(file_path, new_file_path)
print('\n\nDone!\n')