| name | zcf-release |
| description | Automate version release and code commit using changeset |
| disable-model-invocation | true |
| allowed-tools | Read(**), Exec(git, pnpm, node, date, cat, gh) |
ZCF Release - Automated Release and Commit
Automate version release and code commit using changeset.
Usage
/zcf-release [-p|-mi|-ma|<version>]
Parameters
-p or --patch: Patch version (default) - bug fixes, minor changes
-mi or --minor: Minor version - new features, backward compatible
-ma or --major: Major version - breaking changes, incompatible
<version>: Specific version number (e.g., 1.2.3, 2.0.0-beta.1) - directly use provided version
Context
- Automatically analyze code changes and generate bilingual CHANGELOG
- Use changeset for version management
- Create release branch and pull request for protected main branch
- Auto commit code changes (NO manual tags)
- Support GitHub Actions auto publish to npm with automatic tagging after PR merge
Your Role
You are a professional release management assistant responsible for:
- Analyzing code changes
- Generating standardized CHANGELOG
- Executing version release process
Execution Flow
Parse arguments: $ARGUMENTS
1. Parameter Parsing
VERSION_TYPE="patch"
SPECIFIC_VERSION=""
if [[ "$ARGUMENTS" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-].*)?$ ]]; then
SPECIFIC_VERSION="$ARGUMENTS"
VERSION_TYPE="custom"
echo "๐ Preparing to release exact version: $SPECIFIC_VERSION"
else
case "$ARGUMENTS" in
-p|--patch)
VERSION_TYPE="patch"
;;
-mi|--minor)
VERSION_TYPE="minor"
;;
-ma|--major)
VERSION_TYPE="major"
;;
"")
VERSION_TYPE="patch"
;;
*)
echo "โ Unknown parameter: $ARGUMENTS"
echo "Usage: /zcf-release [-p|-mi|-ma|<version>]"
echo "Examples:"
echo " /zcf-release -p # Patch version bump"
echo " /zcf-release -mi # Minor version bump"
echo " /zcf-release -ma # Major version bump"
echo " /zcf-release 1.2.3 # Exact version"
echo " /zcf-release 2.0.0-beta.1 # Pre-release version"
exit 1
;;
esac
2. Check Working Directory Status
Check if the current working directory meets release conditions:
if [ ! -f "package.json" ]; then
echo "โ Error: package.json not found, please run in project root"
exit 1
fi
HAS_UNCOMMITTED=false
if ! git diff --quiet || ! git diff --cached --quiet; then
echo "โ ๏ธ Detected uncommitted changes:"
git status --short
echo ""
HAS_UNCOMMITTED=true
fi
echo "โ
Working directory status OK"
3. Analyze Version Changes
Analyze all changes since last release:
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
echo "๐ No previous version tag found, analyzing all commits"
COMMITS=$(git log --oneline)
else
echo "๐ Last version: $LAST_TAG"
echo "Analyzing changes since $LAST_TAG..."
COMMITS=$(git log $LAST_TAG..HEAD --oneline)
fi
echo -e "\n๐ Changes:"
echo "$COMMITS"
echo -e "\n๐ File change statistics:"
if [ -z "$LAST_TAG" ]; then
git diff --stat
else
git diff --stat $LAST_TAG..HEAD
fi
4. Generate CHANGELOG Content
Based on code change analysis, I will generate CHANGELOG following these standards:
Format Requirements:
- English description first, Chinese description second
- No mixing Chinese and English on the same line
- Organize by category: New Features, Optimization, Fixes, Documentation, etc.
- Each entry should be concise and clear
Example Format:
## New Features
- Add technical execution guidelines with command best practices
- Support automated release command /zcf-release
- Automatic quote handling for Windows paths
## ๆฐๅ่ฝ
- ๆทปๅ ๆๆฏๆง่กๆๅๆๆกฃ๏ผๆไพๅฝไปคๆง่กๆไฝณๅฎ่ทต
- ๆฏๆ่ชๅจๅๅ็ๅฝไปค /zcf-release
- Windows ่ทฏๅพ่ชๅจๅ ๅผๅทๅค็
## Optimization
- Prioritize ripgrep for better search performance
- Improve template file organization
## ไผๅ
- ไผๅ
ไฝฟ็จ ripgrep ๆๅๆ็ดขๆง่ฝ
- ๆน่ฟๆจกๆฟๆไปถ็ป็ป็ปๆ
## Fixes
- Fix Windows path backslash escaping issue
## ไฟฎๅค
- ไฟฎๅค Windows ่ทฏๅพๅๆๆ ไธขๅคฑ้ฎ้ข
5. Create Changeset
Create changeset file based on analysis:
TIMESTAMP=$(date +%Y%m%d%H%M%S)
CHANGESET_FILE=".changeset/release-$TIMESTAMP.md"
echo "๐ Creating changeset file..."
if [ "$VERSION_TYPE" = "custom" ]; then
cat > "$CHANGESET_FILE" << EOF
---
"zcf": $SPECIFIC_VERSION
---
[Bilingual CHANGELOG content generated based on actual changes]
EOF
echo "โ
Changeset file created with exact version: $SPECIFIC_VERSION"
else
cat > "$CHANGESET_FILE" << EOF
---
"zcf": $VERSION_TYPE
---
[Bilingual CHANGELOG content generated based on actual changes]
EOF
echo "โ
Changeset file created with version type: $VERSION_TYPE"
fi
6. Update Version Number
Use changeset to update version number and CHANGELOG:
echo "๐ Updating version number and CHANGELOG..."
pnpm changeset version
NEW_VERSION=$(node -p "require('./package.json').version")
if [ "$VERSION_TYPE" = "custom" ]; then
echo "๐ฆ New version set to: v$NEW_VERSION (specified: $SPECIFIC_VERSION)"
else
echo "๐ฆ New version: v$NEW_VERSION"
fi
echo -e "\n๐ CHANGELOG has been updated, please review the content"
echo "โ
Temporary changeset file has been automatically deleted"
7. Create Release Branch and Handle Commits
Create release branch first, then handle commits separately to avoid polluting main branch:
echo "๐ Creating release branch..."
RELEASE_BRANCH="release/v$NEW_VERSION"
git checkout -b "$RELEASE_BRANCH"
if [ "$HAS_UNCOMMITTED" = true ]; then
echo "๐ Committing pre-release changes..."
git add .
git reset HEAD package.json CHANGELOG.md 2>/dev/null || true
if ! git diff --quiet --staged; then
echo "๐ Analyzing uncommitted changes..."
CHANGED_FILES=$(git diff --staged --name-only)
COMMIT_TYPE="chore"
COMMIT_SCOPE=""
COMMIT_DESCRIPTION="pre-release changes"
if echo "$CHANGED_FILES" | grep -E "\.(md|txt)$" >/dev/null; then
if echo "$CHANGED_FILES" | grep -i "readme" >/dev/null; then
COMMIT_TYPE="docs"
COMMIT_SCOPE="readme"
COMMIT_DESCRIPTION="update README documentation"
| grep -E >/dev/null;
COMMIT_TYPE=
COMMIT_SCOPE=
COMMIT_DESCRIPTION=
COMMIT_TYPE=
COMMIT_DESCRIPTION=
| grep -E >/dev/null;
| grep -E >/dev/null;
COMMIT_TYPE=
COMMIT_DESCRIPTION=
COMMIT_TYPE=
COMMIT_DESCRIPTION=
| grep -E >/dev/null;
| grep >/dev/null;
COMMIT_TYPE=
COMMIT_DESCRIPTION=
COMMIT_TYPE=
COMMIT_DESCRIPTION=
[ -n ];
COMMIT_MSG=
COMMIT_MSG=
COMMIT_BODY=
file ;
COMMIT_BODY=
COMMIT_BODY=
โ
Pre-release changes committed: โน๏ธ No additional changes to commit after version update๐พ Committing release version changes...chore: release v
- Update version to
- Update CHANGELOG.md
- Generated by /zcf-release ๐ Creating pull request...๐ Release v$( <<
Release version v with automated version bump and CHANGELOG update.
This release includes important changes, please review CHANGELOG.md details.
- [x] New feature
- [ ] Bug fix
- [ ] Breaking change
- [x] Documentation update
- [x] Tests added/updated
- [x] All tests pass
- [x] Coverage maintained
- [x] Code follows style guidelines
- [x] Self-review completed
- [x] Documentation updated
- [x] No new warnings introduced
โ ๏ธ **IMPORTANT**: After merge, GitHub Actions will automatically:
- Create release tag
- Publish to npm
- Generate GitHub Release
๐ค Generated by /zcf-release
EOF
)\nโ
Release preparation complete!๐ฆ Version v is ready๐ Pull request created successfullyโ ๏ธ IMPORTANT: Review and merge the PR to trigger the releaseโ ๏ธ Do NOT create or push tags manually!๐ค After PR merge, GitHub Actions will automatically: - Create the release tag - Publish to npm - Generate GitHub Release๐ View release status: https://github.com/UfoMiao/zcf/actions
Complete Workflow Summary
- Preparation Phase: Check parameters (version type or exact version), working directory status
- Analysis Phase: Analyze commit history and file changes
- Generation Phase: Create bilingual CHANGELOG
- Execution Phase: Update version (automatic bump or exact version)
- Branch Creation Phase: Create release branch BEFORE committing
- Commit Phase: Commit changes on release branch
- PR Creation Phase: Push release branch and create pull request
- Review & Release Phase: Manual PR review and merge, then GitHub Actions auto publish
Important Notes
โ ๏ธ CRITICAL: NEVER create or push Git tags manually! GitHub Actions will automatically:
- Create the version tag after successful PR merge
- Generate GitHub Release
- Publish to npm registry
Manual tags will cause conflicts with the automated release process!
New Protected Branch Workflow:
- ๐ก๏ธ Main branch is protected: Cannot push directly to main
- ๐ฟ Release branch created: Automatic creation of
release/v{version} branch
- ๐ Pull Request required: All releases must go through PR review process
- โ
Manual approval needed: PR must be reviewed and merged manually
- ๐ค Auto-release after merge: GitHub Actions triggers after PR merge
Additional Notes:
- Ensure all code has been tested before running release command
- CHANGELOG must follow bilingual format standards
- When using version types (-p/-mi/-ma), choose the correct type for your changes
- When providing exact version numbers, ensure they follow semantic versioning (e.g., 1.2.3, 2.0.0-beta.1)
- Exact version numbers bypass automatic version determination - use carefully
- Carefully review CHANGELOG content in the created PR before merging
- No manual cleanup needed:
changeset version automatically deletes temporary changeset files
- The
.changeset/ directory should only contain config files, not temporary release files
- Requires
gh CLI: Ensure GitHub CLI is installed and authenticated for PR creation
Version Parameter Examples:
/zcf-release or /zcf-release -p - Auto patch bump (2.9.11 โ 2.9.12)
/zcf-release -mi - Auto minor bump (2.9.11 โ 2.10.0)
/zcf-release -ma - Auto major bump (2.9.11 โ 3.0.0)
/zcf-release 1.5.0 - Exact version (โ 1.5.0)
/zcf-release 3.0.0-alpha.1 - Pre-release version (โ 3.0.0-alpha.1)
Now starting release process...