From 5648f73d45bd9011ea5f4f12334a49385358976c Mon Sep 17 00:00:00 2001 From: KenanZhu <3471685733@qq.com> Date: Tue, 23 Jun 2026 10:34:43 +0800 Subject: [PATCH] refactor(ci): use marker comments instead of regex for tracker workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add TRACKER: HTML comment markers to COMPATIBILITY.md, README.md, and all 5 translation READMEs. Rewrite gitea-tracker.yml to use grep -n for precise line-based insertion and sed line-address editing. Markers introduced: - TRACKER:QUICK-REF-MAX — Quick Reference max tested version - TRACKER:VERSION-INSERT — Version History row insertion point - TRACKER:LATEST-VERIFIED — latest verified note version - TRACKER:BADGE — shields.io badge version - TRACKER:LATEST-TESTED — latest tested version in READMEs Co-Authored-By: Claude --- .github/workflows/gitea-tracker.yml | 56 +++++++++++++++++------------ COMPATIBILITY.md | 4 ++- README.md | 4 +-- docs/README.ja.md | 2 +- docs/README.ko.md | 2 +- docs/README.ru.md | 2 +- docs/README.zh-CN.md | 2 +- docs/README.zh-TW.md | 2 +- 8 files changed, 43 insertions(+), 31 deletions(-) diff --git a/.github/workflows/gitea-tracker.yml b/.github/workflows/gitea-tracker.yml index 1e1e205..a2abf17 100644 --- a/.github/workflows/gitea-tracker.yml +++ b/.github/workflows/gitea-tracker.yml @@ -31,11 +31,13 @@ jobs: NEW_VERSION=$(echo "$RELEASE_JSON" | jq -r '.tag_name') fi echo "New Gitea version: $NEW_VERSION" - echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT - # Parse current max tested from COMPATIBILITY.md - CURRENT=$(grep -oP 'Max Tested Gitea.*?\|\s*\*\*\K[0-9.]+' COMPATIBILITY.md) + # Read current max-tested from the TRACKER:QUICK-REF-MAX marker line above it + MARKER_LINE=$(grep -n 'TRACKER:QUICK-REF-MAX' COMPATIBILITY.md | cut -d: -f1) + CURRENT=$(sed -n "$((MARKER_LINE - 1))p" COMPATIBILITY.md | grep -oP '\*\*[0-9.]+\*\*' | tail -1 | tr -d '*') echo "Current max tested: $CURRENT" + + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT echo "current_version=$CURRENT" >> $GITHUB_OUTPUT if [ "$NEW_VERSION" = "$CURRENT" ]; then @@ -46,50 +48,58 @@ jobs: echo "skip=false" >> $GITHUB_OUTPUT fi - - name: Update COMPATIBILITY.md — Quick Reference + # --- COMPATIBILITY.md --- + + - name: COMPATIBILITY.md — Quick Reference (max tested version) if: steps.version.outputs.skip != 'true' run: | NEW="${{ steps.version.outputs.new_version }}" - sed -i "s/|\*\*\([0-9.]*\)\*\* | \*\*[0-9.]*\*\* |/\|\*\*\1\*\* | \*\*${NEW}\*\* |/" COMPATIBILITY.md + # The Quick Reference row is the line directly above TRACKER:QUICK-REF-MAX + MARKER=$(grep -n 'TRACKER:QUICK-REF-MAX' COMPATIBILITY.md | cut -d: -f1) + TARGET=$((MARKER - 1)) + # Replace the last **X.Y.Z** in that line with the new version + sed -i "${TARGET}s/\*\*[0-9.]*\*\* | ✅/**${NEW}** | ✅/" COMPATIBILITY.md - - name: Update COMPATIBILITY.md — Version History table + - name: COMPATIBILITY.md — Version History table if: steps.version.outputs.skip != 'true' run: | NEW="${{ steps.version.outputs.new_version }}" TODAY=$(date +%Y-%m-%d) - # Insert new row after the table header (line with "|---|---") + # Insert a new row right after TRACKER:VERSION-INSERT marker + MARKER=$(grep -n 'TRACKER:VERSION-INSERT' COMPATIBILITY.md | cut -d: -f1) ROW="| **${NEW}** | ${TODAY} | ⏳ Pending Verification | TBD |" - sed -i "/^|---/a ${ROW}" COMPATIBILITY.md + sed -i "${MARKER}a ${ROW}" COMPATIBILITY.md - - name: Update COMPATIBILITY.md — latest verified note + - name: COMPATIBILITY.md — latest verified note if: steps.version.outputs.skip != 'true' run: | NEW="${{ steps.version.outputs.new_version }}" - # Update the "Latest verified" note - sed -i "s/Gitea [0-9.]* data contexts/Gitea ${NEW} data contexts/" COMPATIBILITY.md + # Update version inline on the line with TRACKER:LATEST-VERIFIED + sed -i "/TRACKER:LATEST-VERIFIED/s/Gitea [0-9.]*/Gitea ${NEW}/" COMPATIBILITY.md - - name: Update README.md badge + # --- README.md --- + + - name: README.md — badge and latest tested if: steps.version.outputs.skip != 'true' run: | NEW="${{ steps.version.outputs.new_version }}" - # Update the shields.io badge - sed -i "s/\(tested\)-[0-9a-z.]*\(blue\)/\1-${NEW}\2/" README.md - # Update the "Latest tested" line - sed -i "s/Latest tested:\*\* Gitea [0-9.]*/Latest tested:** Gitea ${NEW}/" README.md + # Badge: update version on the TRACKER:BADGE line + sed -i "/TRACKER:BADGE/s/tested\)-[0-9a-z.]*\(blue\)/tested\)-${NEW}\2/" README.md + # Latest tested: update version on the TRACKER:LATEST-TESTED line + sed -i "/TRACKER:LATEST-TESTED/s/Gitea [0-9.]*/Gitea ${NEW}/" README.md - - name: Update README translations + # --- Translation READMEs --- + + - name: README translations — latest tested if: steps.version.outputs.skip != 'true' run: | NEW="${{ steps.version.outputs.new_version }}" for f in docs/README.{ja,ko,ru,zh-CN,zh-TW}.md; do - # Update version number in the compatibility section - sed -i "s/テスト:\*\* Gitea [0-9.]*/テスト:** Gitea ${NEW}/" "$f" - sed -i "s/테스트:\*\* Gitea [0-9.]*/테스트:** Gitea ${NEW}/" "$f" - sed -i "s/проверка:\*\* Gitea [0-9.]*/проверка:** Gitea ${NEW}/" "$f" - sed -i "s/测试:\*\* Gitea [0-9.]*/测试:** Gitea ${NEW}/" "$f" - sed -i "s/測試:\*\* Gitea [0-9.]*/測試:** Gitea ${NEW}/" "$f" + sed -i "/TRACKER:LATEST-TESTED/s/Gitea [0-9.]*/Gitea ${NEW}/" "$f" done + # --- Create PR --- + - name: Create Pull Request if: steps.version.outputs.skip != 'true' uses: peter-evans/create-pull-request@v7 diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index 4063df1..1965213 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -6,9 +6,10 @@ This document tracks the compatibility between **Gitea Mail Templates** releases | Template Release | Min Gitea | Max Tested Gitea | Status | |-----------------|-----------|-----------------|--------| + | **v1.0.x** | **1.25.0** | **1.26.4** | ✅ Active | -> **Latest verified:** All 11 templates pass validation against Gitea 1.26.4 data contexts. +> **Latest verified:** All 11 templates pass validation against Gitea 1.26.4 data contexts. ## Check Your Gitea Version @@ -20,6 +21,7 @@ gitea --version ## Gitea Version History — Mail Template Impact + | Gitea | Release Date | Mail Template Changes | Breaking? | |-------|-------------|----------------------|-----------| | **1.26.4** | 2026-06-21 | None — hotfix release | No | diff --git a/README.md b/README.md index 4e0e319..482eadc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A curated collection of professionally designed, audience-driven email templates for self-hosted [Gitea](https://about.gitea.com) instances. -[![Gitea](https://img.shields.io/badge/Gitea-1.25+%20%7C%201.26.4%20tested-blue)](COMPATIBILITY.md) +[![Gitea](https://img.shields.io/badge/Gitea-1.25+%20%7C%201.26.4%20tested-blue)](COMPATIBILITY.md) > **110 template files — 10 visual styles, 11 email types each** @@ -164,7 +164,7 @@ gitea-mail-templates/ ## Compatibility - **Gitea 1.25+** — matches the refactored mail template directory structure (v1.25) -- **Latest tested:** Gitea 1.26.4 +- **Latest tested:** Gitea 1.26.4 - 100% variable-compatible with official Gitea templates — see [COMPATIBILITY.md](COMPATIBILITY.md) for the full matrix - Uses only built-in Gitea template functions and official translation keys - No custom template functions or locale patches required diff --git a/docs/README.ja.md b/docs/README.ja.md index 54143c4..79c0503 100644 --- a/docs/README.ja.md +++ b/docs/README.ja.md @@ -58,7 +58,7 @@ cd tools && go run . dev ## 互換性 - **Gitea 1.25+** — v1.25で導入されたメールテンプレートディレクトリ構造 -- **最新テスト:** Gitea 1.26.4 +- **最新テスト:** Gitea 1.26.4 - Gitea公式テンプレートと100%互換 — 詳細は [COMPATIBILITY.md](COMPATIBILITY.md)を参照 ## ライセンス diff --git a/docs/README.ko.md b/docs/README.ko.md index 53d341a..470bb45 100644 --- a/docs/README.ko.md +++ b/docs/README.ko.md @@ -58,7 +58,7 @@ cd tools && go run . dev ## 호환성 - **Gitea 1.25+** — v1.25에서 도입된 메일 템플릿 디렉토리 구조 사용 -- **최신 테스트:** Gitea 1.26.4 +- **최신 테스트:** Gitea 1.26.4 - Gitea 공식 템플릿과 100% 호환 — 자세한 내용은 [COMPATIBILITY.md](../COMPATIBILITY.md) 참조 ## 라이선스 diff --git a/docs/README.ru.md b/docs/README.ru.md index f524811..5660ced 100644 --- a/docs/README.ru.md +++ b/docs/README.ru.md @@ -58,7 +58,7 @@ cd tools && go run . dev ## Совместимость - **Gitea 1.25+** — структура директорий из v1.25 -- **Последняя проверка:** Gitea 1.26.4 +- **Последняя проверка:** Gitea 1.26.4 - 100% совместимость с официальными шаблонами Gitea — см. [COMPATIBILITY.md](COMPATIBILITY.md) ## Лицензия diff --git a/docs/README.zh-CN.md b/docs/README.zh-CN.md index 25fb1d7..4212035 100644 --- a/docs/README.zh-CN.md +++ b/docs/README.zh-CN.md @@ -79,7 +79,7 @@ cd tools && go run . dev ## 兼容性 - **Gitea 1.25+** — v1.25 引入的邮件模板目录结构 -- **最新测试:** Gitea 1.26.4 +- **最新测试:** Gitea 1.26.4 - 与 Gitea 官方模板 100% 兼容 — 详见 [COMPATIBILITY.md](COMPATIBILITY.md) ## 许可证 diff --git a/docs/README.zh-TW.md b/docs/README.zh-TW.md index 2ae19b4..777f69b 100644 --- a/docs/README.zh-TW.md +++ b/docs/README.zh-TW.md @@ -74,7 +74,7 @@ cd tools && go run . dev ## 相容性 - **Gitea 1.25+** — v1.25 引入的郵件模板目錄結構 -- **最新測試:** Gitea 1.26.4 +- **最新測試:** Gitea 1.26.4 - 與 Gitea 官方模板 100% 相容 — 詳見 [COMPATIBILITY.md](COMPATIBILITY.md) ## 授權