7171# Function to show usage
7272show_usage () {
7373 local script_name=" ${0##*/ } "
74- cat << EOF
75- Usage: $script_name [options]
74+ cat << ' EOF '
75+ Usage: full-release.zsh [options]
7676
7777This script performs the complete GoProX release process:
78781. Bump version with --auto --push --force
@@ -89,12 +89,21 @@ Options:
8989 --major bump major version (default: minor)
9090 --minor bump minor version (default)
9191 --patch bump patch version
92+ --preserve-summary preserve summary file (override default behavior)
93+ --remove-summary rename/remove summary file (override default behavior)
94+
95+ Summary File Behavior:
96+ Default: Dry-runs preserve summary file, real releases rename it
97+ --preserve-summary: Force preserve even for real releases
98+ --remove-summary: Force rename even for dry-runs
9299
93100Examples:
94- $script_name --dry-run --prev 00.52.00
95- $script_name --dry-run --base 00.52.00
96- $script_name --prev 00.52.00 --version 01.00.15
97- $script_name --dry-run --prev 01.00.13 --patch
101+ ./scripts/release/full-release.zsh --dry-run --prev 00.52.00
102+ ./scripts/release/full-release.zsh --dry-run --base 00.52.00
103+ ./scripts/release/full-release.zsh --prev 00.52.00 --version 01.00.15
104+ ./scripts/release/full-release.zsh --dry-run --prev 01.00.13 --patch
105+ ./scripts/release/full-release.zsh --prev 00.52.00 --preserve-summary
106+ ./scripts/release/full-release.zsh --dry-run --prev 00.52.00 --remove-summary
98107
99108The script is fully automated and requires no user interaction.
100109EOF
@@ -169,6 +178,8 @@ main() {
169178 version=" "
170179 force=" false"
171180 bump_type=" minor"
181+ preserve_summary=" false"
182+ remove_summary=" false"
172183
173184 # Parse options using zparseopts for strict parameter validation
174185 declare -A opts
@@ -184,6 +195,8 @@ main() {
184195 -patch \
185196 -verbose \
186197 -debug \
198+ -preserve-summary \
199+ -remove-summary \
187200 || {
188201 # Unknown option
189202 print_error " Unknown option: $@ "
@@ -222,6 +235,12 @@ main() {
222235 -verbose|-debug)
223236 VERBOSE=1
224237 ;;
238+ --preserve-summary)
239+ preserve_summary=" true"
240+ ;;
241+ --remove-summary)
242+ remove_summary=" true"
243+ ;;
225244 esac
226245 done
227246
@@ -279,71 +298,104 @@ main() {
279298 local base_version=" $prev_version "
280299 local summary_file=" docs/release/latest-major-changes-since-${base_version} .md"
281300 local new_summary_file=" docs/release/${intended_new_version} -major-changes-since-${base_version} .md"
301+
282302 if [[ -f " $summary_file " ]]; then
283- # Always remove the target file if it exists to ensure clean rename
284- if [[ -f " $new_summary_file " ]] ; then
285- print_warning " $new_summary_file already exists. Removing existing file. "
286- rm -f " $new_summary_file "
287- if [[ -f " $new_summary_file " ]]; then
288- print_error " Failed to remove existing file: $new_summary_file "
289- exit 1
290- fi
303+ # Determine whether to rename the summary file based on flags and run type
304+ local should_rename=false
305+
306+ # Default behavior: dry-runs preserve, real releases rename
307+ if [[ " $dry_run " == " true " ]]; then
308+ should_rename=false # Default: preserve for dry-runs
309+ else
310+ should_rename=true # Default: rename for real releases
291311 fi
292312
293- print_status " Renaming $summary_file to $new_summary_file "
313+ # Override with explicit flags
314+ if [[ " $preserve_summary " == " true" ]]; then
315+ should_rename=false
316+ print_status " Forcing summary file preservation (--preserve-summary)"
317+ fi
294318
295- # Perform the rename operation with explicit error checking
296- if mv " $summary_file " " $new_summary_file " 2> /dev/null; then
297- # Verify the rename actually succeeded
298- if [[ -f " $new_summary_file " && ! -f " $summary_file " ]]; then
299- print_success " Successfully renamed summary file"
300-
301- # Handle git operations with better error handling
302- if git add " $new_summary_file " 2> /dev/null; then
303- print_status " Added new summary file to git"
304- else
305- print_warning " Failed to add new summary file to git (may already be tracked)"
306- fi
307-
308- # Remove old file from git if it exists
309- if git rm " $summary_file " 2> /dev/null; then
310- print_status " Removed old summary file from git"
311- else
312- print_warning " Old summary file not in git (already removed or never tracked)"
319+ if [[ " $remove_summary " == " true" ]]; then
320+ should_rename=true
321+ print_status " Forcing summary file rename (--remove-summary)"
322+ fi
323+
324+ # Handle conflicting flags
325+ if [[ " $preserve_summary " == " true" && " $remove_summary " == " true" ]]; then
326+ print_error " Conflicting flags: --preserve-summary and --remove-summary cannot be used together"
327+ exit 1
328+ fi
329+
330+ if [[ " $should_rename " == " true" ]]; then
331+ # Always remove the target file if it exists to ensure clean rename
332+ if [[ -f " $new_summary_file " ]]; then
333+ print_warning " $new_summary_file already exists. Removing existing file."
334+ rm -f " $new_summary_file "
335+ if [[ -f " $new_summary_file " ]]; then
336+ print_error " Failed to remove existing file: $new_summary_file "
337+ exit 1
313338 fi
314-
315- # Commit the changes
316- if git commit -m " docs(release): rename major changes summary for release $intended_new_version (refs #68)" 2> /dev/null; then
317- print_status " Committed summary file rename"
339+ fi
340+
341+ print_status " Renaming $summary_file to $new_summary_file "
342+
343+ # Perform the rename operation with explicit error checking
344+ if mv " $summary_file " " $new_summary_file " 2> /dev/null; then
345+ # Verify the rename actually succeeded
346+ if [[ -f " $new_summary_file " && ! -f " $summary_file " ]]; then
347+ print_success " Successfully renamed summary file"
348+
349+ # Handle git operations with better error handling
350+ if git add " $new_summary_file " 2> /dev/null; then
351+ print_status " Added new summary file to git"
352+ else
353+ print_warning " Failed to add new summary file to git (may already be tracked)"
354+ fi
355+
356+ # Remove old file from git if it exists
357+ if git rm " $summary_file " 2> /dev/null; then
358+ print_status " Removed old summary file from git"
359+ else
360+ print_warning " Old summary file not in git (already removed or never tracked)"
361+ fi
318362
319- # Push the changes
320- if git push 2> /dev/null; then
321- print_success " Pushed summary file changes"
363+ # Commit the changes
364+ if git commit -m " docs(release): rename major changes summary for release $intended_new_version (refs #68)" 2> /dev/null; then
365+ print_status " Committed summary file rename"
366+
367+ # Push the changes
368+ if git push 2> /dev/null; then
369+ print_success " Pushed summary file changes"
370+ else
371+ print_warning " Failed to push summary file changes (may already be up to date)"
372+ fi
322373 else
323- print_warning " Failed to push summary file changes (may already be up to date )"
374+ print_warning " Failed to commit summary file rename (no changes to commit )"
324375 fi
376+
377+ print_success " Committed and pushed $new_summary_file "
325378 else
326- print_warning " Failed to commit summary file rename (no changes to commit)"
379+ print_error " Rename operation appeared to succeed but file verification failed"
380+ print_error " Expected: $new_summary_file to exist and $summary_file to not exist"
381+ exit 1
327382 fi
328-
329- print_success " Committed and pushed $new_summary_file "
330383 else
331- print_error " Rename operation appeared to succeed but file verification failed "
332- print_error " Expected: $new_summary_file to exist and $summary_file to not exist "
384+ print_error " Failed to rename summary file from $summary_file to $new_summary_file "
385+ print_error " This may be due to file system permissions or the target file being locked "
333386 exit 1
334387 fi
335388 else
336- print_error " Failed to rename summary file from $summary_file to $new_summary_file "
337- print_error " This may be due to file system permissions or the target file being locked "
338- exit 1
389+ # Preserve the summary file
390+ print_status " Preserving summary file: $summary_file "
391+ print_success " Summary file will remain available for future runs "
339392 fi
340393 else
341- if [[ " $dry_run " == " true" ]]; then
342- print_warning " No major changes summary file found for base $base_version (dry run). Please create docs/release/latest-major-changes-since-${base_version} .md before running the release."
343- else
344- print_error " No major changes summary file found for base $base_version (real release). AI must create docs/release/latest-major-changes-since-${base_version} .md before resubmitting the release job."
345- exit 1
346- fi
394+ # Summary file doesn't exist - this is always an error
395+ print_error " No major changes summary file found for base $base_version "
396+ print_error " AI must create docs/release/latest-major-changes-since-${base_version} .md before any release or dry run"
397+ print_error " This file must contain a summary of major changes since version $base_version "
398+ exit 1
347399 fi
348400 fi
349401 # --- End major changes summary file handling ---
0 commit comments