Skip to content

Commit

Permalink
支持输出安卓repo的issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Soltus committed Mar 21, 2024
1 parent 74a1fe0 commit ea5626d
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 25 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,14 @@ jobs:
run: |
echo "release_title=$(git show --format=%s --no-patch | head -1)" >> $GITHUB_OUTPUT
echo "release_version=v${{ steps.version.outputs.value }}_$(TZ=Asia/Shanghai date +'%Y%m%d')_syv${{ steps.syv.outputs.value }}" >> $GITHUB_OUTPUT
changelog=$(python scripts/parse-changelog-sillot.py -t ${{ github.ref }} -b ${{ steps.thislatestR.outputs.release }} Hi-Windom/Sillot)
changelog1=$(python scripts/parse-changelog-HEAD.py -t ${{ github.ref }} -b ${{ steps.thislatestR.outputs.release }} Hi-Windom/Sillot)
changelog2=$(python scripts/parse-changelog-sillot.py -t ${{ github.ref }} Hi-Windom/Sillot)
changelog3=$(python scripts/parse-changelog-sillot.py -t ${{ github.ref }} Hi-Windom/Sillot-android)
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "release_body_sillot<<$EOF" >> $GITHUB_ENV
echo "$changelog" >> $GITHUB_ENV
echo "$changelog1" >> $GITHUB_ENV
echo "$changelog2" >> $GITHUB_ENV
echo "$changelog3" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sillot",
"version": "0.27.18",
"version": "0.27.19",
"syv": "3.0.5",
"sypv": "3.0.4",
"description": "Build Your Eternal Digital Garden",
Expand Down
61 changes: 61 additions & 0 deletions scripts/parse-changelog-HEAD.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import os
import re
from argparse import ArgumentParser
from collections import defaultdict

import github # pip install PyGithub

# ensure the milestone is open before run this
docmap = {
"Feature": "引入特性 | Feature",
"Enhancement": "改进功能 | Enhancement",
"Bug": "修复错误 | Bugfix",
"Security": "安全相关 | Security",
"Document": "文档相关 | Document",
"Refactor": "开发重构 | Refactor",
"Abolishment": "移除废止 | Abolishment",
"Shinning": "闪亮之名 | Shinning",
}


def generate_msg_from_repo(repo_name, tag_name, lastestRelease):
thisRelease = tag_name.split("/")[-1]
pat = re.search("v([0-9.]+)", thisRelease)
if not pat:
return None

print(f'''
---
<p align="center">
<a href="https://github.com/Hi-Windom/Sillot/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/Hi-Windom/Sillot/ci.yml?event=push&label=ci.yml%20Action&logo=github" style="cursor:pointer;height: 30px;margin: 3px auto;"/></a>
<a href="https://github.com/Hi-Windom/Sillot/releases/{thisRelease}/"><img src="https://img.shields.io/github/downloads/Hi-Windom/Sillot/{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/Hi-Windom/Sillot?base={lastestRelease}&head={thisRelease}&logo=git" style="cursor:pointer;height: 30px;margin: 3px auto;"/>
</p>
⚠️ 这是自动构建的开发者版本!数据无价,请勿用于生产环节
❤️ 欢迎共建汐洛 694357845@qq.com
🚧 [{repo_name} is currently in active development](https://github.com/orgs/Hi-Windom/projects/2/views/2)
🚢 [Docker image](https://hub.docker.com/r/soltus/sillot/tags?page=1&ordering=last_updated) 📱 [Android application package](https://github.com/Hi-Windom/Sillot-android/releases) 📦 [Chromium Browser Extension](https://github.com/K-Sillot/Sillot-Be/releases)
<span>
<img src="https://img.shields.io/badge/Chromium 94+-black?logo=Google Chrome&logoColor=white" alt="" title=""/><img src="https://img.shields.io/badge/Windows 10+-black?logo=Windows 11" title=""/><img src="https://img.shields.io/badge/macOS-black?logo=apple" title=""/><img src="https://img.shields.io/badge/Docker-black?logo=docker" title=""/><img src="https://img.shields.io/badge/Android 11+-black?logo=android" title=""/>
</span>
---
''')


if __name__ == "__main__":
parser = ArgumentParser(
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, args.lastestRelease)
except AssertionError:
print(args.tag)
25 changes: 3 additions & 22 deletions scripts/parse-changelog-sillot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def generate_msg_from_repo(repo_name, tag_name, lastestRelease):
repo_name (str): The repository name
tag_name (str): the tag name
"""
print(f'# [@{repo_name.split("/")[-1]}](https://github.com/{repo_name})\n')
hostname = os.getenv("GITHUB_HOST") or "api.github.com"
token = os.getenv("GITHUB_TOKEN")
desc_mapping = defaultdict(list)
Expand All @@ -45,7 +46,7 @@ def generate_msg_from_repo(repo_name, tag_name, lastestRelease):
generate_msg(desc_mapping)


def find_milestone(repo, title, lastestRelease):
def find_milestone(repo, title):
"""Find the milestone in a repository that is similar to milestone title
Args:
Expand All @@ -61,26 +62,7 @@ def find_milestone(repo, title, lastestRelease):
if not pat:
return None
version = ".".join(pat.group(1).split(".")[:2])
print(f'''
---
<p align="center">
<a href="https://github.com/Hi-Windom/Sillot/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/Hi-Windom/Sillot/ci.yml?event=push&label=ci.yml%20Action&logo=github" style="cursor:pointer;height: 30px;margin: 3px auto;"/></a>
<a href="https://github.com/Hi-Windom/Sillot/releases/{thisRelease}/"><img src="https://img.shields.io/github/downloads/Hi-Windom/Sillot/{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/Hi-Windom/Sillot?base={lastestRelease}&head={thisRelease}&logo=git" style="cursor:pointer;height: 30px;margin: 3px auto;"/>
</p>
⚠️ 这是自动构建的开发者版本!数据无价,请勿用于生产环节
❤️ 欢迎共建汐洛 694357845@qq.com
🚧 [Sillot is currently in active development](https://github.com/orgs/Hi-Windom/projects/2/views/2)
🚢 [Docker image](https://hub.docker.com/r/soltus/sillot/tags?page=1&ordering=last_updated) 📱 [Android application package](https://github.com/Hi-Windom/Sillot-android/releases) 📦 [Chromium Browser Extension](https://github.com/K-Sillot/Sillot-Be/releases)
<span>
<img src="https://img.shields.io/badge/Chromium 94+-black?logo=Google Chrome&logoColor=white" alt="" title=""/><img src="https://img.shields.io/badge/Windows 10+-black?logo=Windows 11" title=""/><img src="https://img.shields.io/badge/macOS-black?logo=apple" title=""/><img src="https://img.shields.io/badge/Docker-black?logo=docker" title=""/><img src="https://img.shields.io/badge/Android 11+-black?logo=android" title=""/>
</span>
---
''')

# REF https://docs.github.com/en/rest/issues/milestones?apiVersion=2022-11-28#list-milestones
for milestone in repo.get_milestones():
if version in milestone.title:
Expand All @@ -101,7 +83,6 @@ def get_issue_first_label(issue):
def generate_msg(desc_mapping):
"""Print changelogs from direction."""
print()
print('# [@Sillot](https://github.com/Hi-Windom/Sillot)\n')
for header in docmap:
if not desc_mapping[header]:
continue
Expand Down

0 comments on commit ea5626d

Please sign in to comment.