Skip to content

Commit d950df8

Browse files
committed
fix: release.sh
1 parent ca7af7d commit d950df8

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

release.sh

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ BLUE='\033[0;34m'
1212
NC='\033[0m' # No Color
1313

1414
DRY_RUN=false
15+
WITH_GH_RELEASE=false
1516
VERSION=""
1617

1718
function release::show_usage() {
@@ -22,12 +23,14 @@ Arguments:
2223
version The new version number (e.g., 0.30.0)
2324
2425
Options:
25-
--dry-run Preview changes without modifying any files
26-
-h, --help Show this help message
26+
--dry-run Preview changes without modifying any files
27+
--with-gh-release Create the GitHub release (default: print manual instructions)
28+
-h, --help Show this help message
2729
2830
Example:
2931
./release.sh 0.30.0
3032
./release.sh 0.30.0 --dry-run
33+
./release.sh 0.30.0 --with-gh-release
3134
EOF
3235
}
3336

@@ -151,7 +154,7 @@ function release::update_changelog() {
151154
local new_header="## [$new_version]($compare_url) - $today"
152155

153156
# Replace "## Unreleased" with new Unreleased + version header
154-
sed -i.bak "s/^## Unreleased$/## Unreleased\n\n$new_header/" "$file"
157+
sed -i.bak "s|^## Unreleased$|## Unreleased\n\n$new_header|" "$file"
155158
rm -f "$file.bak"
156159
release::log_success "Updated $file with version $new_version"
157160
}
@@ -228,12 +231,17 @@ function release::create_github_release() {
228231
return
229232
fi
230233

231-
if ! release::confirm_action "Do you want to create the GitHub release now?"; then
232-
release::log_warning "Skipping GitHub release creation"
233-
echo ""
234-
echo "To create the release manually, run:"
234+
if [[ "$WITH_GH_RELEASE" != true ]]; then
235+
release::log_info "To create the GitHub release, run:"
235236
echo -e " ${BLUE}gh release create $version bin/bashunit bin/checksum \\"
236237
echo -e " --title \"$version\" --notes-file \"$notes_file\"${NC}"
238+
echo ""
239+
release::log_info "Or re-run with --with-gh-release flag"
240+
return
241+
fi
242+
243+
if ! release::confirm_action "Do you want to create the GitHub release now?"; then
244+
release::log_warning "Skipping GitHub release creation"
237245
return
238246
fi
239247

@@ -374,6 +382,10 @@ function release::main() {
374382
DRY_RUN=true
375383
shift
376384
;;
385+
--with-gh-release)
386+
WITH_GH_RELEASE=true
387+
shift
388+
;;
377389
-h|--help)
378390
release::show_usage
379391
exit 0

0 commit comments

Comments
 (0)