From deddb3bbca1c9a298bbc6cebc449396a1d67e2f7 Mon Sep 17 00:00:00 2001 From: xiangzihao <460888207@qq.com> Date: Fri, 30 Aug 2024 17:42:14 +0800 Subject: [PATCH] [Chore] Improve release doc (#16553) * improve release doc --- .gitignore | 1 + docs/docs/en/contribute/release.md | 2 +- docs/docs/zh/contribute/release.md | 2 +- tools/release/README.md | 2 +- tools/release/github/changelog.py | 20 ++++++++++++++++++-- tools/release/release.py | 6 +++++- 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 813ad9c4bc..174ab57242 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,4 @@ dolphinscheduler-common/test dolphinscheduler-worker/logs dolphinscheduler-master/logs dolphinscheduler-api/logs +__pycache__ diff --git a/docs/docs/en/contribute/release.md b/docs/docs/en/contribute/release.md index 2bccc166c1..1ee8979428 100644 --- a/docs/docs/en/contribute/release.md +++ b/docs/docs/en/contribute/release.md @@ -386,7 +386,7 @@ Decompress `apache-dolphinscheduler--bin.tar.gz` to check the following You should create a release note in GitHub by [new release note](https://github.com/apache/dolphinscheduler/releases/new). It should be done before vote mail because we need the release note in the mail. You could use command -`python release.py changelog` in directory `tools/release` to creat the changelog. +`python release.py changelog` in directory `tools/release` to creat the changelog.([Usage](https://github.com/apache/dolphinscheduler/blob/dev/tools/release/README.md) > NOTE: Or if you prefer to create manually, you can use command `git log --pretty="- %s" .. > changelog.md` > (some log maybe not correct, you should filter them by yourself) and classify them and paste them to GitHub release note page diff --git a/docs/docs/zh/contribute/release.md b/docs/docs/zh/contribute/release.md index 8d3eda60a7..b5c61fcfed 100644 --- a/docs/docs/zh/contribute/release.md +++ b/docs/docs/zh/contribute/release.md @@ -393,7 +393,7 @@ svn --username="${A_USERNAME}" commit -m "release ${VERSION}" 在 GitHub 中通过 [创建新的 release note](https://github.com/apache/dolphinscheduler/releases/new) 创建一个 release note。 这要在 投票邮件开始之前完成,因为我们需要在邮件中使用 release note。你可以在 `tools/release` 目录中运行 `python release.py changelog` 自动创建 -changelog. +changelog.([使用方式](https://github.com/apache/dolphinscheduler/blob/dev/tools/release/README.md)) > 备注: 如果你更加倾向于手动创建 changelog,你可以通过命令 `git log --pretty="- %s" .. > changelog.md` > 生成 changelog(部分可以不太准确,需要人为过滤一遍),然后将他们分类并粘贴到 GitHub 的 release note 中 diff --git a/tools/release/README.md b/tools/release/README.md index d2bd5ca61a..4e8718f985 100644 --- a/tools/release/README.md +++ b/tools/release/README.md @@ -4,7 +4,7 @@ A tools for convenient release DolphinScheduler. ## Prepare -* python: python 3.6 or above +* python: python 3.6 or higher * pip: latest version of pip is better To install dependence, you should run command diff --git a/tools/release/github/changelog.py b/tools/release/github/changelog.py index 76c2c4152f..68f3b902fa 100644 --- a/tools/release/github/changelog.py +++ b/tools/release/github/changelog.py @@ -25,7 +25,7 @@ class Changelog: Each pull requests will only once in final result. If pull requests have more than one label we need, will classify to high priority label type, currently priority is - `feature > bug > improvement > document > chore`. pr will into feature section if it with both `feature`, + `dsip > feature > bug > improvement > document > chore`. pr will into feature section if it with both `feature`, `improvement`, `document` label. :param prs: pull requests list. @@ -35,6 +35,7 @@ class Changelog: key_labels = "labels" key_name = "name" + label_dsip = "dsip" label_feature = "feature" label_bug = "bug" label_improvement = "improvement" @@ -46,6 +47,7 @@ class Changelog: def __init__(self, prs: List[Dict]): self.prs = prs + self.dsips = [] self.features = [] self.bugfixs = [] self.improvements = [] @@ -57,6 +59,9 @@ class Changelog: """Generate changelog.""" self.classify() final = [] + if self.dsips: + detail = f"## DSIP{self.changelog_prefix}{self._convert(self.dsips)}{self.changelog_suffix}" + final.append(detail) if self.features: detail = f"## Feature{self.changelog_prefix}{self._convert(self.features)}{self.changelog_suffix}" final.append(detail) @@ -98,7 +103,9 @@ class Changelog: for pr in self.prs: if self.key_labels not in pr: raise KeyError("PR %s do not have labels", pr[self.key_number]) - if self._is_feature(pr): + if self._is_dsip(pr): + self.dsips.append(pr) + elif self._is_feature(pr): self.features.append(pr) elif self._is_bugfix(pr): self.bugfixs.append(pr) @@ -111,6 +118,15 @@ class Changelog: else: self.others.append(pr) + def _is_dsip(self, pr: Dict) -> bool: + """Belong to dsip pull requests.""" + return any( + [ + label[self.key_name].lower() == self.label_dsip + for label in pr[self.key_labels] + ] + ) + def _is_feature(self, pr: Dict) -> bool: """Belong to feature pull requests.""" return any( diff --git a/tools/release/release.py b/tools/release/release.py index 122e57caaf..32b6f86a38 100644 --- a/tools/release/release.py +++ b/tools/release/release.py @@ -92,7 +92,7 @@ def build_argparse() -> argparse.ArgumentParser: if __name__ == "__main__": arg_parser = build_argparse() - # args = arg_parser.parse_args(["cherry-pick"]) + # args = arg_parser.parse_args(["changelog"]) args = arg_parser.parse_args() ENV_ACCESS_TOKEN = os.environ.get("GH_ACCESS_TOKEN", None) @@ -103,4 +103,8 @@ if __name__ == "__main__": "Environment variable `GH_ACCESS_TOKEN` and `GH_REPO_MILESTONE` must provider" ) + if not hasattr(args, "func"): + arg_parser.print_help() + exit(1) + print(args.func(ENV_ACCESS_TOKEN, ENV_MILESTONE))