Skip to content

Commit

Permalink
sed -i option requires an option on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Gildas Cherruel committed Aug 8, 2023
1 parent 3a1a239 commit f14fcfc
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 11 deletions.
43 changes: 36 additions & 7 deletions hooks/common/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,15 @@ function update_chart_version() { # {{{2
local version=$2

verbose "Updating Chart: ${file##*/} to ${version}"
sed -Ei "/^version:/s/[0-9]+\.[0-9]+\.[0-9]+/${version}/" "$file"
sed -Ei .bak "/^version:/s/[0-9]+\.[0-9]+\.[0-9]+/${version}/" "$file"
status=$?
if (( status )); then
error "Failed to update ${file##*/}, exit code: $status"
return $status
else
success "Updated ${file##*/}"
rm -f "$file.bak"
fi
return 0
} # 2}}}

Expand All @@ -118,8 +126,15 @@ function update_chart_appversion() { # {{{2
local status

verbose "Updating App Version: ${file##*/} to ${version}"
sed -Ei "/^appVersion:/s/[0-9]+\.[0-9]+\.[0-9]+/${version}/" "$file"
status=$? ; (( status )) && error "Failed to update ${file##*/}, exit code: $status" || success "Updated ${file##*/}"
sed -Ei .bak "/^appVersion:/s/[0-9]+\.[0-9]+\.[0-9]+/${version}/" "$file"
status=$?
if (( status )); then
error "Failed to update ${file##*/}, exit code: $status"
return $status
else
success "Updated ${file##*/}"
rm -f "$file.bak"
fi
return 0
} # 2}}}

Expand All @@ -130,11 +145,18 @@ function update_dockerfile_version() { # {{{2
local status

verbose "Updating: ${file##*/} to ${version}"
sed -Ei \
sed -Ei .bak \
-e "/^LABEL\s+org\.opencontainers\.image\.version/s/[0-9]+\.[0-9]+\.[0-9]+/${version}/" \
-e "/^LABEL\s+org\.opencontainers\.image\.created/s/[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z/$(date -u +%Y-%m-%dT%H:%M:%SZ)/" \
"$file"
status=$? ; (( status )) && error "Failed to update ${file##*/}, exit code: $status" || success "Updated ${file##*/}"
status=$?
if (( status )); then
error "Failed to update ${file##*/}, exit code: $status"
return $status
else
success "Updated ${file##*/}"
rm -f "$file.bak"
fi
} # 2}}}

function update_appveyor_version() { # {{{2
Expand All @@ -143,9 +165,16 @@ function update_appveyor_version() { # {{{2
local status

verbose "Updating: ${file##*/} to ${version}"
sed -Ei \
sed -Ei .bak \
-e "/^version:/s/.*/version: ${version}+{build}/" \
"$file"
status=$? ; (( status )) && error "Failed to update ${file##*/}, exit code: $status" || success "Updated ${file##*/}"
status=$?
if (( status )); then
error "Failed to update ${file##*/}, exit code: $status"
return $status
else
success "Updated ${file##*/}"
rm -f "$file.bak"
fi
} # 2}}}

11 changes: 9 additions & 2 deletions hooks/go/functions-lang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ function update_version_file() { # {{{2
local status

verbose "Updating: ${file##*/} to ${version}"
sed -Ei "/^var[ ]+VERSION[ ]*=/s/[0-9]+\.[0-9]+\.[0-9]+/${version}/" "$file"
status=$? ; (( status )) && error "Failed to update ${file##*/}, exit code: $status" || success "Updated ${file##*/}"
sed -Ei .bak "/^var[ ]+VERSION[ ]*=/s/[0-9]+\.[0-9]+\.[0-9]+/${version}/" "$file"
status=$?
if (( status )); then
error "Failed to update ${file##*/}, exit code: $status"
return $status
else
success "Updated ${file##*/}"
rm -f "$file.bak"
fi
return 0
} # 2}}}
11 changes: 9 additions & 2 deletions hooks/node/functions-lang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ function update_version_file() { # {{{2
local status

verbose "Updating: ${file##*/} to ${version}"
sed -Ei "/^[ \t]*\"version\":[ \t]*\"/s/[0-9]+\.[0-9]+\.[0-9]+/${version}/" "$file"
status=$? ; (( status )) && error "Failed to update ${file##*/}, exit code: $status" || success "Updated ${file##*/}"
sed -Ei .bak "/^[ \t]*\"version\":[ \t]*\"/s/[0-9]+\.[0-9]+\.[0-9]+/${version}/" "$file"
status=$?
if (( status )); then
error "Failed to update ${file##*/}, exit code: $status"
return $status
else
success "Updated ${file##*/}"
rm -f "$file.bak"
fi
return 0
} # 2}}}

0 comments on commit f14fcfc

Please sign in to comment.