Skip to content

Commit

Permalink
chore: update changelog config
Browse files Browse the repository at this point in the history
  • Loading branch information
mobiusklein committed May 5, 2024
1 parent eb5f4dc commit 5e957af
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
35 changes: 34 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,37 @@ update-cv:
https://github.com/HUPO-PSI/psi-ms-CV/releases/latest/download/psi-ms.obo | gzip -c > cv/psi-ms.obo.gz

update-cv-terms:
cog -c -r -U src/meta/software.rs src/meta/instrument.rs
cog -c -r -U src/meta/software.rs src/meta/instrument.rs

changelog:
#!/usr/bin/env python
import subprocess
import re

new_content = subprocess.check_output(['git', 'cliff', '-s', 'all', '-u', '--bump'], stderr=subprocess.DEVNULL).decode()

new_version = subprocess.check_output(
["git", "cliff", "--bumped-version"], stderr=subprocess.DEVNULL
).decode().strip()

buffer = open('CHANGELOG.md').read()

buffer = buffer.replace("## ", f"{new_content}## ", 1).splitlines()

offset = buffer.index("<!-- Versions -->") + 1
line_to_patch = buffer[offset]
buffer[offset] = re.sub(r"v\d+\.\d+\.\d+[^\.]*", new_version, line_to_patch)
version_link_template = buffer[offset + 1]
version_link_template = re.sub(
r"\d+\.\d+\.\d+[^\.]*(?=\])", new_version[1:], version_link_template
)
version_link_template = re.sub(
r"v\d+\.\d+\.\d+[^\.]*", new_version, version_link_template
)

buffer.insert(offset + 1, version_link_template)

buffer = '\n'.join(buffer)
open('CHANGELOG.md', 'wt').write(buffer)

3 changes: 1 addition & 2 deletions cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ commit_parsers = [
{ message = "^test", group = "Fixed" },
{ message = "^fix", group = "Fixed" },
{ message = "^.*: fix", group = "Fixed" },
{ message = "^chore", group = "Maintenance" },
{ message = "^doc", group = "Documentation" },
{ message = "^.*", group = "Changed" },
{ message = "^.: change(d?)*", group = "Changed" },
]
# protect breaking changes from being skipped due to matching a skipping commit_parser
protect_breaking_commits = false
Expand Down

0 comments on commit 5e957af

Please sign in to comment.