返回 DeepSeek-Reasonix
prepare-release-notes.yml
根目录 / .github / workflows / prepare-release-notes.yml
1 name: Prepare release
2
3 on:
4 workflow_dispatch:
5 inputs:
6 version:
7 description: "Official version without a tag prefix (for example 1.20.0)"
8 required: true
9 type: string
10
11 permissions:
12 contents: write
13 pull-requests: write
14
15 jobs:
16 draft:
17 name: generate reviewable bilingual draft
18 runs-on: ubuntu-latest
19 steps:
20 - uses: actions/checkout@v7
21 with:
22 fetch-depth: 0
23
24 - uses: actions/setup-node@v7
25 with:
26 node-version: "22"
27
28 - name: Select the review branch
29 env:
30 GH_TOKEN: ${{ github.token }}
31 VERSION: ${{ inputs.version }}
32 run: |
33 set -euo pipefail
34 git config user.name "github-actions[bot]"
35 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
36 git fetch origin main-v2
37
38 if [[ ! "$VERSION" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
39 echo "::error::version must be MAJOR.MINOR.PATCH"
40 exit 1
41 fi
42 branch="release-notes/v${VERSION}"
43 if git ls-remote --exit-code --heads origin "$branch" >/dev/null 2>&1; then
44 git fetch origin "refs/heads/$branch:refs/remotes/origin/$branch"
45 git checkout -b "$branch" --track "origin/$branch"
46 source_sha="$(git merge-base origin/main-v2 HEAD)"
47 else
48 git checkout -b "$branch"
49 source_sha="$(git rev-parse HEAD)"
50 fi
51 git merge-base --is-ancestor "$source_sha" origin/main-v2
52 echo "RELEASE_NOTES_BRANCH=$branch" >> "$GITHUB_ENV"
53 echo "RELEASE_NOTES_SOURCE_SHA=$source_sha" >> "$GITHUB_ENV"
54
55 - name: Generate and validate release notes
56 env:
57 DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
58 DEEPSEEK_MODEL: deepseek-v4-pro
59 GH_TOKEN: ${{ github.token }}
60 VERSION: ${{ inputs.version }}
61 run: |
62 set -euo pipefail
63 # The first preparation fixes the product range. Reruns update the
64 # draft without silently absorbing unrelated main-v2 merges.
65 node scripts/generate-release-notes.mjs --version "$VERSION" --to "$RELEASE_NOTES_SOURCE_SHA"
66 node scripts/release-notes.mjs validate
67 node --test scripts/release-notes.test.mjs
68 node scripts/release-notes.mjs render --version "$VERSION" --output /tmp/release-notes.md
69 {
70 echo "## Review draft for v${VERSION#v}"
71 echo
72 cat /tmp/release-notes.md
73 } >> "$GITHUB_STEP_SUMMARY"
74
75 - name: Open or update the review PR
76 env:
77 GH_TOKEN: ${{ github.token }}
78 VERSION: ${{ inputs.version }}
79 run: |
80 set -euo pipefail
81 git add release-notes/releases.json
82 if ! git diff --cached --quiet; then
83 git commit -m "docs(release): prepare v${VERSION#v} notes" \
84 -m "Summary:
85 Generate a bilingual, product-focused draft from merged pull request metadata. Reuse the selected release-bound PR when one is available.
86
87 Verification:
88 Validate the catalog, citations, bilingual fields, and rendered GitHub release notes before committing."
89 fi
90 git push -u origin "$RELEASE_NOTES_BRANCH"
91 if ! gh pr list --head "$RELEASE_NOTES_BRANCH" --state open --json number --jq 'length > 0' | grep -q true; then
92 if ! gh pr create \
93 --base main-v2 \
94 --head "$RELEASE_NOTES_BRANCH" \
95 --title "docs(release): 准备 v${VERSION#v} 中英更新日志" \
96 --body-file /tmp/release-notes.md; then
97 echo "::warning::GitHub Actions could not open the PR; the reviewed branch is preserved."
98 {
99 echo "## Manual PR handoff"
100 echo
101 echo '```sh'
102 echo "gh pr create --repo ${{ github.repository }} --base main-v2 --head $RELEASE_NOTES_BRANCH --fill"
103 echo '```'
104 } >> "$GITHUB_STEP_SUMMARY"
105 fi
106 fi
107
107 lines YAML