# Rebuild path: Update existing release assets without changing the tag/version name
# Optionally accepts a tag argument; defaults to latest tag.
TAG_ARG=$2
if[ -z "$TAG_ARG"];then
TAG_VERSION=$(git describe --tags --abbrev=0)
else
TAG_VERSION=$TAG_ARG
fi
if[ -z "$TAG_VERSION"];then
print_error "No tag found. Provide an explicit tag: ./scripts/release.sh rebuild vX.Y.Z"
exit1
fi
print_status "Rebuilding existing release for tag: $TAG_VERSION"
echo
read -p "Proceed to rebuild $TAG_VERSION and update its assets? (y/N): " -n 1 -r
echo
if[[ ! $REPLY=~ ^[Yy]$ ]];then
print_warning "Rebuild cancelled"
exit0
fi
ifcommand -v gh >/dev/null 2>&1;then
print_status "Dispatching GitHub Actions workflow (Release) via gh CLI..."
gh workflow run "Release"\
--ref main \
-f tag="$TAG_VERSION"\
-f remove_old_assets=true
print_status "Workflow dispatched. Track progress in GitHub Actions."
else
print_warning "GitHub CLI (gh) not found. Trigger the workflow manually:"
echo"- Go to: https://github.com/$(git config --get remote.origin.url | sed -E 's#(git@|https://)([^/:]+)[:/]([^/.]+/[^.]+)(\.git)?#\2/\3#')/actions/workflows/release.yml"
echo"- Click 'Run workflow', set tag to $TAG_VERSION, and run."