Skip to content

Commit bb667d2

Browse files
fix(tag_release): improve macOS and Linux compatibility (#335)
Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
1 parent f08bb30 commit bb667d2

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

scripts/tag_release.sh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,15 @@ add_json_error() {
103103
local details="${3:-}"
104104
local exit_code="${4:-1}"
105105

106-
JSON_OUTPUT=$(echo "$JSON_OUTPUT" | jq --arg type "$type" --arg msg "$message" --arg details "$details" --argjson code "$exit_code" \
107-
'.errors += [{"type": $type, "message": $msg, "details": $details, "exit_code": $code}]')
106+
JSON_OUTPUT=$(echo "$JSON_OUTPUT" | jq --arg type "$type" --arg msg "$message" --arg details "$details" --argjson code "$exit_code" '.errors += [{"type": $type, "message": $msg, "details": $details, "exit_code": $code}]')
108107
}
109108

110109
add_json_warning() {
111110
local module="$1"
112111
local message="$2"
113112
local type="$3"
114113

115-
JSON_OUTPUT=$(echo "$JSON_OUTPUT" | jq --arg module "$module" --arg msg "$message" --arg type "$type" \
116-
'.warnings += [{"module": $module, "message": $msg, "type": $type}]')
114+
JSON_OUTPUT=$(echo "$JSON_OUTPUT" | jq --arg module "$module" --arg msg "$message" --arg type "$type" '.warnings += [{"module": $module, "message": $msg, "type": $type}]')
117115
}
118116

119117
add_json_module() {
@@ -125,9 +123,7 @@ add_json_module() {
125123
local status="$6"
126124
local already_existed="$7"
127125

128-
JSON_OUTPUT=$(echo "$JSON_OUTPUT" | jq --arg ns "$namespace" --arg name "$module_name" --arg path "$path" \
129-
--arg version "$version" --arg tag "$tag_name" --arg status "$status" --argjson existed "$already_existed" \
130-
'.modules += [{"namespace": $ns, "module_name": $name, "path": $path, "version": $version, "tag_name": $tag, "status": $status, "already_existed": $existed}]')
126+
JSON_OUTPUT=$(echo "$JSON_OUTPUT" | jq --arg ns "$namespace" --arg name "$module_name" --arg path "$path" --arg version "$version" --arg tag "$tag_name" --arg status "$status" --argjson existed "$already_existed" '.modules += [{"namespace": $ns, "module_name": $name, "path": $path, "version": $version, "tag_name": $tag, "status": $status, "already_existed": $existed}]')
131127
}
132128

133129
parse_arguments() {
@@ -235,11 +231,11 @@ extract_version_from_readme() {
235231
}
236232

237233
local version_line
238-
version_line=$(grep -E "source\s*=\s*\"registry\.coder\.com/${namespace}/${module_name}" "$readme_path" | head -1 || echo "")
234+
version_line=$(grep -E "source[[:space:]]*=[[:space:]]*\"registry\.coder\.com/${namespace}/${module_name}" "$readme_path" | head -1 || echo "")
239235

240236
if [ -n "$version_line" ]; then
241237
local version
242-
version=$(echo "$version_line" | sed -n 's/.*version\s*=\s*"\([^"]*\)".*/\1/p')
238+
version=$(echo "$version_line" | sed -n 's/.*version[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p')
243239
if [ -n "$version" ]; then
244240
log "DEBUG" "Found version '$version' from source line: $version_line"
245241
echo "$version"
@@ -248,7 +244,7 @@ extract_version_from_readme() {
248244
fi
249245

250246
local fallback_version
251-
fallback_version=$(grep -E 'version\s*=\s*"[0-9]+\.[0-9]+\.[0-9]+"' "$readme_path" | head -1 | sed 's/.*version\s*=\s*"\([^"]*\)".*/\1/' || echo "")
247+
fallback_version=$(grep -E 'version[[:space:]]*=[[:space:]]*"[0-9]+\.[0-9]+\.[0-9]+"' "$readme_path" | head -1 | sed 's/.*version[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/' || echo "")
252248

253249
if [ -n "$fallback_version" ]; then
254250
log "DEBUG" "Found fallback version '$fallback_version'"

0 commit comments

Comments
 (0)