Enhance ci workflow (#7807)

* Update parse-changelog.py

* Update ci.yml

* Update ci.yml

* Update parse-changelog.py
This commit is contained in:
绛亽 2023-03-29 08:44:33 +08:00 committed by GitHub
parent 0d71170331
commit 3b6afae6c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 6 deletions

View file

@ -16,7 +16,7 @@ docmap = {
}
def generate_msg_from_repo(repo_name, tag_name):
def generate_msg_from_repo(repo_name, tag_name, lastestRelease):
"""Generate changelog messages from repository and tag name.
Envs:
@ -33,7 +33,7 @@ def generate_msg_from_repo(repo_name, tag_name):
gh = github.Github(token, base_url=f"https://{hostname}")
repo = gh.get_repo(repo_name)
milestone = find_milestone(repo, tag_name)
milestone = find_milestone(repo, tag_name, lastestRelease)
for issue in repo.get_issues(state="closed", milestone=milestone):
# REF https://pygithub.readthedocs.io/en/latest/github_objects/Issue.html#github.Issue.Issue
@ -43,7 +43,7 @@ def generate_msg_from_repo(repo_name, tag_name):
generate_msg(desc_mapping)
def find_milestone(repo, title):
def find_milestone(repo, title, lastestRelease):
"""Find the milestone in a repository that is similar to milestone title
Args:
@ -55,9 +55,21 @@ def find_milestone(repo, title):
If no milestone matches, it will return None
"""
pat = re.search("v([0-9.]+)", title)
thisRelease = title.split("/")[-1]
if not pat:
return None
version = pat.group(1)
print(f'''
---
<p align="center">
<a href="https://github.com/siyuan-note/siyuan/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/siyuan-note/siyuan/ci.yml?event=push&label=ci.yml%20Action&logo=github" style="cursor:pointer;height: 30px;margin: 3px auto;"/></a>
<a href="https://github.com/siyuan-note/siyuan/releases/{thisRelease}/"><img src="https://img.shields.io/github/downloads/siyuan-note/siyuan/{thisRelease}/total?logo=github" style="cursor:pointer;height: 30px;margin: 3px auto;"/></a>
<img alt="GitHub commits difference between two branches/tags/commits" src="https://img.shields.io/github/commits-difference/siyuan-note/siyuan?base={lastestRelease}&head={thisRelease}&logo=git" style="cursor:pointer;height: 30px;margin: 3px auto;"/>
</p>
---
''')
for milestone in repo.get_milestones():
if version in milestone.title:
return milestone
@ -88,10 +100,11 @@ if __name__ == "__main__":
description="Automaticly generate information from issues by tag."
)
parser.add_argument("-t", "--tag", help="the tag to filter issues.")
parser.add_argument("-b", "--lastestRelease", help="lastest Release")
parser.add_argument("repo", help="The repository name")
args = parser.parse_args()
try:
generate_msg_from_repo(args.repo, args.tag)
generate_msg_from_repo(args.repo, args.tag, args.lastestRelease)
except AssertionError:
print(args.tag)