Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 40 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# 导出 build 分支且只包含其文件,防止 workflow 污染

name: Create Release

on:
push:
tags:
- 'v*'
workflow_dispatch:

jobs:
build-and-release:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get latest tag and next version
id: versions
run: |
# 获取最新标签
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT

# 生成下一个版本(基于时间戳)
next_version="v$(date +%Y%m%d%H%M%S)"
echo "next_version=$next_version" >> $GITHUB_OUTPUT

- name: Prepare build branch for release artifacts
run: |
rm -rf build_files
Expand Down Expand Up @@ -28,17 +55,21 @@
- name: Advanced release note formatting and empty artifact checks
id: generate_body
run: |
last_tag="${{ steps.latest_tag.outputs.value }}"
version="${{ steps.next_version.outputs.value }}"
last_tag="${{ steps.versions.outputs.latest_tag }}"
version="${{ steps.versions.outputs.next_version }}"
n_commit=$(git log "$last_tag"..HEAD --pretty=format:"%h" | wc -l)
n_contrib=$(git log "$last_tag"..HEAD --pretty=format:"%an" | sort | uniq | wc -l)
body="${version} 最新发行版\n\n本次更新共 ${n_commit} 个 commit,${n_contrib} 位贡献者。\n\n---\n"
# ... 分组 commit 分类 shell 如你现有 …

# 如果有commit分类逻辑可以在这里添加
# body+="分组commit内容..."

body+="\n---\n"
body+="### 贡献者\n"
git log "$last_tag"..HEAD --pretty=format:"%an" | sort | uniq | awk '{print "- " $0}' >> contributors.txt
git log "$last_tag"..HEAD --pretty=format:"%an" | sort | uniq | awk '{print "- " $0}' > contributors.txt
body+="$(cat contributors.txt)\n"
body+="\n---\n"

# 附件格式优化
size=$(cat build-artifacts.size)
hash=$(cat build-artifacts.sha256)
Expand All @@ -60,9 +91,9 @@
- name: Create & Publish Release With Artifact
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.next_version.outputs.value }}
name: "Operating-document ${{ steps.next_version.outputs.value }} 最新发行版"
tag: ${{ steps.versions.outputs.next_version }}
name: "Operating-document ${{ steps.versions.outputs.next_version }} 最新发行版"
body: ${{ steps.generate_body.outputs.body }}
artifacts: build-artifacts.zip
draft: false
prerelease: false
prerelease: false
81 changes: 81 additions & 0 deletions .github/workflows/sync-templates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Sync Issue Templates
on:
schedule:
# 每周一凌晨0点(UTC时间)自动同步,相当于北京时间周一早上8点
- cron: '0 0 * * 1'
workflow_dispatch: # 支持手动触发
push:
branches: [ main ]
paths:
- '.github/workflows/sync-templates.yml' # 当工作流文件本身更新时也触发

jobs:
sync-templates:
runs-on: ubuntu-latest
permissions:
contents: write # 需要写入权限来提交更改

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 # 获取所有历史记录,便于推送

- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Sync templates from issue-templates repository
run: |
# 克隆模板仓库到临时目录
git clone https://github.com/Flyleague-Collection/issue-templates temp-templates

# 确保目标目录存在
mkdir -p .github/ISSUE_TEMPLATE

# 备份可能存在的自定义配置文件(如果有的话)
if [ -f ".github/ISSUE_TEMPLATE/config.yml" ]; then
cp .github/ISSUE_TEMPLATE/config.yml config-backup.yml
fi

# 复制所有模板文件(排除可能不需要的文件)
cp -r temp-templates/.github/ISSUE_TEMPLATE/* .github/ISSUE_TEMPLATE/ || true

# 如果有备份的配置文件,恢复它(保持仓库特定的配置)
if [ -f "config-backup.yml" ]; then
cp config-backup.yml .github/ISSUE_TEMPLATE/config.yml
rm config-backup.yml
fi

# 清理临时目录
rm -rf temp-templates

- name: Check for changes
id: changes
run: |
# 检查是否有文件变更
if git diff --quiet; then
echo "changes=false" >> $GITHUB_OUTPUT
echo "🔄 没有检测到模板变更"
else
echo "changes=true" >> $GITHUB_OUTPUT
echo "📝 检测到模板变更"
git status
git diff --name-only
fi

- name: Commit and push if changes
if: steps.changes.outputs.changes == 'true'
run: |
git add .github/ISSUE_TEMPLATE/
git commit -m "🔁 chore: 自动同步最新的 issue 模板 [skip ci]"
git push origin main

echo "✅ 模板同步完成并已提交"

- name: No changes
if: steps.changes.outputs.changes == 'false'
run: |
echo "✅ 模板已是最新版本,无需更新"