Skip to content

Commit 7e8a11f

Browse files
committed
feat: enhance release script with improved git operations
- Add comprehensive git operations handling with error checking - Improve push_commit and push_tag functions with better error handling - Add handle_git_operations function for centralized git management - Update dry-run output to reflect new git operations flow - Ensure all changes are committed and pushed to GitHub
1 parent 894dceb commit 7e8a11f

File tree

1 file changed

+77
-28
lines changed

1 file changed

+77
-28
lines changed

scripts/release.sh

Lines changed: 77 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -291,19 +291,43 @@ create_tag() {
291291

292292
if git tag -l | grep -q "^$tag$"; then
293293
print_error "Tag $tag already exists"
294-
exit 1
294+
return 1
295+
fi
296+
297+
if ! git tag -a "$tag" -m "Release $tag"; then
298+
print_error "Failed to create tag $tag"
299+
return 1
295300
fi
296301

297-
git tag -a "$tag" -m "Release $tag"
298302
print_success "Created tag $tag"
299303
}
300304

305+
# Function to push commit to GitHub
306+
push_commit() {
307+
local version=$1
308+
309+
print_info "Pushing commit to GitHub..."
310+
if ! git push origin main; then
311+
print_error "Failed to push commit to GitHub"
312+
print_info "You may need to push manually: git push origin main"
313+
return 1
314+
fi
315+
316+
print_success "Pushed commit to GitHub"
317+
}
318+
301319
# Function to push tag to GitHub
302320
push_tag() {
303321
local version=$1
304322
local tag="v$version"
305323

306-
git push origin "$tag"
324+
print_info "Pushing tag $tag to GitHub..."
325+
if ! git push origin "$tag"; then
326+
print_error "Failed to push tag $tag to GitHub"
327+
print_info "You may need to push tag manually: git push origin $tag"
328+
return 1
329+
fi
330+
307331
print_success "Pushed tag $tag to GitHub"
308332
}
309333

@@ -377,6 +401,44 @@ increment_version() {
377401
echo "${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"
378402
}
379403

404+
# Function to handle all git operations
405+
handle_git_operations() {
406+
local version=$1
407+
local files_to_commit=$2
408+
409+
print_info "Handling git operations..."
410+
411+
# Add files to git
412+
git add $files_to_commit
413+
print_info "Staged files: $files_to_commit"
414+
415+
# Commit version change
416+
if ! git commit -m "chore: bump version to $version"; then
417+
print_error "Failed to commit version changes"
418+
return 1
419+
fi
420+
print_success "Committed version bump"
421+
422+
# Push commit to GitHub
423+
if ! push_commit "$version"; then
424+
print_error "Failed to push commit - release may be incomplete"
425+
return 1
426+
fi
427+
428+
# Create and push tag
429+
if ! create_tag "$version"; then
430+
print_error "Failed to create tag"
431+
return 1
432+
fi
433+
434+
if ! push_tag "$version"; then
435+
print_error "Failed to push tag - release may be incomplete"
436+
return 1
437+
fi
438+
439+
print_success "All git operations completed successfully"
440+
}
441+
380442
# Main function
381443
main() {
382444
local version=""
@@ -478,16 +540,13 @@ main() {
478540
echo
479541
echo "Would perform the following actions:"
480542
echo "1. Update version to $version in all package files"
481-
echo "2. Create git tag v$version"
482-
echo "3. Push tag v$version to GitHub"
483-
if [[ "$skip_crates" != "true" ]]; then
484-
echo "4. Publish to crates.io (dry run)"
485-
echo "5. Trigger docs.rs rebuild"
486-
fi
487-
if [[ "$skip_homebrew" != "true" ]]; then
488-
echo "6. Update Homebrew formula"
489-
fi
490-
echo "7. GitHub Actions will create release with binaries"
543+
echo "2. Publish to crates.io (if enabled)"
544+
echo "3. Update Homebrew formula (if enabled)"
545+
echo "4. Commit version changes to git"
546+
echo "5. Push commit to GitHub"
547+
echo "6. Create and push git tag v$version"
548+
echo "7. Trigger docs.rs rebuild"
549+
echo "8. GitHub Actions will create release with binaries"
491550
exit 0
492551
fi
493552

@@ -549,21 +608,11 @@ main() {
549608
update_homebrew_formula "$version"
550609
fi
551610

552-
# Commit version change
553-
git add Cargo.toml vtcode-core/Cargo.toml
554-
git commit -m "chore: bump version to $version"
555-
print_success "Committed version bump"
556-
557-
# Push commit to GitHub
558-
git push origin main
559-
print_success "Pushed commit to GitHub"
560-
561-
# Create and push tag
562-
create_tag "$version"
563-
push_tag "$version"
564-
565-
# Trigger docs.rs rebuild
566-
trigger_docs_rs_rebuild false
611+
# Handle all git operations
612+
if ! handle_git_operations "$version" "$files_to_commit"; then
613+
print_error "Git operations failed - release may be incomplete"
614+
exit 1
615+
fi
567616

568617
print_success "Release $version created successfully!"
569618
print_info "Distribution Summary:"

0 commit comments

Comments
 (0)