mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 04:31:50 +08:00
Enhance ci workflow (#7807)
* Update parse-changelog.py * Update ci.yml * Update ci.yml * Update parse-changelog.py
This commit is contained in:
parent
0d71170331
commit
3b6afae6c6
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
@ -25,13 +25,22 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: "3.10"
|
||||||
- run: pip install PyGithub
|
- run: pip install PyGithub
|
||||||
|
|
||||||
|
- id: thislatestR
|
||||||
|
uses: pozetroninc/github-action-get-latest-release@master
|
||||||
|
with:
|
||||||
|
# owner: siyuan-note
|
||||||
|
# repo: siyuan
|
||||||
|
repository: ${{ github.repository }}
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
excludes: prerelease, draft
|
||||||
|
|
||||||
- name: Gather Release Information
|
- name: Gather Release Information
|
||||||
id: release_info
|
id: release_info
|
||||||
run: |
|
run: |
|
||||||
echo "release_title=$(git show --format=%s --no-patch | head -1)" >> $GITHUB_OUTPUT
|
echo "release_title=$(git show --format=%s --no-patch | head -1)" >> $GITHUB_OUTPUT
|
||||||
echo "release_version=$(TZ=Asia/Shanghai date +'v%Y%m%d%H%M')" >> $GITHUB_OUTPUT
|
echo "release_version=$(TZ=Asia/Shanghai date +'v%Y%m%d%H%M')" >> $GITHUB_OUTPUT
|
||||||
changelog=$(python scripts/parse-changelog.py -t ${{ github.ref }} siyuan-note/siyuan)
|
changelog=$(python scripts/parse-changelog.py -t ${{ github.ref }} -b ${{ steps.thislatestR.outputs.release }} siyuan-note/siyuan)
|
||||||
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
|
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
|
||||||
echo "release_body<<$EOF" >> $GITHUB_ENV
|
echo "release_body<<$EOF" >> $GITHUB_ENV
|
||||||
echo "$changelog" >> $GITHUB_ENV
|
echo "$changelog" >> $GITHUB_ENV
|
||||||
@ -143,7 +152,7 @@ jobs:
|
|||||||
working-directory: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/app
|
working-directory: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/app
|
||||||
|
|
||||||
- name: Install Node Dependencies
|
- name: Install Node Dependencies
|
||||||
run: pnpm install
|
run: pnpm install --no-frozen-lockfile
|
||||||
working-directory: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/app
|
working-directory: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/app
|
||||||
|
|
||||||
- name: Building UI
|
- name: Building UI
|
||||||
|
@ -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.
|
"""Generate changelog messages from repository and tag name.
|
||||||
|
|
||||||
Envs:
|
Envs:
|
||||||
@ -33,7 +33,7 @@ def generate_msg_from_repo(repo_name, tag_name):
|
|||||||
|
|
||||||
gh = github.Github(token, base_url=f"https://{hostname}")
|
gh = github.Github(token, base_url=f"https://{hostname}")
|
||||||
repo = gh.get_repo(repo_name)
|
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):
|
for issue in repo.get_issues(state="closed", milestone=milestone):
|
||||||
# REF https://pygithub.readthedocs.io/en/latest/github_objects/Issue.html#github.Issue.Issue
|
# 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)
|
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
|
"""Find the milestone in a repository that is similar to milestone title
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -55,9 +55,21 @@ def find_milestone(repo, title):
|
|||||||
If no milestone matches, it will return None
|
If no milestone matches, it will return None
|
||||||
"""
|
"""
|
||||||
pat = re.search("v([0-9.]+)", title)
|
pat = re.search("v([0-9.]+)", title)
|
||||||
|
thisRelease = title.split("/")[-1]
|
||||||
if not pat:
|
if not pat:
|
||||||
return None
|
return None
|
||||||
version = pat.group(1)
|
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():
|
for milestone in repo.get_milestones():
|
||||||
if version in milestone.title:
|
if version in milestone.title:
|
||||||
return milestone
|
return milestone
|
||||||
@ -88,10 +100,11 @@ if __name__ == "__main__":
|
|||||||
description="Automaticly generate information from issues by tag."
|
description="Automaticly generate information from issues by tag."
|
||||||
)
|
)
|
||||||
parser.add_argument("-t", "--tag", help="the tag to filter issues.")
|
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")
|
parser.add_argument("repo", help="The repository name")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
generate_msg_from_repo(args.repo, args.tag)
|
generate_msg_from_repo(args.repo, args.tag, args.lastestRelease)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
print(args.tag)
|
print(args.tag)
|
||||||
|
Loading…
Reference in New Issue
Block a user