Skip to content

Commit a118bd7

Browse files
vdemeesterclaude
andcommitted
fix: always quote descriptions in AH changelog
Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
1 parent 4be0731 commit a118bd7

4 files changed

Lines changed: 94 additions & 65 deletions

File tree

hack/apply-ah-changes.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python3
2+
"""Replace artifacthub.io/changes annotation in YAML from stdin, write to stdout.
3+
4+
Usage: cat task.yaml | python3 apply-ah-changes.py changes.txt
5+
"""
6+
import re
7+
import sys
8+
9+
content = sys.stdin.read()
10+
with open(sys.argv[1]) as f:
11+
changes_raw = f.read()
12+
13+
# Ensure all description values are quoted
14+
lines = []
15+
for line in changes_raw.strip().split('\n'):
16+
m = re.match(r'(\s+description:\s*)(.*)', line)
17+
if m:
18+
prefix, val = m.group(1), m.group(2)
19+
val = val.strip().strip('"').strip("'")
20+
lines.append(prefix + '"' + val + '"')
21+
else:
22+
lines.append(line)
23+
24+
new_changes = ' artifacthub.io/changes: |\n' + '\n'.join(lines)
25+
content = re.sub(
26+
r' artifacthub\.io/changes: \|\n( .*\n)*',
27+
new_changes.rstrip() + '\n',
28+
content,
29+
)
30+
sys.stdout.write(content)

hack/release.sh

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,12 @@ Output the two sections separated by the exact string ---SEPARATOR--- on its own
154154
fi
155155

156156
# Sanitize description for Artifact Hub YAML (strip {}[]&*#?|-<>=!%@ or quote)
157+
# Sanitize and always quote description for Artifact Hub YAML-in-YAML
158+
# AH parses the changes |block as YAML, so descriptions must be quoted
157159
sanitize_desc() {
158160
local d
159161
d=$(echo "$1" | sed 's/[{}]//g; s/[][&*#?|<>=!%@`]//g' | sed 's/ */ /g' | sed 's/^ //;s/ $//')
160-
# Quote if it contains colons (YAML special char)
161-
if echo "$d" | grep -qF ':'; then
162-
echo "\"${d}\""
163-
else
164-
echo "$d"
165-
fi
162+
echo "\"${d}\""
166163
}
167164

