-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[action/ci] 定时发布release版本 #10162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
hydevcode
wants to merge
1
commit into
RT-Thread:master
Choose a base branch
from
hydevcode:auto_release
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+97
−0
Draft
[action/ci] 定时发布release版本 #10162
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# | ||
# Copyright (c) 2025, RT-Thread Development Team | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Change Logs: | ||
# Date Author Notes | ||
# 2025-04-01 Hydevcode 定时自动发送Release版本 | ||
# | ||
name: Auto Release with PR Notes | ||
|
||
on: | ||
schedule: | ||
- cron: '0 16 * 3,6,9,12 *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == 'RT-Thread' | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # 获取完整提交历史 | ||
|
||
- name: Get Previous Tag | ||
id: prev_tag | ||
run: | | ||
# 获取上一个发布的标签(排除预发布标签) | ||
PREV_TAG=$(git describe --tags --abbrev=0 --match "v*" 2>/dev/null || echo "") | ||
echo "prev_tag=${PREV_TAG}" >> $GITHUB_OUTPUT | ||
echo "${PREV_TAG}" | ||
# 获取上一个版本的时间,如果有的话,没有就用基准时间 | ||
PREV_TIME=$(gh release list -L 1 --json publishedAt | jq '.[].publishedAt') | ||
|
||
echo "${PREV_TIME}" | ||
if [[ -z "$PREV_TIME" ]]; then | ||
# 基准时间 | ||
PREV_TIME="2025-04-01" | ||
echo "${PREV_TIME}" | ||
fi | ||
echo "prev_time=${PREV_TIME}" >> $GITHUB_OUTPUT | ||
|
||
echo "--------------------------------" | ||
if [[ -n "$PREV_TAG" ]]; then | ||
last_digit=$(echo "${PREV_TAG}" | grep -oE '[0-9]+$') | ||
new_last_digit=$((last_digit + 1)) | ||
echo "$new_last_digit" | ||
new_version=$(echo "$PREV_TAG" | sed "s/[0-9]\+$/$new_last_digit/") | ||
|
||
echo "$new_version" | ||
else | ||
echo "没有找到上一个版本" | ||
#默认第一个版本 | ||
new_version=v1.0.0 | ||
fi | ||
echo "new_version=${new_version}" >> $GITHUB_OUTPUT | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Generate PR List | ||
id: pr_list | ||
run: | | ||
# 获取两个标签之间的 PR 列表(使用 GitHub CLI) | ||
# 依靠的是上一个版本的时间 | ||
gh pr list \ | ||
--base master \ | ||
--state merged \ | ||
--search "merged:>=${{steps.prev_tag.outputs.prev_time}}" \ | ||
--json number,title,url \ | ||
--jq 'map("- [#\(.number)](\(.url)) \(.title)") | join("\n")' \ | ||
> pr_list.txt | ||
|
||
# 将 PR 列表保存为变量 | ||
PR_NOTES=$(cat pr_list.txt) | ||
|
||
# 统计当前到上一个版本的pr做成描述 | ||
RELEASE_NOTES="## ${{ steps.prev_tag.outputs.new_version }} ($(date -I))\n\n" | ||
if [ -n "$PR_NOTES" ]; then | ||
RELEASE_NOTES+="### Merged PRs since ${{ steps.prev_tag.outputs.prev_tag }}:\n" | ||
RELEASE_NOTES+="$PR_NOTES\n" | ||
else | ||
RELEASE_NOTES+="No new PRs since last release.\n" | ||
fi | ||
|
||
echo -e "$RELEASE_NOTES" > release_notes.md | ||
echo "$RELEASE_NOTES" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Publish Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
body_path: release_notes.md | ||
tag_name: ${{ steps.prev_tag.outputs.new_version }} | ||
name: RT-Thread ${{ steps.prev_tag.outputs.new_version }} released | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是如何保证版本的稳定性的?