Skip to content

Commit 38eea5a

Browse files
Merge pull request #19 from Flyleague-Collection/issue-template
feat: 细化issue例子(#17)
2 parents 3e2dcd8 + 92a4397 commit 38eea5a

File tree

7 files changed

+121
-9
lines changed

7 files changed

+121
-9
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

.github/workflows/release.yml

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
1-
# 导出 build 分支且只包含其文件,防止 workflow 污染
2-
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-release:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Get latest tag and next version
20+
id: versions
21+
run: |
22+
# 获取最新标签
23+
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
24+
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT
25+
26+
# 生成下一个版本(基于时间戳)
27+
next_version="v$(date +%Y%m%d%H%M%S)"
28+
echo "next_version=$next_version" >> $GITHUB_OUTPUT
29+
330
- name: Prepare build branch for release artifacts
431
run: |
532
rm -rf build_files
@@ -28,17 +55,21 @@
2855
- name: Advanced release note formatting and empty artifact checks
2956
id: generate_body
3057
run: |
31-
last_tag="${{ steps.latest_tag.outputs.value }}"
32-
version="${{ steps.next_version.outputs.value }}"
58+
last_tag="${{ steps.versions.outputs.latest_tag }}"
59+
version="${{ steps.versions.outputs.next_version }}"
3360
n_commit=$(git log "$last_tag"..HEAD --pretty=format:"%h" | wc -l)
3461
n_contrib=$(git log "$last_tag"..HEAD --pretty=format:"%an" | sort | uniq | wc -l)
3562
body="${version} 最新发行版\n\n本次更新共 ${n_commit} 个 commit,${n_contrib} 位贡献者。\n\n---\n"
36-
# ... 分组 commit 分类 shell 如你现有 …
63+
64+
# 如果有commit分类逻辑可以在这里添加
65+
# body+="分组commit内容..."
66+
3767
body+="\n---\n"
3868
body+="### 贡献者\n"
39-
git log "$last_tag"..HEAD --pretty=format:"%an" | sort | uniq | awk '{print "- " $0}' >> contributors.txt
69+
git log "$last_tag"..HEAD --pretty=format:"%an" | sort | uniq | awk '{print "- " $0}' > contributors.txt
4070
body+="$(cat contributors.txt)\n"
4171
body+="\n---\n"
72+
4273
# 附件格式优化
4374
size=$(cat build-artifacts.size)
4475
hash=$(cat build-artifacts.sha256)
@@ -60,9 +91,9 @@
6091
- name: Create & Publish Release With Artifact
6192
uses: ncipollo/release-action@v1
6293
with:
63-
tag: ${{ steps.next_version.outputs.value }}
64-
name: "Operating-document ${{ steps.next_version.outputs.value }} 最新发行版"
94+
tag: ${{ steps.versions.outputs.next_version }}
95+
name: "Operating-document ${{ steps.versions.outputs.next_version }} 最新发行版"
6596
body: ${{ steps.generate_body.outputs.body }}
6697
artifacts: build-artifacts.zip
6798
draft: false
68-
prerelease: false
99+
prerelease: false
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Sync Issue Templates
2+
on:
3+
schedule:
4+
# 每周一凌晨0点(UTC时间)自动同步,相当于北京时间周一早上8点
5+
- cron: '0 0 * * 1'
6+
workflow_dispatch: # 支持手动触发
7+
push:
8+
branches: [ main ]
9+
paths:
10+
- '.github/workflows/sync-templates.yml' # 当工作流文件本身更新时也触发
11+
12+
jobs:
13+
sync-templates:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write # 需要写入权限来提交更改
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
fetch-depth: 0 # 获取所有历史记录,便于推送
24+
25+
- name: Set up Git
26+
run: |
27+
git config --global user.name "github-actions[bot]"
28+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
29+
30+
- name: Sync templates from issue-templates repository
31+
run: |
32+
# 克隆模板仓库到临时目录
33+
git clone https://github.com/Flyleague-Collection/issue-templates temp-templates
34+
35+
# 确保目标目录存在
36+
mkdir -p .github/ISSUE_TEMPLATE
37+
38+
# 备份可能存在的自定义配置文件(如果有的话)
39+
if [ -f ".github/ISSUE_TEMPLATE/config.yml" ]; then
40+
cp .github/ISSUE_TEMPLATE/config.yml config-backup.yml
41+
fi
42+
43+
# 复制所有模板文件(排除可能不需要的文件)
44+
cp -r temp-templates/.github/ISSUE_TEMPLATE/* .github/ISSUE_TEMPLATE/ || true
45+
46+
# 如果有备份的配置文件,恢复它(保持仓库特定的配置)
47+
if [ -f "config-backup.yml" ]; then
48+
cp config-backup.yml .github/ISSUE_TEMPLATE/config.yml
49+
rm config-backup.yml
50+
fi
51+
52+
# 清理临时目录
53+
rm -rf temp-templates
54+
55+
- name: Check for changes
56+
id: changes
57+
run: |
58+
# 检查是否有文件变更
59+
if git diff --quiet; then
60+
echo "changes=false" >> $GITHUB_OUTPUT
61+
echo "🔄 没有检测到模板变更"
62+
else
63+
echo "changes=true" >> $GITHUB_OUTPUT
64+
echo "📝 检测到模板变更"
65+
git status
66+
git diff --name-only
67+
fi
68+
69+
- name: Commit and push if changes
70+
if: steps.changes.outputs.changes == 'true'
71+
run: |
72+
git add .github/ISSUE_TEMPLATE/
73+
git commit -m "🔁 chore: 自动同步最新的 issue 模板 [skip ci]"
74+
git push origin main
75+
76+
echo "✅ 模板同步完成并已提交"
77+
78+
- name: No changes
79+
if: steps.changes.outputs.changes == 'false'
80+
run: |
81+
echo "✅ 模板已是最新版本,无需更新"

0 commit comments

Comments
 (0)