168165
if [[ "${USE_LLM}" != true ]]; then
@@ -215,20 +212,14 @@ apply_version_bumps() {
215212

216213
# --- Helper: update artifacthub changelog in content (stdin → stdout) ---
217214
apply_ah_changes() {
218-
local normalized
219-
normalized=$(echo -e "${AH_CHANGES}" | grep -v '^[[:space:]]*```' | sed -e 's/^[[:space:]]*- kind:/ - kind:/' -e 's/^[[:space:]]*description:/ description:/')
220-
python3 -c "
221-
import re, sys
222-
content = sys.stdin.read()
223-
new_changes = ''' artifacthub.io/changes: |
224-
${normalized}'''
225-
content = re.sub(
226-
r' artifacthub\.io/changes: \|\n( .*\n)*',
227-
new_changes.rstrip() + '\n',
228-
content,
229-
)
230-
sys.stdout.write(content)
231-
"
215+
local tmpchanges
216+
tmpchanges=$(mktemp)
217+
echo -e "${AH_CHANGES}" | grep -v '^[[:space:]]*```' \
218+
| sed -e 's/^[[:space:]]*- kind:/ - kind:/' \
219+
-e 's/^[[:space:]]*description:/ description:/' \
220+
> "${tmpchanges}"
221+
python3 "${SCRIPT_DIR}/apply-ah-changes.py" "${tmpchanges}"
222+
rm -f "${tmpchanges}"
232223
}
233224

234225
if [[ "${DRY_RUN}" == true ]]; then

stepaction/git-clone/git-clone.yaml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,58 @@ metadata:
99
annotations:
1010
artifacthub.io/category: integration-delivery
1111
artifacthub.io/changes: |
12+
- kind: fixed
13+
description: "always quote descriptions in AH changelog"
14+
- kind: changed
15+
description: "bump version to v1.6.0"
1216
- kind: fixed
13-
description: quote descriptions containing colons in changelog
17+
description: "quote descriptions containing colons in changelog"
1418
- kind: changed
15-
description: bump version to v1.6.0
19+
description: "bump version to v1.6.0"
1620
- kind: fixed
17-
description: sanitize special YAML chars in changelog descriptions
21+
description: "sanitize special YAML chars in changelog descriptions"
1822
- kind: changed
19-
description: bump version to v1.6.0
23+
description: "bump version to v1.6.0"
2024
- kind: fixed
21-
description: reset version for v1.6.0 re-release (pyyaml generator)
25+
description: "reset version for v1.6.0 re-release (pyyaml generator)"
2226
- kind: fixed
23-
description: quote special characters in artifacthub changelog annotation
27+
description: "quote special characters in artifacthub changelog annotation"
2428
- kind: changed
25-
description: bump version to v1.6.0
29+
description: "bump version to v1.6.0"
2630
- kind: fixed
27-
description: reset version to v1.5.0 for v1.6.0 re-release
31+
description: "reset version to v1.5.0 for v1.6.0 re-release"
2832
- kind: fixed
29-
description: rewrite StepAction generator with pyyaml
33+
description: "rewrite StepAction generator with pyyaml"
3034
- kind: changed
31-
description: bump version to v1.6.1
35+
description: "bump version to v1.6.1"
3236
- kind: fixed
33-
description: release script signing and bundle workflow
37+
description: "release script signing and bundle workflow"
3438
- kind: fixed
35-
description: release script version detection and signing
39+
description: "release script version detection and signing"
3640
- kind: fixed
3741
description: "strip spurious resources: from signed task YAMLs"
3842
- kind: fixed
3943
description: "strip spurious resources: from signed task YAML"
4044
- kind: changed
41-
description: set Artifact Hub repository ID for StepAction
45+
description: "set Artifact Hub repository ID for StepAction"
4246
- kind: changed
43-
description: add Artifact Hub metadata for StepAction repository
47+
description: "add Artifact Hub metadata for StepAction repository"
4448
- kind: changed
45-
description: bump version to v1.6.0
49+
description: "bump version to v1.6.0"
4650
- kind: fixed
47-
description: release script backtick stripping in changelog normalization
51+
description: "release script backtick stripping in changelog normalization"
4852
- kind: changed
49-
description: add task signing to release script
53+
description: "add task signing to release script"
5054
- kind: changed
51-
description: add parameters and results tables to StepAction README
55+
description: "add parameters and results tables to StepAction README"
5256
- kind: added
53-
description: stepaction tests, bundle publishing, release integration
57+
description: "stepaction tests, bundle publishing, release integration"
5458
- kind: changed
55-
description: update READMEs for Artifact Hub and StepAction
59+
description: "update READMEs for Artifact Hub and StepAction"
5660
- kind: added
57-
description: add git-clone StepAction, generated from Task
61+
description: "add git-clone StepAction, generated from Task"
5862
- kind: changed
59-
description: add task signing public key
63+
description: "add task signing public key"
6064
artifacthub.io/license: Apache-2.0
6165
artifacthub.io/links: |
6266
- name: support

task/git-clone/git-clone.yaml

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,58 @@ metadata:
44
annotations:
55
artifacthub.io/category: integration-delivery
66
artifacthub.io/changes: |
7+
- kind: fixed
8+
description: "always quote descriptions in AH changelog"
9+
- kind: changed
10+
description: "bump version to v1.6.0"
711
- kind: fixed
8-
description: quote descriptions containing colons in changelog
12+
description: "quote descriptions containing colons in changelog"
913
- kind: changed
10-
description: bump version to v1.6.0
14+
description: "bump version to v1.6.0"
1115
- kind: fixed
12-
description: sanitize special YAML chars in changelog descriptions
16+
description: "sanitize special YAML chars in changelog descriptions"
1317
- kind: changed
14-
description: bump version to v1.6.0
18+
description: "bump version to v1.6.0"
1519
- kind: fixed
16-
description: reset version for v1.6.0 re-release (pyyaml generator)
20+
description: "reset version for v1.6.0 re-release (pyyaml generator)"
1721
- kind: fixed
18-
description: quote special characters in artifacthub changelog annotation
22+
description: "quote special characters in artifacthub changelog annotation"
1923
- kind: changed
20-
description: bump version to v1.6.0
24+
description: "bump version to v1.6.0"
2125
- kind: fixed
22-
description: reset version to v1.5.0 for v1.6.0 re-release
26+
description: "reset version to v1.5.0 for v1.6.0 re-release"
2327
- kind: fixed
24-
description: rewrite StepAction generator with pyyaml
28+
description: "rewrite StepAction generator with pyyaml"
2529
- kind: changed
26-
description: bump version to v1.6.1
30+
description: "bump version to v1.6.1"
2731
- kind: fixed
28-
description: release script signing and bundle workflow
32+
description: "release script signing and bundle workflow"
2933
- kind: fixed
30-
description: release script version detection and signing
34+
description: "release script version detection and signing"
3135
- kind: fixed
3236
description: "strip spurious resources: from signed task YAMLs"
3337
- kind: fixed
3438
description: "strip spurious resources: from signed task YAML"
3539
- kind: changed
36-
description: set Artifact Hub repository ID for StepAction
40+
description: "set Artifact Hub repository ID for StepAction"
3741
- kind: changed
38-
description: add Artifact Hub metadata for StepAction repository
42+
description: "add Artifact Hub metadata for StepAction repository"
3943
- kind: changed
40-
description: bump version to v1.6.0
44+
description: "bump version to v1.6.0"
4145
- kind: fixed
42-
description: release script backtick stripping in changelog normalization
46+
description: "release script backtick stripping in changelog normalization"
4347
- kind: changed
44-
description: add task signing to release script
48+
description: "add task signing to release script"
4549
- kind: changed
46-
description: add parameters and results tables to StepAction README
50+
description: "add parameters and results tables to StepAction README"
4751
- kind: added
48-
description: stepaction tests, bundle publishing, release integration
52+
description: "stepaction tests, bundle publishing, release integration"
4953
- kind: changed
50-
description: update READMEs for Artifact Hub and StepAction
54+
description: "update READMEs for Artifact Hub and StepAction"
5155
- kind: added
52-
description: add git-clone StepAction, generated from Task
56+
description: "add git-clone StepAction, generated from Task"
5357
- kind: changed
54-
description: add task signing public key
58+
description: "add task signing public key"
5559
artifacthub.io/license: Apache-2.0
5660
artifacthub.io/links: |
5761
- name: support
@@ -72,7 +76,7 @@ metadata:
7276
tekton.dev/signature: MEYCIQCm/4td/qSjle4l8U0yihk1ONgg6Mr4suUJj24kLKwOdgIhALTuOKknf7fJObtkUb/6ggEjovHDh3ITCNJwRMGuJuKy
7377
tekton.dev/tags: git
7478
labels:
75-
app.kubernetes.io/version: 1.6.0
79+
app.kubernetes.io/version: "1.6.0"
7680
name: git-clone
7781
spec:
7882
description: |-

0 commit comments

Comments
 (0)