Skip to content

Commit ca3fa6e

Browse files
authored
Merge pull request #4494 from VisActor/feat/optimiz-post-release
Feat/optimiz post release
2 parents d833c77 + b0a0d50 commit ca3fa6e

4 files changed

Lines changed: 156 additions & 29 deletions

File tree

.cursor/commands/speckit.aftercode.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: 'Automatically execute the subsequent code delivery pipeline: changelog → commit → prgenerate, in strict sequential order.'
2+
description: 'Automatically execute the subsequent code delivery pipeline: skilltypesync → changelog → commit → prgenerate, in strict sequential order.'
33
handoffs:
44
- label: 'Create Pull Request'
55
agent: 'speckit.prcreate'
@@ -15,25 +15,42 @@ $ARGUMENTS
1515

1616
## Outline
1717

18-
This command orchestrates the code delivery pipeline, executing the `changelog`, `commit`, and `prgenerate` phases in a strict, sequential, and non-interactive flow. It ensures that the entire process, from generating change files to preparing the PR body, is automated while maintaining the precise behavior of each individual step.
18+
This command orchestrates the code delivery pipeline, executing the `skilltypesync`, `changelog`, `commit`, and `prgenerate` phases in a strict, sequential, and non-interactive flow. It ensures that the entire process, from synchronizing skill type resources to preparing the PR body, is automated while maintaining the precise behavior of each individual step.
1919

2020
**Execution is strictly sequential. No steps will be skipped or run in parallel.**
2121

22-
### Phase 1: Generate Changelog (`/speckit.changelog`)
22+
### Phase 1: Sync Skill Type Resources (`/speckit.skilltypesync`)
2323

24-
- **Action**: Initiates the delivery pipeline by invoking `/speckit.changelog`.
24+
- **Action**: Initiates the delivery pipeline by invoking `/speckit.skilltypesync`.
25+
- **Process**:
26+
- Detects whether this feature includes user-facing config/API/type changes.
27+
- If required, synchronizes skill reference assets under:
28+
- `skills/vchart-development-assistant/references/type-meta/`
29+
- `skills/vchart-development-assistant/references/type-details/`
30+
- Runs consistency checks to prevent broken type references in the skill resources.
31+
- Any parameters provided in `$ARGUMENTS` will be passed through (for example: `--base`, `--force`, `--types`).
32+
- **Handoff**: Upon successful completion, automatically triggers the `changelog` phase.
33+
- **Output Report**:
34+
- "Phase 1 (Skill Type Sync) completed."
35+
- `SYNC_TRIGGER`: [auto-detected | forced]
36+
- `UPDATED_TYPE_META`: [List of updated files or empty]
37+
- `UPDATED_TYPE_DETAILS`: [List of updated files or empty]
38+
39+
### Phase 2: Generate Changelog (`/speckit.changelog`)
40+
41+
- **Action**: Triggered automatically after `skilltypesync` completes.
2542
- **Process**:
2643
- Collects commits since a base branch (defaulting to `develop`).
2744
- Infers the version bump type (`patch`, `minor`, `major`) automatically from commit messages unless an explicit `bumpType` is passed in `$ARGUMENTS`.
2845
- Generates the necessary change files within the `common/changes/` directory.
2946
- Any parameters provided in `$ARGUMENTS` will be passed through to override default behavior.
3047
- **Handoff**: Upon successful completion, automatically triggers the `commit` phase.
3148
- **Output Report**:
32-
- "Phase 1 (Changelog) completed."
49+
- "Phase 2 (Changelog) completed."
3350
- `CREATED_FILES`: [List of paths to generated files in `common/changes/`]
3451
- `VALIDATION`: "Changelog message conforms to Conventional Commits standards."
3552

36-
### Phase 2: Create Commit (`/speckit.commit`)
53+
### Phase 3: Create Commit (`/speckit.commit`)
3754

3855
- **Action**: Triggered automatically after `changelog` completes.
3956
- **Process**:
@@ -44,11 +61,11 @@ This command orchestrates the code delivery pipeline, executing the `changelog`,
4461
- The `message` and `pushAfterCommit` behaviors can be overridden via `$ARGUMENTS`.
4562
- **Handoff**: Upon successful completion, automatically triggers the `prgenerate` phase.
4663
- **Output Report**:
47-
- "Phase 2 (Commit) completed."
64+
- "Phase 3 (Commit) completed."
4865
- `COMMIT_MESSAGE`: [The full commit message used]
4966
- `PUSH_STATUS`: "Branch [branch-name] pushed to origin."
5067

51-
### Phase 3: Generate PR Body (`/speckit.prgenerate`)
68+
### Phase 4: Generate PR Body (`/speckit.prgenerate`)
5269

