Skip to content

Commit

Permalink
Update version in bug report template automation
Browse files Browse the repository at this point in the history
  • Loading branch information
forntoh committed Jun 18, 2023
1 parent 4041785 commit fe79454
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .scripts/bugreport.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import re

import click

search = r'(\s+- \d\.\d\.\d)'
filename = ".github/ISSUE_TEMPLATE/bug_report.yml"

@click.command()
@click.argument('version')

def build(version):
with open(filename, "r") as file:
contents = file.read()
old_version = re.search(search, contents)[0]
updated_contents = re.sub(old_version, f'\n - {version}{old_version}', contents)

with open(filename, "w") as file:
file.write(updated_contents)
file.truncate()
print("Updated version number in bug report template")

if __name__ == '__main__':
build()
2 changes: 1 addition & 1 deletion .scripts/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def build(files):
a_file.write(keyword_2_data)
a_file.write(pre_lit_1)
a_file.write(literal_1_data)
print("Done")
print("Updated keywords")

if __name__ == '__main__':
build()
4 changes: 3 additions & 1 deletion .scripts/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import re

import click


@click.command()
@click.argument('files', type=click.Path("r"), nargs=-1)
@click.argument('version')
Expand Down Expand Up @@ -33,7 +35,7 @@ def build(files, version):
with open(file, "w") as a_file:
a_file.truncate()
a_file.write(data)
print("Done")
print("Updated version in library.properties")

if __name__ == '__main__':
build()
2 changes: 2 additions & 0 deletions version
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ if [[ "$part_to_increment" =~ ^[1-3]$ ]]; then
python3 .scripts/version.py library.* $incremented_version
# Update keywords
python3 .scripts/keywords.py src/*.h
# Update Bug Report Template
python3 .scripts/bugreport.py $incremented_version
else
echo "Invalid part to increment. Please provide a valid part (1, 2, or 3)."
exit 1
Expand Down

0 comments on commit fe79454

Please sign in to comment.