Skip to content

[chore] fix use of sed by writing to a temp file #923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions .github/workflows/scripts/bump-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,6 @@ escaped_current_beta_core=${current_beta_core//./\\.}
escaped_current_beta_contrib=${current_beta_contrib//./\\.}
escaped_current_stable=${current_stable//./\\.}

# Determine the OS and set the sed command accordingly
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
sed_command="sed -i ''"
else
# Linux
sed_command="sed -i"
fi

# Update versions in each manifest file
echo "Making the following updates:"
echo " - core beta module set from $current_beta_core to $next_beta_core"
Expand All @@ -160,17 +151,22 @@ echo " - contrib beta module set from $current_beta_contrib to $next_beta_contr
echo " - distribution version to $next_distribution_version"
for file in "${manifest_files[@]}"; do
if [ -f "$file" ]; then
$sed_command "s/\(^.*go\.opentelemetry\.io\/collector\/.*\) v$escaped_current_beta_core/\1 v$next_beta_core/" "$file"
$sed_command "s/\(^.*github\.com\/open-telemetry\/opentelemetry-collector-contrib\/.*\) v$escaped_current_beta_contrib/\1 v$next_beta_contrib/" "$file"
$sed_command "s/\(^.*go\.opentelemetry\.io\/collector\/.*\) v$escaped_current_stable/\1 v$next_stable_core/" "$file"
$sed_command "s/version: .*/version: $next_distribution_version/" "$file"
sed "s/\(^.*go\.opentelemetry\.io\/collector\/.*\) v$escaped_current_beta_core/\1 v$next_beta_core/" "$file" > "$file.tmp"
mv "$file.tmp" "$file"
sed "s/\(^.*github\.com\/open-telemetry\/opentelemetry-collector-contrib\/.*\) v$escaped_current_beta_contrib/\1 v$next_beta_contrib/" "$file" > "$file.tmp"
mv "$file.tmp" "$file"
sed "s/\(^.*go\.opentelemetry\.io\/collector\/.*\) v$escaped_current_stable/\1 v$next_stable_core/" "$file" > "$file.tmp"
mv "$file.tmp" "$file"
sed "s/version: .*/version: $next_distribution_version/" "$file" > "$file.tmp"
mv "$file.tmp" "$file"
else
echo "File $file does not exist"
fi
done

# Update Makefile OCB version
$sed_command "s/OTELCOL_BUILDER_VERSION ?= $escaped_current_beta_core/OTELCOL_BUILDER_VERSION ?= $next_beta_core/" Makefile
sed "s/OTELCOL_BUILDER_VERSION ?= $escaped_current_beta_core/OTELCOL_BUILDER_VERSION ?= $next_beta_core/" Makefile > Makefile.tmp
mv Makefile.tmp Makefile

echo "Version update completed."

Expand Down