5370
- **Action**: The final phase, realized via the native `handoff` from `/speckit.commit` to `/speckit.prgenerate` after `commit` completes. This `/speckit.aftercode` command does not declare its own `handoff` entry for `/speckit.prgenerate` to avoid duplicate execution.
5471
- **Process**:
@@ -57,7 +74,7 @@ This command orchestrates the code delivery pipeline, executing the `changelog`,
5774
- Saves the final, populated PR body to `.trae/output/pr.body.local.md`.
5875
- **Handoff**: This step retains its original `handoff` to `speckit.prcreate`. The `/speckit.aftercode` command depends strictly on the original single-step handoff chain and does **not** introduce any additional handoffs, preventing `prgenerate` (or downstream steps) from running more than once.
5976
- **Output Report**:
60-
- "Phase 3 (PR Generate) completed."
77+
- "Phase 4 (PR Generate) completed."
6178
- `OUTPUT_FILE`: ".trae/output/pr.body.local.md"
6279
- `VALIDATION_SUMMARY`: "PR body generated. Please review the file before creating the pull request."
6380
- `NEXT_STEPS`: "The `speckit.prcreate` command may have been triggered automatically. If not, you can run it manually to create the GitHub Pull Request."
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
description: "After feature development, detect user-config/API changes and synchronize skill type resources under skills/vchart-development-assistant/references/type-meta and type-details."
3+
---
4+
5+
## User Input
6+
7+
```text
8+
$ARGUMENTS
9+
```
10+
11+
You **MUST** consider user input if provided. Treat it as optional CLI-style overrides only (for example: `--base develop`, `--force`, `--types ILabelSpec,IData`).
12+
13+
## Outline
14+
15+
1. **Resolve diff scope**:
16+
- Default base branch is `develop`.
17+
- If `$ARGUMENTS` contains `--base <branch>`, use that branch as comparison base.
18+
- Collect changed files from:
19+
- staged + unstaged local changes, and
20+
- branch diff against base (`<base>...HEAD`).
21+
- De-duplicate all changed paths.
22+
23+
2. **Determine whether sync is required**:
24+
- Mark as **requires sync** when changes affect user-facing configuration or API/type definitions, including (but not limited to):
25+
- `packages/vchart/src/typings/**`
26+
- `packages/vchart/src/chart/**/interface/**`
27+
- `packages/vchart/src/component/**/interface/**`
28+
- `packages/vchart/src/series/**/interface/**`
29+
- `packages/vchart/src/theme/**`
30+
- any public API or option schema files referenced by VChart docs.
31+
- If no matching files and no `--force`, stop with a clear summary: "No user config/API changes detected, skill type sync skipped."
32+
33+
3. **Identify impacted type entities**:
34+
- From changed TypeScript definitions, extract impacted type/interface names (for example `ILabelSpec`, `IData`, `ITheme`).
35+
- Build two impact sets:
36+
- **Meta impact**: chart/common entries that need `type-meta/*.json` updates.
37+
- **Detail impact**: concrete types needing `type-details/*-Type-Definition.md` updates.
38+
- If `$ARGUMENTS` includes `--types`, merge explicit type names into the detail impact set.
39+
40+
4. **Update `type-meta` resources**:
41+
- Target directory: `skills/vchart-development-assistant/references/type-meta/`.
42+
- For each impacted chart/common meta file:
43+
- sync user-visible property paths,
44+
- sync `required` flags,
45+
- sync `type` and `isSimple` fields,
46+
- remove stale keys that no longer exist in source typings.
47+
- Keep JSON valid and stable (no duplicated keys, deterministic field ordering where possible).
48+
49+
5. **Update `type-details` resources**:
50+
- Target directory: `skills/vchart-development-assistant/references/type-details/`.
51+
- For each impacted type:
52+
- create or update `[TypeName]-Type-Definition.md` (for example `ILabelSpec-Type-Definition.md`),
53+
- ensure definitions reflect latest fields, value types, optional/required semantics, and usage notes,
54+
- include concise, runnable-style code examples that match current VChart API behavior.
55+
- Keep naming aligned with `references/FILE_NAMING_CONVENTIONS.md`.
56+
57+
6. **Consistency checks**:
58+
- Verify every complex type referenced in `type-meta` (`isSimple: false`) has a corresponding `type-details` document.
59+
- Verify removed/renamed types no longer leave broken references in `type-meta`.
60+
- Validate JSON syntax for all changed files under `type-meta`.
61+
- Ensure Markdown files under `type-details` are non-empty and include the target type name in title/content.
62+
63+
7. **Output report**:
64+
- Print:
65+
- base branch used,
66+
- whether sync was triggered by auto-detection or `--force`,
67+
- changed source files that triggered sync,
68+
- updated `type-meta` files,
69+
- updated `type-details` files,
70+
- unresolved gaps (if any manual follow-up is required).
71+
- If unresolved gaps exist, fail with actionable errors instead of silently succeeding.
72+
73+
## Notes
74+
75+
- This command only synchronizes skill reference assets; it does not commit, push, or create PR content.
76+
- Preferred execution point is after implementation is complete and before `/speckit.changelog` or `/speckit.aftercode`.

