Skip to content

Commit 7dd9e43

Browse files
authored
pack.yml: Parse string, array and object type changelog messages.
1 parent 3bd5f2b commit 7dd9e43

File tree

1 file changed

+25
-46
lines changed

1 file changed

+25
-46
lines changed

.github/workflows/pack.yml

+25-46
Original file line numberDiff line numberDiff line change
@@ -47,52 +47,31 @@ jobs:
4747
echo "version=$version" >> "$GITHUB_ENV"
4848
4949
# Create release body
50-
echo "$firstEntry" | "${jqCommand}" -j "
51-
.logs as \$clFirstEntryLogs | (
52-
\$clFirstEntryLogs |
53-
if ((.features | length) > 0) then
54-
(.features |
55-
map(\"* \" + .message + \"\n\") |
56-
. |= [\"### Features\n\"] + . |
57-
. |= . + [\"\n\"] |
58-
join(\"\"))
59-
else (\"\")
60-
end
61-
),
62-
(
63-
\$clFirstEntryLogs |
64-
if ((.fixes | length) > 0) then
65-
(.fixes |
66-
map(\"* \" + .message + \"\n\") |
67-
. |= [\"### Fixes\n\"] + . |
68-
. |= . + [\"\n\"] |
69-
join(\"\"))
70-
else (\"\")
71-
end
72-
),
73-
(
74-
\$clFirstEntryLogs |
75-
if ((.changes | length) > 0) then
76-
(.changes |
77-
map(\"* \" + .message + \"\n\") |
78-
. |= [\"### Changes\n\"] + . |
79-
. |= . + [\"\n\"] |
80-
join(\"\"))
81-
else (\"\")
82-
end
83-
),
84-
(
85-
\$clFirstEntryLogs |
86-
if ((.removed | length) > 0) then
87-
(.removed |
88-
map(\"* \" + .message + \"\n\") |
89-
. |= [\"### Removed\n\"] + . |
90-
. |= . + [\"\n\"] |
91-
join(\"\"))
92-
else (\"\")
93-
end
94-
)
95-
" >> "$releaseBodyFile"
50+
echo "$firstEntry" | "${jqCommand}" -j '
51+
def process_category($keyAndTitle):
52+
. as $logs |
53+
$keyAndTitle | split(";")[0] as $key |
54+
$keyAndTitle | split(";")[1] as $title |
55+
if ($logs[$key] | length) > 0 then
56+
($logs[$key] |
57+
map("* " +
58+
(if .message | type == "string" then .message
59+
elif .message | type == "array" then .message | join(" ")
60+
else .message | tostring
61+
end
62+
) +
63+
"\n") |
64+
. |= [$title] + . |
65+
. |= . + ["\n"] |
66+
join(""))
67+
else ("")
68+
end;
69+
.logs |
70+
process_category("features;### Features\n"),
71+
process_category("fixes;### Fixes\n"),
72+
process_category("changes;### Changes\n"),
73+
process_category("removed;### Removed\n")
74+
' >> "$releaseBodyFile"
9675
9776
# Update changelog.json date and remove empty features, fixes and changes entries
9877
"${jqCommand}" -j ".[0].date |= \"$(date +"%Y/%m/%d")\"" "${changelogPath}" > "${tmpFile}" && mv "${tmpFile}" "${changelogPath}"

0 commit comments

Comments
 (0)