From c004ec6bfe206949c32573cd1ca53bfd525ca7fa Mon Sep 17 00:00:00 2001 From: feige996 <1020102647@qq.com> Date: Thu, 22 May 2025 18:52:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?ci:=20=E6=9B=B4=E6=96=B0=20GitHub=20Actions?= =?UTF-8?q?=20=E4=B8=AD=E7=9A=84=20actions/checkout=20=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=88=B0=20v4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新 GitHub Actions 配置文件中的 actions/checkout 版本,以使用最新的稳定版本 v4,确保工作流的兼容性和安全性 --- .github/workflows/auto-merge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index 8efc862..a84e52e 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GH_TOKEN_AUTO_MERGE }} From 4d51cc7881874cd1b07f59948d4e687218d90333 Mon Sep 17 00:00:00 2001 From: feige996 <1020102647@qq.com> Date: Thu, 22 May 2025 18:57:35 +0800 Subject: [PATCH 2/3] =?UTF-8?q?ci:=20=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=B7=A5=E4=BD=9C=E6=B5=81=E5=92=8C=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加 `.github/release.yml` 和 `.github/workflows/release.yml` 文件,用于配置和自动化发布流程。发布工作流会在推送标签时触发,生成更新日志并创建 GitHub 发布。 --- .github/release.yml | 31 +++++++++ .github/workflows/release.yml | 119 ++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 .github/release.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..f31e34c --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,31 @@ +categories: + - title: '🚀 新功能' + labels: ['feat', 'feature'] + - title: '🛠️ 修复' + labels: ['fix', 'bugfix'] + - title: '💅 样式' + labels: ['style'] + - title: '📄 文档' + labels: ['docs'] + - title: '⚡️ 性能' + labels: ['perf'] + - title: '🧪 测试' + labels: ['test'] + - title: '♻️ 重构' + labels: ['refactor'] + - title: '📦 构建' + labels: ['build'] + - title: '🚨 补丁' + labels: ['patch', 'hotfix'] + - title: '🌐 发布' + labels: ['release', 'publish'] + - title: '🔧 流程' + labels: ['ci', 'cd', 'workflow'] + - title: '⚙️ 配置' + labels: ['config', 'chore'] + - title: '📁 文件' + labels: ['file'] + - title: '🎨 格式化' + labels: ['format'] + - title: '🔀 其他' + labels: ['other', 'misc'] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c2887ab --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,119 @@ +name: Auto Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + pull-requests: read + issues: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install yq + run: sudo snap install yq + + - name: Generate changelog + id: changelog + env: + CONFIG_FILE: .github/release.yml + run: | + # 解析配置文件 + declare -A category_map + while IFS=";" read -r title labels; do + for label in $labels; do + category_map[$label]="$title" + done + done < <(yq -o=tsv '.categories[] | [.title, (.labels | join(" "))] | join(";")' $CONFIG_FILE) + # 获取版本范围 + mapfile -t tags < <(git tag -l --sort=-version:refname) + current_tag=${tags[0]} + previous_tag=${tags[1]:-} + if [[ -z "$previous_tag" ]]; then + commit_range="$current_tag" + echo "首次发布版本: $current_tag" + else + commit_range="$previous_tag..$current_tag" + echo "版本范围: $commit_range" + fi + # 获取所有符合规范的提交 + commits=$(git log --pretty=format:"%s|%h" "$commit_range") + # 生成分类日志 + declare -A log_entries + while IFS="|" read -r subject hash; do + # type=$(echo "$subject" | cut -d':' -f1 | tr -d ' ') + type=$(echo "$subject" | sed -E 's/^([[:alnum:]]+)(\(.*\))?:.*/\1/' | tr -d ' ') + found=0 + for label in "${!category_map[@]}"; do + if [[ "$type" == "$label" ]]; then + entry="- ${subject} (${hash:0:7})" + log_entries[${category_map[$label]}]+="$entry"$'\n' + found=1 + break + fi + done + if [[ $found -eq 0 ]]; then + entry="- ${subject} (${hash:0:7})" + log_entries["其他"]+="$entry"$'\n' + fi + done <<< "$commits" + + # 统计提交数量 + commit_count=$(git log --oneline "$commit_range" | wc -l) + # 统计受影响的文件数量 + file_count=$(git diff --name-only "$commit_range" | wc -l) + # 统计贡献者信息 + contributor_stats=$(git shortlog -sn "$commit_range") + contributor_notes="" + while IFS= read -r line; do + commits=$(echo "$line" | awk '{print $1}') + name=$(echo "$line" | awk '{$1=""; print $0}' | sed 's/^ //') + contributor_notes+="- @${name} (${commits} commits)\n" + done <<< "$contributor_stats" + # 构建输出内容 + release_notes="## 版本更新日志 ($current_tag)\n\n" + while IFS= read -r category; do + if [[ -n "${log_entries[$category]}" ]]; then + release_notes+="### $category\n${log_entries[$category]}\n" + fi + done < <(yq '.categories[].title' $CONFIG_FILE) + # 构建输出内容 + release_notes="## 版本更新日志 ($current_tag)\n\n" + current_date=$(date +"%Y-%m-%d") + # 添加发布日期和下载统计信息 + release_notes+=" ### 📅 发布日期: ${current_date}\n" + while IFS= read -r category; do + if [[ -n "${log_entries[$category]}" ]]; then + release_notes+="### $category\n${log_entries[$category]}\n" + fi + done < <(yq '.categories[].title' $CONFIG_FILE) + + # 添加统计信息 + release_notes+="### 📊 统计信息\n" + release_notes+="- 本次发布包含 ${commit_count} 个提交\n" + release_notes+="- 影响 ${file_count} 个文件\n\n" + # 添加贡献者信息 + release_notes+="### 👥 贡献者\n" + release_notes+="感谢这些优秀的贡献者(按提交次数排序):\n" + release_notes+="${contributor_notes}\n" + release_notes+="---\n" + # 写入文件 + echo -e "$release_notes" > changelog.md + echo "生成日志内容:" + cat changelog.md + - name: Create Release + uses: ncipollo/release-action@v1 + with: + generateReleaseNotes: false + bodyFile: changelog.md + tag: ${{ github.ref_name }} From da32e6da0c88db37013c79ff84134446915c8773 Mon Sep 17 00:00:00 2001 From: feige996 <1020102647@qq.com> Date: Thu, 22 May 2025 18:59:17 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=20package.json?= =?UTF-8?q?=20=E4=B8=AD=E7=9A=84=E7=89=88=E6=9C=AC=E5=8F=B7=E8=87=B3=202.8?= =?UTF-8?q?.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 51aeda9..b68a085 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "unibest", "type": "commonjs", - "version": "2.8.0", + "version": "2.8.1", "description": "unibest - 最好的 uniapp 开发模板", "author": { "name": "feige996",