Skip to content

Commit 285e308

Browse files
khewonclevan-m
andauthored
Add link to agent release notes on agent version change (#2304)
Co-authored-by: levan-m <[email protected]>
1 parent 6ccff83 commit 285e308

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed

.github/workflows/release.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,107 @@ jobs:
3636
CR_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
3737
CR_SKIP_EXISTING: true # Ignore chart changes when version was not updated (documentation)
3838
CR_GENERATE_RELEASE_NOTES: true
39+
- name: Check if datadog chart was modified
40+
id: datadog_modified
41+
run: |
42+
# Check if any files in charts/datadog/ were modified in this push
43+
if git diff --name-only HEAD~1 HEAD | grep -q "^charts/datadog/"; then
44+
echo "datadog_chart_modified=true" >> "$GITHUB_OUTPUT"
45+
echo "Datadog chart was modified in this push"
46+
else
47+
echo "datadog_chart_modified=false" >> "$GITHUB_OUTPUT"
48+
echo "Datadog chart was not modified in this push"
49+
fi
50+
- name: Check if datadog agent version changed
51+
id: agent_image_tag_change
52+
# Only check agent version for the datadog chart
53+
if: steps.datadog_modified.outputs.datadog_chart_modified == 'true'
54+
run: |
55+
# Default to no change detected
56+
echo "agent_changed=false" >> "$GITHUB_OUTPUT"
57+
58+
# Get the previous agent version
59+
old_version=$(git show HEAD~1:charts/datadog/values.yaml | yq e '.agents.image.tag' - 2>/dev/null)
60+
if [[ -z "$old_version" ]]; then
61+
echo "Unable to get agent image version from previous commit"
62+
exit 0
63+
fi
64+
65+
# Get the current agent version
66+
new_version=$(yq e '.agents.image.tag' charts/datadog/values.yaml 2>/dev/null)
67+
if [[ -z "$new_version" ]]; then
68+
echo "Unable to get agent image version from current values.yaml"
69+
exit 0
70+
fi
71+
72+
# Compare versions - only set to true if they're different
73+
if [[ "$old_version" != "$new_version" ]]; then
74+
echo "Agent version changed from $old_version to $new_version"
75+
echo "agent_changed=true" >> "$GITHUB_OUTPUT"
76+
echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
77+
else
78+
echo "Agent version unchanged: $old_version"
79+
fi
80+
- name: Enhance datadog chart release with agent release notes
81+
if: steps.agent_image_tag_change.outputs.agent_changed == 'true'
82+
run: |
83+
# Get the chart version for this commit to construct the expected release tag
84+
chart_version=$(yq e '.version' charts/datadog/Chart.yaml 2>/dev/null)
85+
if [[ -z "$chart_version" ]]; then
86+
echo "Unable to get chart version from Chart.yaml"
87+
exit 0
88+
fi
89+
90+
expected_release_tag="datadog-${chart_version}"
91+
echo "Looking for release: $expected_release_tag"
92+
93+
# Poll for the specific release to be created (up to 5 minutes)
94+
max_attempts=10 # 5 minutes with 30-second intervals
95+
attempt=0
96+
97+
while [[ $attempt -lt $max_attempts ]]; do
98+
# Check if the expected release exists in GitHub
99+
if gh release view "$expected_release_tag" >/dev/null 2>&1; then
100+
echo "Found release: $expected_release_tag (attempt $((attempt + 1)))"
101+
latest_datadog_chart_tag="$expected_release_tag"
102+
break
103+
fi
104+
105+
attempt=$((attempt + 1))
106+
echo "Waiting for release $expected_release_tag to be created... (attempt $attempt/$max_attempts)"
107+
sleep 30
108+
done
109+
110+
if [[ $attempt -eq $max_attempts ]]; then
111+
echo "Timeout: Release $expected_release_tag not found after 5 minutes"
112+
exit 0
113+
fi
114+
115+
if [[ -n "$latest_datadog_chart_tag" ]]; then
116+
echo "Enhancing release notes for $latest_datadog_chart_tag"
117+
118+
new_version="${{ steps.agent_image_tag_change.outputs.new_version }}"
119+
120+
# Get current release notes
121+
current_notes=$(gh release view "$latest_datadog_chart_tag" --json body -q .body 2>/dev/null || echo "")
122+
123+
# Add agent release notes link with version change info
124+
enhanced_notes="${current_notes}
125+
126+
---
127+
128+
**🚀 Datadog Agent Version Update**
129+
130+
This release updates the default Datadog Agent to \`${new_version}\`.
131+
132+
**📋 What's New in Agent ${new_version}**
133+
For information about new features, bug fixes, and improvements in this agent version, see the [Datadog Agent ${new_version} Release Notes](https://github.com/DataDog/datadog-agent/releases/tag/${new_version})."
134+
135+
# Update the release notes
136+
gh release edit "$latest_datadog_chart_tag" --notes "$enhanced_notes"
137+
echo "Enhanced release notes for $latest_datadog_chart_tag with agent version update to $new_version"
138+
else
139+
echo "No datadog release found to enhance"
140+
fi
141+
env:
142+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)