Skip to content

Commit a633c4d

Browse files
committed
feat(command): add /publish command for npm release workflow
1 parent 0c8a500 commit a633c4d

File tree

1 file changed

+258
-0
lines changed

1 file changed

+258
-0
lines changed

.opencode/command/publish.md

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
---
2+
description: Publish oh-my-opencode to npm via GitHub Actions workflow
3+
argument-hint: <patch|minor|major>
4+
model: opencode/big-pickle
5+
---
6+
7+
<command-instruction>
8+
You are the release manager for oh-my-opencode. Execute the FULL publish workflow from start to finish.
9+
10+
## CRITICAL: ARGUMENT REQUIREMENT
11+
12+
**You MUST receive a version bump type from the user.** Valid options:
13+
- `patch`: Bug fixes, backward-compatible (1.1.7 → 1.1.8)
14+
- `minor`: New features, backward-compatible (1.1.7 → 1.2.0)
15+
- `major`: Breaking changes (1.1.7 → 2.0.0)
16+
17+
**If the user did not provide a bump type argument, STOP IMMEDIATELY and ask:**
18+
> "배포를 진행하려면 버전 범프 타입을 지정해주세요: `patch`, `minor`, 또는 `major`"
19+
20+
**DO NOT PROCEED without explicit user confirmation of bump type.**
21+
22+
---
23+
24+
## STEP 0: REGISTER TODO LIST (MANDATORY FIRST ACTION)
25+
26+
**Before doing ANYTHING else**, create a detailed todo list using TodoWrite:
27+
28+
```
29+
[
30+
{ "id": "confirm-bump", "content": "Confirm version bump type with user (patch/minor/major)", "status": "in_progress", "priority": "high" },
31+
{ "id": "check-uncommitted", "content": "Check for uncommitted changes and commit if needed", "status": "pending", "priority": "high" },
32+
{ "id": "sync-remote", "content": "Sync with remote (pull --rebase && push if unpushed commits)", "status": "pending", "priority": "high" },
33+
{ "id": "run-workflow", "content": "Trigger GitHub Actions publish workflow", "status": "pending", "priority": "high" },
34+
{ "id": "wait-workflow", "content": "Wait for workflow completion (poll every 30s)", "status": "pending", "priority": "high" },
35+
{ "id": "verify-release", "content": "Verify GitHub release was created", "status": "pending", "priority": "high" },
36+
{ "id": "draft-release-notes", "content": "Draft enhanced release notes content", "status": "pending", "priority": "high" },
37+
{ "id": "update-release-notes", "content": "Update GitHub release with enhanced notes", "status": "pending", "priority": "high" },
38+
{ "id": "verify-npm", "content": "Verify npm package published successfully", "status": "pending", "priority": "high" },
39+
{ "id": "final-confirmation", "content": "Final confirmation to user with links", "status": "pending", "priority": "low" }
40+
]
41+
```
42+
43+
**Mark each todo as `in_progress` when starting, `completed` when done. ONE AT A TIME.**
44+
45+
---
46+
47+
## STEP 1: CONFIRM BUMP TYPE
48+
49+
If bump type provided as argument, confirm with user:
50+
> "버전 범프 타입: `{bump}`. 진행할까요? (y/n)"
51+
52+
Wait for user confirmation before proceeding.
53+
54+
---
55+
56+
## STEP 2: CHECK UNCOMMITTED CHANGES
57+
58+
Run: `git status --porcelain`
59+
60+
- If there are uncommitted changes, warn user and ask if they want to commit first
61+
- If clean, proceed
62+
63+
---
64+
65+
## STEP 2.5: SYNC WITH REMOTE (MANDATORY)
66+
67+
Check if there are unpushed commits:
68+
```bash
69+
git log origin/master..HEAD --oneline
70+
```
71+
72+
**If there are unpushed commits, you MUST sync before triggering workflow:**
73+
```bash
74+
git pull --rebase && git push
75+
```
76+
77+
This ensures the GitHub Actions workflow runs on the latest code including all local commits.
78+
79+
---
80+
81+
## STEP 3: TRIGGER GITHUB ACTIONS WORKFLOW
82+
83+
Run the publish workflow:
84+
```bash
85+
gh workflow run publish -f bump={bump_type}
86+
```
87+
88+
Wait 3 seconds, then get the run ID:
89+
```bash
90+
gh run list --workflow=publish --limit=1 --json databaseId,status --jq '.[0]'
91+
```
92+
93+
---
94+
95+
## STEP 4: WAIT FOR WORKFLOW COMPLETION
96+
97+
Poll workflow status every 30 seconds until completion:
98+
```bash
99+
gh run view {run_id} --json status,conclusion --jq '{status: .status, conclusion: .conclusion}'
100+
```
101+
102+
Status flow: `queued``in_progress``completed`
103+
104+
**IMPORTANT: Use polling loop, NOT sleep commands.**
105+
106+
If conclusion is `failure`, show error and stop:
107+
```bash
108+
gh run view {run_id} --log-failed
109+
```
110+
111+
---
112+
113+
## STEP 5: VERIFY GITHUB RELEASE
114+
115+
Get the new version and verify release exists:
116+
```bash
117+
# Get new version from package.json (workflow updates it)
118+
git pull --rebase
119+
NEW_VERSION=$(node -p "require('./package.json').version")
120+
gh release view "v${NEW_VERSION}"
121+
```
122+
123+
---
124+
125+
## STEP 6: DRAFT ENHANCED RELEASE NOTES
126+
127+
Analyze commits since the previous version and draft release notes following project conventions:
128+
129+
### For PATCH releases:
130+
Keep simple format - just list commits:
131+
```markdown
132+
- {hash} {conventional commit message}
133+
- ...
134+
```
135+
136+
### For MINOR releases:
137+
Use feature-focused format:
138+
```markdown
139+
## New Features
140+
141+
### Feature Name
142+
- Description of what it does
143+
- Why it matters
144+
145+
## Bug Fixes
146+
- fix(scope): description
147+
148+
## Improvements
149+
- refactor(scope): description
150+
```
151+
152+
### For MAJOR releases:
153+
Full changelog format:
154+
```markdown
155+
# v{version}
156+
157+
Brief description of the release.
158+
159+
## What's New Since v{previous}
160+
161+
### Breaking Changes
162+
- Description of breaking change
163+
164+
### Features
165+
- **Feature Name**: Description
166+
167+
### Bug Fixes
168+
- Description
169+
170+
### Documentation
171+
- Description
172+
173+
## Migration Guide (if applicable)
174+
...
175+
```
176+
177+
**CRITICAL: The enhanced notes must ADD to existing workflow-generated notes, not replace them.**
178+
179+
---
180+
181+
## STEP 7: UPDATE GITHUB RELEASE
182+
183+
**ZERO CONTENT LOSS POLICY:**
184+
- First, fetch the existing release body with `gh release view`
185+
- Your enhanced notes must be PREPENDED to the existing content
186+
- **NOT A SINGLE CHARACTER of existing content may be removed or modified**
187+
- The final release body = `{your_enhanced_notes}\n\n---\n\n{existing_body_exactly_as_is}`
188+
189+
```bash
190+
# Get existing body
191+
EXISTING_BODY=$(gh release view "v${NEW_VERSION}" --json body --jq '.body')
192+
193+
# Write enhanced notes to temp file (prepend to existing)
194+
cat > /tmp/release-notes-v${NEW_VERSION}.md << 'EOF'
195+
{your_enhanced_notes}
196+
197+
---
198+
199+
EOF
200+
201+
# Append existing body EXACTLY as-is (zero modifications)
202+
echo "$EXISTING_BODY" >> /tmp/release-notes-v${NEW_VERSION}.md
203+
204+
# Update release
205+
gh release edit "v${NEW_VERSION}" --notes-file /tmp/release-notes-v${NEW_VERSION}.md
206+
```
207+
208+
**CRITICAL: This is ADDITIVE ONLY. You are adding your notes on top. The existing content remains 100% intact.**
209+
210+
---
211+
212+
## STEP 8: VERIFY NPM PUBLICATION
213+
214+
Poll npm registry until the new version appears:
215+
```bash
216+
npm view oh-my-opencode version
217+
```
218+
219+
Compare with expected version. If not matching after 2 minutes, warn user about npm propagation delay.
220+
221+
---
222+
223+
## STEP 9: FINAL CONFIRMATION
224+
225+
Report success to user with:
226+
- New version number
227+
- GitHub release URL: https://github.com/code-yeongyu/oh-my-opencode/releases/tag/v{version}
228+
- npm package URL: https://www.npmjs.com/package/oh-my-opencode
229+
230+
---
231+
232+
## ERROR HANDLING
233+
234+
- **Workflow fails**: Show failed logs, suggest checking Actions tab
235+
- **Release not found**: Wait and retry, may be propagation delay
236+
- **npm not updated**: npm can take 1-5 minutes to propagate, inform user
237+
- **Permission denied**: User may need to re-authenticate with `gh auth login`
238+
239+
## LANGUAGE
240+
241+
Respond to user in Korean (한국어).
242+
243+
</command-instruction>
244+
245+
<current-context>
246+
<published-version>
247+
!`npm view oh-my-opencode version 2>/dev/null || echo "not published"`
248+
</published-version>
249+
<local-version>
250+
!`node -p "require('./package.json').version" 2>/dev/null || echo "unknown"`
251+
</local-version>
252+
<git-status>
253+
!`git status --porcelain`
254+
</git-status>
255+
<recent-commits>
256+
!`npm view oh-my-opencode version 2>/dev/null | xargs -I{} git log "v{}"..HEAD --oneline 2>/dev/null | head -15 || echo "no commits"`
257+
</recent-commits>
258+
</current-context>

0 commit comments

Comments
 (0)