From 73362c59da2ab65c9c6f61d8abc0965bc4dd72e5 Mon Sep 17 00:00:00 2001 From: Floyd Wang Date: Fri, 24 Oct 2025 11:35:59 +0800 Subject: [PATCH] Add bump version shell (#1423) image --- CONTRIBUTING.md | 18 +++++-- script/bump-version.sh | 109 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 5 deletions(-) create mode 100755 script/bump-version.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 55a3edf9..14dab31a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -97,18 +97,26 @@ Use `samply record` command to start rust development, and do some operations in When we are ready to release a new version, please follow the steps below: +### Use the script to bump the version(Recommended) + +```bash +./script/bump-version.sh x.y.z +``` + +### Manually bump the version + 1. Run `cargo set-version` to set the new version for all crates. ```bash - cargo set-version 0.2.0 + cargo set-version x.y.z ``` -2. Git Commit the changes with message `chore: Release v0.2.0`. -3. Create a new git tag with the version `v0.2.0` and push `main` branch and the tag to remote. +2. Git Commit the changes with message `chore: Release vx.y.z`. +3. Create a new git tag with the version `vx.y.z` and push `main` branch and the tag to remote. ```bash - git tag v0.2.0 - git push origin main --tags + git tag vx.y.z + git push origin vx.y.z ``` 4. Then GitHub Actions will automatically publish the crates to crates.io and create a new release in GitHub. diff --git a/script/bump-version.sh b/script/bump-version.sh new file mode 100755 index 00000000..9dcb4df9 --- /dev/null +++ b/script/bump-version.sh @@ -0,0 +1,109 @@ +#!/bin/bash + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +MAGENTA='\033[0;35m' +CYAN='\033[0;36m' +BOLD='\033[1m' +RESET='\033[0m' + +# Check if version argument is provided +new_version=$1 +if [ -z "$new_version" ] +then + echo -e "${RED}${BOLD}Error:${RESET} Version argument is required" + echo -e "${YELLOW}USAGE:${RESET} ./bump.sh [VERSION]" + exit 1 +fi + +# Logging functions +function log_header() { + local message=$1 + echo "" + echo -e "${BOLD}${BLUE}╔════════════════════════════════════════════════════════╗${RESET}" + echo -e "${BOLD}${BLUE}║${RESET} ${CYAN}${BOLD}$message${RESET}" + echo -e "${BOLD}${BLUE}╚════════════════════════════════════════════════════════╝${RESET}" + echo "" +} + +function log_step() { + local step=$1 + local message=$2 + echo -e "${MAGENTA}${BOLD}[$step]${RESET} ${message}" +} + +function log_success() { + local message=$1 + echo -e "${GREEN}${BOLD}✓${RESET} ${message}" +} + +function log_info() { + local message=$1 + echo -e "${CYAN}ℹ${RESET} ${message}" +} + +function log_error() { + local message=$1 + echo -e "${RED}${BOLD}✗${RESET} ${message}" +} + +# Start release process +log_header "Starting Release Process for v$new_version" + +# Step 1: Update crates version +log_step "1/4" "Updating crates to version ${BOLD}v$new_version${RESET}" +if cargo set-version "$new_version"; then + log_success "Crates version updated successfully" +else + log_error "Failed to update crates version" + exit 1 +fi +echo "" + +# Step 2: Stage changes +log_step "2/4" "Staging modified files" +if git add -u .; then + log_success "Files staged successfully" +else + log_error "Failed to stage files" + exit 1 +fi +echo "" + +# Step 3: Create commit and tag +log_step "3/4" "Creating commit and tag" +if git commit -m "Bump v$new_version"; then + log_success "Commit created: ${BOLD}Bump v$new_version${RESET}" +else + log_error "Failed to create commit" + exit 1 +fi + +if git tag "v$new_version"; then + log_success "Tag created: ${BOLD}v$new_version${RESET}" +else + log_error "Failed to create tag" + exit 1 +fi +echo "" + +# Step 4: Push to remote +log_step "4/4" "Pushing tag to remote" +log_info "Pushing ${BOLD}v$new_version${RESET} to origin..." +if git push origin "v$new_version"; then + log_success "Tag pushed to remote successfully" +else + log_error "Failed to push tag to remote" + exit 1 +fi +echo "" + +# Success message +echo -e "${GREEN}${BOLD}╔════════════════════════════════════════════════════════╗${RESET}" +echo -e "${GREEN}${BOLD}║${RESET} ${BOLD}🚀 Release v$new_version standby!${RESET}" +echo -e "${GREEN}${BOLD}║${RESET} ${GREEN}Let's ship it!${RESET}" +echo -e "${GREEN}${BOLD}╚════════════════════════════════════════════════════════╝${RESET}" +echo ""