.github/workflows/post-release.yml

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,31 +74,28 @@ jobs:
7474
7575
echo "skip=false" >> "$GITHUB_OUTPUT"
7676
77-
- name: Fetch develop changelog
77+
- name: Ensure main changelog exists
7878
if: steps.meta.outputs.skip != 'true' && steps.exist.outputs.skip != 'true'
7979
run: |
8080
set -euo pipefail
81-
git fetch origin develop:refs/remotes/origin/develop --depth=1
82-
git show origin/develop:docs/assets/changelog/en/release.md > release-develop.md
81+
if [ ! -f "docs/assets/changelog/en/release.md" ]; then
82+
echo "Error: docs/assets/changelog/en/release.md not found in main."
83+
exit 1
84+
fi
8385
84-
- name: Extract release body from develop changelog
86+
- name: Extract release body from main changelog
8587
id: body
8688
if: steps.meta.outputs.skip != 'true' && steps.exist.outputs.skip != 'true'
8789
env:
8890
VERSION: ${{ steps.meta.outputs.version }}
8991
run: |
9092
set -euo pipefail
91-
if [ ! -f "release-develop.md" ]; then
92-
echo "develop changelog file not found, skip post-release."
93-
echo "has_body=false" >> "$GITHUB_OUTPUT"
94-
exit 0
95-
fi
96-
97-
if node <<'NODE'
93+
node <<'NODE'
9894
const fs = require('fs');
9995
10096
const version = process.env.VERSION;
101-
const content = fs.readFileSync('release-develop.md', 'utf8');
97+
const changelogPath = 'docs/assets/changelog/en/release.md';
98+
const content = fs.readFileSync(changelogPath, 'utf8');
10299
103100
function escapeRegExp(str) {
104101
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
@@ -108,27 +105,53 @@ jobs:
108105
const match = headerPattern.exec(content);
109106
110107
if (!match) {
111-
console.log('No changelog block for version', version, 'found in develop.');
108+
console.error('No changelog block for version', version, 'found in main changelog.');
112109
process.exit(1);
113110
}
114111
115112
const startIndex = match.index;
116113
const rest = content.slice(startIndex);
117114
118-
const nextHeaderPattern = /^#\s*v?\d+\.\d+\.\d+[^\n]*$/gm;
115+
// Find the next release header after the current one.
116+
const nextHeaderPattern = /^#\s*v?\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?[^\n]*$/gm;
119117
let nextIndex = rest.length;
120118
let m;
121-
if ((m = nextHeaderPattern.exec(rest)) !== null && m.index !== 0) {
122-
nextIndex = m.index;
119+
while ((m = nextHeaderPattern.exec(rest)) !== null) {
120+
if (m.index > 0) {
121+
nextIndex = m.index;
122+
break;
123+
}
123124
}
124125
125126
const block = rest.slice(0, nextIndex).trimEnd() + '\n';
127+
if (!block.trim()) {
128+
console.error('Extracted changelog block is empty for version', version);
129+
process.exit(1);
130+
}
126131
fs.writeFileSync('release-body.md', block, 'utf8');
127132
NODE
128-
then
129-
echo "has_body=true" >> "$GITHUB_OUTPUT"
130-
else
131-
echo "has_body=false" >> "$GITHUB_OUTPUT"
133+
echo "has_body=true" >> "$GITHUB_OUTPUT"
134+
135+
- name: Validate extracted release body
136+
if: steps.meta.outputs.skip != 'true' && steps.exist.outputs.skip != 'true' && steps.body.outputs.has_body == 'true'
137+
env:
138+
VERSION: ${{ steps.meta.outputs.version }}
139+
run: |
140+
set -euo pipefail
141+
if [ ! -s "release-body.md" ]; then
142+
echo "Error: release-body.md is missing or empty."
143+
exit 1
144+
fi
145+
146+
if ! grep -Eq "^#\\s*v?${VERSION}\\b" release-body.md; then
147+
echo "Error: release-body.md does not start with expected version header v${VERSION}."
148+
exit 1
149+
fi
150+
151+
HEADER_COUNT="$(grep -Ec '^#\s*v?[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.]+)?\b' release-body.md || true)"
152+
if [ "${HEADER_COUNT}" -ne 1 ]; then
153+
echo "Error: extracted release body contains ${HEADER_COUNT} release headers, expected exactly 1."
154+
exit 1
132155
fi
133156
134157
- name: Verify gh identity
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "feat: optimiz workflows for release\n\n",
5+
"type": "none",
6+
"packageName": "@visactor/vchart"
7+
}
8+
],
9+
"packageName": "@visactor/vchart",
10+
"email": "lixuef1313@163.com"
11+
}

0 commit comments

Comments
 (0)