From 842ab9fb32f5e823dab17c1096f0b24e83d1fef9 Mon Sep 17 00:00:00 2001 From: Erick52106 Date: Sun, 26 Apr 2026 20:32:26 +0800 Subject: [PATCH 1/7] =?UTF-8?q?chore:=20add=20weekly=20release=20PR=20work?= =?UTF-8?q?flow=EF=BC=88=E9=80=B1=E5=85=AD=2010:00=20UTC+8=20=E8=87=AA?= =?UTF-8?q?=E5=8B=95=E8=A7=B8=E7=99=BC=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs #365 Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/weekly-release-pr.yml | 65 +++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/weekly-release-pr.yml diff --git a/.github/workflows/weekly-release-pr.yml b/.github/workflows/weekly-release-pr.yml new file mode 100644 index 00000000..0f4785c6 --- /dev/null +++ b/.github/workflows/weekly-release-pr.yml @@ -0,0 +1,65 @@ +name: Weekly Release PR + +on: + schedule: + # 週六 10:00 UTC+8 = 週六 02:00 UTC + - cron: "0 2 * * 6" + workflow_dispatch: + +permissions: + contents: read + pull-requests: write + +jobs: + create-release-pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check if develop is ahead of main + id: check + run: | + git fetch origin main develop + COMMITS_AHEAD=$(git rev-list --count origin/main..origin/develop) + echo "commits_ahead=$COMMITS_AHEAD" >> "$GITHUB_OUTPUT" + echo "develop is $COMMITS_AHEAD commits ahead of main" + + - name: Skip if nothing to release + if: steps.check.outputs.commits_ahead == '0' + run: echo "develop is up to date with main, skipping." + + - name: Check for existing open release PR + if: steps.check.outputs.commits_ahead != '0' + id: existing + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + EXISTING=$(gh pr list --base main --head develop --state open --json number --jq '.[0].number') + echo "existing_pr=$EXISTING" >> "$GITHUB_OUTPUT" + if [ -n "$EXISTING" ]; then + echo "Release PR #$EXISTING already open, skipping." + fi + + - name: Create release PR + if: steps.check.outputs.commits_ahead != '0' && steps.existing.outputs.existing_pr == '' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + DATE=$(TZ=Asia/Taipei date +%Y-%m-%d) + COMMITS_AHEAD=${{ steps.check.outputs.commits_ahead }} + gh pr create \ + --base main \ + --head develop \ + --title "[release] develop → main ($DATE)" \ + --body "## Weekly Release — $DATE + +Auto-generated by weekly-release-pr workflow. + +**Commits ahead:** $COMMITS_AHEAD + +### Checklist +- [ ] CI 通過 +- [ ] 確認無 half-finished feature +- [ ] Merge" From 64c1e7890851ccf0e034b2880638e15e8ad0a3e2 Mon Sep 17 00:00:00 2001 From: Erick52106 Date: Sun, 26 Apr 2026 21:17:02 +0800 Subject: [PATCH 2/7] fix: resolve YAML indentation and skip logic issues in weekly-release-pr workflow - Fix 1: Replace multiline --body with heredoc to resolve YAML indentation error - Fix 2: Add clarifying comment for skip logic guard conditions refs #366 Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/weekly-release-pr.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/weekly-release-pr.yml b/.github/workflows/weekly-release-pr.yml index 0f4785c6..3e9ec18d 100644 --- a/.github/workflows/weekly-release-pr.yml +++ b/.github/workflows/weekly-release-pr.yml @@ -30,6 +30,7 @@ jobs: if: steps.check.outputs.commits_ahead == '0' run: echo "develop is up to date with main, skipping." + # 以下 step 全由 if: 條件守衛,不依賴上方 skip step 的 exit 狀態 - name: Check for existing open release PR if: steps.check.outputs.commits_ahead != '0' id: existing @@ -49,11 +50,8 @@ jobs: run: | DATE=$(TZ=Asia/Taipei date +%Y-%m-%d) COMMITS_AHEAD=${{ steps.check.outputs.commits_ahead }} - gh pr create \ - --base main \ - --head develop \ - --title "[release] develop → main ($DATE)" \ - --body "## Weekly Release — $DATE + cat > /tmp/release-pr-body.md < Date: Sun, 26 Apr 2026 21:45:57 +0800 Subject: [PATCH 3/7] chore: dispatch CI against develop after release PR creation refs #366 Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/weekly-release-pr.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/weekly-release-pr.yml b/.github/workflows/weekly-release-pr.yml index 3e9ec18d..947a76e3 100644 --- a/.github/workflows/weekly-release-pr.yml +++ b/.github/workflows/weekly-release-pr.yml @@ -67,3 +67,9 @@ EOF --head develop \ --title "[release] develop → main ($DATE)" \ --body-file /tmp/release-pr-body.md + + - name: Dispatch CI against develop + if: steps.check.outputs.commits_ahead != '0' && steps.existing.outputs.existing_pr == '' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh workflow run ci.yml --ref develop From 3acd20264c6062c65a7804196f756ce713ac368c Mon Sep 17 00:00:00 2001 From: Erick52106 Date: Sun, 26 Apr 2026 21:49:16 +0800 Subject: [PATCH 4/7] fix(scripts): guard depends_on_raw grep against set -e exit on no-match refs #366 Co-Authored-By: Claude Sonnet 4.6 --- scripts/pr-metadata-check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pr-metadata-check.sh b/scripts/pr-metadata-check.sh index 2bd4e4a6..43310335 100755 --- a/scripts/pr-metadata-check.sh +++ b/scripts/pr-metadata-check.sh @@ -221,7 +221,7 @@ main() { fi local depends_on_raw="" - depends_on_raw=$(grep -iE '^[[:space:]-]*Depends on PR[::][[:space:]]*' "$body_file" | head -n1 | sed -E 's/^[^::]*[::][[:space:]]*//' | sed 's/[[:space:]]*$//') + depends_on_raw=$(grep -iE '^[[:space:]-]*Depends on PR[::][[:space:]]*' "$body_file" | head -n1 | sed -E 's/^[^::]*[::][[:space:]]*//' | sed 's/[[:space:]]*$//' || true) if [ "$is_infra_or_chore" -eq 0 ] && [ "$is_release_promotion" -eq 0 ]; then grep -Eq '#[0-9]+' "$body_file" || failures+=("PR body 必須引用至少一個 issue 或 PR 編號,例如 #123") From 8d64502febd798d9ceca774c62cc56d49b70f25b Mon Sep 17 00:00:00 2001 From: Erick52106 Date: Sun, 26 Apr 2026 21:59:54 +0800 Subject: [PATCH 5/7] fix(workflow): add required scope police fields to release PR body template refs #366 Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/weekly-release-pr.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/weekly-release-pr.yml b/.github/workflows/weekly-release-pr.yml index 947a76e3..7fa5afcf 100644 --- a/.github/workflows/weekly-release-pr.yml +++ b/.github/workflows/weekly-release-pr.yml @@ -57,8 +57,27 @@ Auto-generated by weekly-release-pr workflow. **Commits ahead:** $COMMITS_AHEAD -### Checklist -- [ ] CI 通過 +## Scope 對齊 + +- Source of truth: develop release promotion on $DATE. +- Depends on PR: none + +Backend contract already in develop: +- [x] yes +- [ ] no + +If no, this PR is: +- [ ] stacked on dependency branch +- [ ] intentionally blocked until dependency merges + +## 本 PR 明確不做 + +- 不新增任何程式碼變更,僅將 develop promote 到 main。 +- 不修改任何未在 develop 上的內容。 + +## Checklist + +- [ ] CI 通過(Actions tab 查看 dispatch 結果) - [ ] 確認無 half-finished feature - [ ] Merge EOF From 63ea5fc2db04ffe2e85c2b764bc52f16525761c0 Mon Sep 17 00:00:00 2001 From: Erick52106 Date: Sun, 26 Apr 2026 23:42:27 +0800 Subject: [PATCH 6/7] fix: correct weekly release workflow permissions and yaml refs #366 Co-Authored-By: Codex --- .github/workflows/weekly-release-pr.yml | 43 +++++++++++++------------ 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/.github/workflows/weekly-release-pr.yml b/.github/workflows/weekly-release-pr.yml index 7fa5afcf..d3cc2229 100644 --- a/.github/workflows/weekly-release-pr.yml +++ b/.github/workflows/weekly-release-pr.yml @@ -9,6 +9,7 @@ on: permissions: contents: read pull-requests: write + actions: write jobs: create-release-pr: @@ -51,36 +52,38 @@ jobs: DATE=$(TZ=Asia/Taipei date +%Y-%m-%d) COMMITS_AHEAD=${{ steps.check.outputs.commits_ahead }} cat > /tmp/release-pr-body.md < Note: weekly-release-pr workflow 的 schedule / workflow_dispatch 需等此 workflow 檔案存在於 default branch(main)後才會啟用。 + EOF gh pr create \ --base main \ --head develop \ From 1204b402a52e582255dc15fa33f9050fc8ed56be Mon Sep 17 00:00:00 2001 From: Erick52106 Date: Sun, 26 Apr 2026 23:53:48 +0800 Subject: [PATCH 7/7] fix: make release PR lookup fallback explicit refs #366 Co-Authored-By: Codex --- .github/workflows/weekly-release-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/weekly-release-pr.yml b/.github/workflows/weekly-release-pr.yml index d3cc2229..215bc709 100644 --- a/.github/workflows/weekly-release-pr.yml +++ b/.github/workflows/weekly-release-pr.yml @@ -38,7 +38,7 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - EXISTING=$(gh pr list --base main --head develop --state open --json number --jq '.[0].number') + EXISTING=$(gh pr list --base main --head develop --state open --json number --jq '.[0].number // ""') echo "existing_pr=$EXISTING" >> "$GITHUB_OUTPUT" if [ -n "$EXISTING" ]; then echo "Release PR #$EXISTING already open, skipping."