Skip to content

Commit 87f37e2

Browse files
NimrodAvni78claude
andcommitted
ci: auto-bump OBI chart dependency (sync-obi workflow)
Adds a repository_dispatch-driven workflow that mirrors the opentelemetry-collector sync: when the coralogix opentelemetry-ebpf-instrumentation chart releases, it bumps the dependency in otel-integration, updates the changelog + golden renders, and opens a bump PR (also runnable via workflow_dispatch). Generalizes scripts/bump-otel-collector-version.sh with --dependency-name and --charts flags; collector defaults are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent caf0790 commit 87f37e2

2 files changed

Lines changed: 264 additions & 9 deletions

File tree

.github/workflows/sync-obi.yml

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
name: Sync OBI Chart Version
2+
3+
on:
4+
repository_dispatch:
5+
types: [obi-chart-release]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'New opentelemetry-ebpf-instrumentation chart version'
10+
required: true
11+
type: string
12+
13+
env:
14+
DEPENDENCY_NAME: opentelemetry-ebpf-instrumentation
15+
# Charts consuming the OBI chart dependency
16+
CHARTS: otel-integration
17+
# Path (relative to repo root) whose Chart.yaml carries the dependency
18+
CHART_PATHS: otel-integration/k8s-helm
19+
# Source of the chart + changelog
20+
SOURCE_REPO: coralogix/opentelemetry-helm-charts
21+
CHANGELOG_PATH: charts/opentelemetry-ebpf-instrumentation/CHANGELOG.md
22+
23+
jobs:
24+
bump-version:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: write
28+
pull-requests: write
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- uses: azure/setup-helm@v4
36+
37+
- name: Install yq
38+
run: |
39+
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
40+
sudo chmod +x /usr/local/bin/yq
41+
42+
- name: Add helm repos
43+
run: |
44+
helm repo add coralogix-charts https://cgx.jfrog.io/artifactory/coralogix-charts
45+
helm repo add coralogix-charts-virtual https://cgx.jfrog.io/artifactory/coralogix-charts-virtual
46+
helm repo update
47+
48+
- name: Get version
49+
id: version
50+
run: |
51+
if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then
52+
VERSION="${{ github.event.client_payload.version }}"
53+
SOURCE_PR="${{ github.event.client_payload.pr_url }}"
54+
else
55+
VERSION="${{ inputs.version }}"
56+
SOURCE_PR=""
57+
fi
58+
echo "value=$VERSION" >> $GITHUB_OUTPUT
59+
echo "source_pr=$SOURCE_PR" >> $GITHUB_OUTPUT
60+
61+
- name: Extract full changelog
62+
id: changelog
63+
run: |
64+
TARGET_VERSION="${{ steps.version.outputs.value }}"
65+
echo "Target version: $TARGET_VERSION"
66+
67+
# Current pinned dependency version across consuming charts
68+
MIN_VERSION=""
69+
for chart in $CHART_PATHS; do
70+
if [[ -f "${chart}/Chart.yaml" ]]; then
71+
VER=$(yq ".dependencies[] | select(.name == \"$DEPENDENCY_NAME\") | .version" "${chart}/Chart.yaml" 2>/dev/null | head -1 | tr -d '"')
72+
if [[ -n "$VER" ]]; then
73+
echo " $chart: $VER"
74+
if [[ -z "$MIN_VERSION" ]] || [[ "$(printf '%s\n' "$VER" "$MIN_VERSION" | sort -V | head -1)" == "$VER" ]]; then
75+
MIN_VERSION="$VER"
76+
fi
77+
fi
78+
fi
79+
done
80+
81+
echo "Minimum version across charts: $MIN_VERSION"
82+
83+
# Skip if minimum version is at or above target (all charts already up-to-date)
84+
HIGHEST=$(printf '%s\n' "$MIN_VERSION" "$TARGET_VERSION" | sort -V | tail -1)
85+
if [[ "$MIN_VERSION" == "$TARGET_VERSION" ]] || [[ "$HIGHEST" == "$MIN_VERSION" ]]; then
86+
echo "All charts already at target version or newer (min=$MIN_VERSION >= target=$TARGET_VERSION)"
87+
echo "status=skip" >> $GITHUB_OUTPUT
88+
echo "file=" >> $GITHUB_OUTPUT
89+
exit 0
90+
fi
91+
92+
echo "Baseline for changelog: $MIN_VERSION"
93+
94+
# Fetch the OBI chart CHANGELOG.md and extract entries between versions
95+
CHANGELOG=$(gh api "repos/${SOURCE_REPO}/contents/${CHANGELOG_PATH}" \
96+
--jq '.content' | base64 -d | awk -v current="$MIN_VERSION" -v target="$TARGET_VERSION" '
97+
function semver_cmp(v1, v2, a1, a2, i) {
98+
split(v1, a1, "."); split(v2, a2, ".")
99+
for (i = 1; i <= 3; i++) {
100+
if (a1[i]+0 < a2[i]+0) return -1
101+
if (a1[i]+0 > a2[i]+0) return 1
102+
}
103+
return 0
104+
}
105+
/^[[:space:]]*### v[0-9]/ {
106+
match($0, /[0-9]+\.[0-9]+\.[0-9]+/)
107+
ver = substr($0, RSTART, RLENGTH)
108+
in_range = (semver_cmp(ver, current) > 0 && semver_cmp(ver, target) <= 0)
109+
if (in_range) {
110+
if (seen_version) print ""
111+
print "#### Changes from " ENVIRON["DEPENDENCY_NAME"] " " ver ":"
112+
seen_version = 1
113+
}
114+
next
115+
}
116+
in_range && /^[[:space:]]*-/ { print }
117+
')
118+
119+
if [[ -n "$CHANGELOG" ]]; then
120+
echo "$CHANGELOG" > /tmp/changelog-entries.txt
121+
echo "status=ok" >> $GITHUB_OUTPUT
122+
echo "file=/tmp/changelog-entries.txt" >> $GITHUB_OUTPUT
123+
echo "Extracted changelog entries from $MIN_VERSION to $TARGET_VERSION"
124+
echo "$CHANGELOG" | head -10
125+
else
126+
echo "status=empty" >> $GITHUB_OUTPUT
127+
echo "file=" >> $GITHUB_OUTPUT
128+
echo "No changelog entries found"
129+
fi
130+
env:
131+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132+
133+
- name: Check if update needed
134+
if: steps.changelog.outputs.status == 'skip'
135+
run: |
136+
echo "::notice::Already at target version or newer - skipping"
137+
exit 0
138+
139+
- name: Close stale bump PRs
140+
if: steps.changelog.outputs.status != 'skip'
141+
run: |
142+
VERSION="${{ steps.version.outputs.value }}"
143+
144+
gh pr list --label obi-bump --state open --json number,title | jq -c '.[]' | while read -r row; do
145+
PR_NUM=$(echo "$row" | jq -r '.number')
146+
PR_VERSION=$(echo "$row" | jq -r '.title' | grep -oE '[0-9]+\.[0-9]+\.[0-9]+$' || true)
147+
148+
[[ -z "$PR_VERSION" || "$PR_VERSION" == "$VERSION" ]] && continue
149+
150+
HIGHEST=$(printf '%s\n' "$PR_VERSION" "$VERSION" | sort -V | tail -1)
151+
if [[ "$HIGHEST" == "$VERSION" && "$PR_VERSION" != "$VERSION" ]]; then
152+
echo "Closing stale PR #$PR_NUM (v$PR_VERSION < v$VERSION)"
153+
gh pr close $PR_NUM --comment "🔄 Superseded by v${VERSION}. All changelog entries included in new PR." || true
154+
fi
155+
done
156+
env:
157+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158+
159+
- name: Create branch
160+
if: steps.changelog.outputs.status != 'skip'
161+
run: |
162+
branch_name="chore/bump-obi-${{ steps.version.outputs.value }}"
163+
echo "branch_name=$branch_name" >> $GITHUB_ENV
164+
165+
git push origin --delete "$branch_name" 2>/dev/null || true
166+
167+
git config user.name "github-actions[bot]"
168+
git config user.email "github-actions[bot]@users.noreply.github.com"
169+
git checkout -b $branch_name
170+
env:
171+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
172+
173+
- name: Run bump script
174+
if: steps.changelog.outputs.status != 'skip'
175+
run: |
176+
CHANGELOG_ARGS=""
177+
if [[ -n "${{ steps.changelog.outputs.file }}" ]]; then
178+
CHANGELOG_ARGS="--changelog-file ${{ steps.changelog.outputs.file }}"
179+
fi
180+
181+
chmod +x ./scripts/bump-otel-collector-version.sh
182+
./scripts/bump-otel-collector-version.sh \
183+
--version "${{ steps.version.outputs.value }}" \
184+
--dependency-name "$DEPENDENCY_NAME" \
185+
--charts "$CHARTS" \
186+
$CHANGELOG_ARGS
187+
188+
- name: Commit and push
189+
if: steps.changelog.outputs.status != 'skip'
190+
run: |
191+
git add -A
192+
if git diff --staged --quiet; then
193+
echo "::error::No changes to commit - version ${{ steps.version.outputs.value }} may already be applied"
194+
exit 1
195+
fi
196+
git commit -m "chore: bump ${DEPENDENCY_NAME} to ${{ steps.version.outputs.value }}"
197+
git push origin $branch_name
198+
199+
- name: Build PR body
200+
if: steps.changelog.outputs.status != 'skip'
201+
run: |
202+
if [[ -f "/tmp/otel-bump-summary.md" ]]; then
203+
cat /tmp/otel-bump-summary.md > /tmp/pr-body.md
204+
else
205+
echo "Bumping ${DEPENDENCY_NAME} to \`${{ steps.version.outputs.value }}\`" > /tmp/pr-body.md
206+
fi
207+
echo "" >> /tmp/pr-body.md
208+
if [[ -n "${{ steps.version.outputs.source_pr }}" ]]; then
209+
echo "**Source:** ${{ steps.version.outputs.source_pr }}" >> /tmp/pr-body.md
210+
echo "" >> /tmp/pr-body.md
211+
fi
212+
case "${{ steps.changelog.outputs.status }}" in
213+
empty)
214+
echo "⚠️ **Changelog:** No entries found between versions - using default entry." >> /tmp/pr-body.md
215+
echo "" >> /tmp/pr-body.md
216+
;;
217+
ok)
218+
echo "✅ **Changelog:** Includes all entries from current to target version." >> /tmp/pr-body.md
219+
echo "" >> /tmp/pr-body.md
220+
;;
221+
esac
222+
223+
- name: Ensure labels exist
224+
if: steps.changelog.outputs.status != 'skip'
225+
run: |
226+
for label in obi-bump chart:otel-integration; do
227+
gh label create "$label" --description "Auto-created for OBI chart sync" --color "0E8A16" 2>/dev/null || true
228+
done
229+
env:
230+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
231+
232+
- name: Create pull request
233+
if: steps.changelog.outputs.status != 'skip'
234+
run: |
235+
gh pr create \
236+
--base master \
237+
--head "$branch_name" \
238+
--title "chore: bump ${DEPENDENCY_NAME} to ${{ steps.version.outputs.value }}" \
239+
--body-file /tmp/pr-body.md \
240+
--label "obi-bump,chart:otel-integration"
241+
env:
242+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scripts/bump-otel-collector-version.sh

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
#
33
# bump-otel-collector-version.sh
44
#
5-
# Bumps the opentelemetry-collector chart dependency across all integration charts.
5+
# Bumps a helm chart dependency across integration charts.
66
# Updates Chart.yaml, values.yaml, and CHANGELOG.md for each chart.
7+
# Defaults to the opentelemetry-collector dependency; use --dependency-name
8+
# and --charts to bump a different dependency (e.g. opentelemetry-ebpf-instrumentation).
79
#
810
# Options:
9-
# --version VERSION New opentelemetry-collector chart version (required)
11+
# --version VERSION New chart dependency version (required)
12+
# --dependency-name NAME Dependency to bump (default: opentelemetry-collector)
13+
# --charts "A B C" Space-separated charts to process (default: all collector consumers)
1014
# --changelog-file FILE File containing changelog entries to copy (optional)
1115
# --source-commit SHA Source commit SHA for reference (optional)
1216
# --source-pr NUMBER Source PR number for reference (optional)
@@ -22,6 +26,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2226
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
2327

2428
NEW_VERSION=""
29+
DEPENDENCY_NAME="opentelemetry-collector"
2530
CHANGELOG_FILE=""
2631
SOURCE_COMMIT=""
2732
SOURCE_PR=""
@@ -91,6 +96,14 @@ parse_args() {
9196
NEW_VERSION="$2"
9297
shift 2
9398
;;
99+
--dependency-name)
100+
DEPENDENCY_NAME="$2"
101+
shift 2
102+
;;
103+
--charts)
104+
ALL_CHARTS="$2"
105+
shift 2
106+
;;
94107
--changelog-file)
95108
CHANGELOG_FILE="$2"
96109
shift 2
@@ -154,7 +167,7 @@ get_current_chart_version() {
154167

155168
get_dependency_version() {
156169
local chart_yaml="$1"
157-
yq '.dependencies[] | select(.name == "opentelemetry-collector") | .version' "$chart_yaml" | head -1 | tr -d '"'
170+
yq ".dependencies[] | select(.name == \"$DEPENDENCY_NAME\") | .version" "$chart_yaml" | head -1 | tr -d '"'
158171
}
159172

160173
update_chart_yaml() {
@@ -185,7 +198,7 @@ update_chart_yaml() {
185198
fi
186199

187200
yq -i ".version = \"$new_chart_version\"" "$chart_yaml"
188-
yq -i "(.dependencies[] | select(.name == \"opentelemetry-collector\") | .version) = \"$NEW_VERSION\"" "$chart_yaml"
201+
yq -i "(.dependencies[] | select(.name == \"$DEPENDENCY_NAME\") | .version) = \"$NEW_VERSION\"" "$chart_yaml"
189202

190203
echo "$new_chart_version"
191204
}
@@ -244,9 +257,9 @@ update_changelog() {
244257
entry_file=$(mktemp)
245258

246259
local header_version="v${new_chart_version}"
247-
local change_line="- [Chore] Bump chart dependency to opentelemetry-collector ${NEW_VERSION}"
260+
local change_line="- [Chore] Bump chart dependency to ${DEPENDENCY_NAME} ${NEW_VERSION}"
248261

249-
if [[ "$chart" == "otel-ecs-ec2" ]]; then
262+
if [[ "$chart" == "otel-ecs-ec2" && "$DEPENDENCY_NAME" == "opentelemetry-collector" ]]; then
250263
change_line="- [Change] Update Helm dependency \`opentelemetry-agent\` to chart version \`${NEW_VERSION}\`."
251264
fi
252265

@@ -421,7 +434,7 @@ generate_summary() {
421434
log_info "Summary"
422435
log_info "=========================================="
423436
echo "" >&2
424-
echo "New opentelemetry-collector version: $NEW_VERSION" >&2
437+
echo "New $DEPENDENCY_NAME version: $NEW_VERSION" >&2
425438
echo "" >&2
426439
echo "Charts:" >&2
427440

@@ -493,7 +506,7 @@ generate_markdown_summary() {
493506
local has_failures=false
494507

495508
{
496-
echo "## OpenTelemetry Collector Bump Summary"
509+
echo "## ${DEPENDENCY_NAME} Bump Summary"
497510
echo ""
498511
echo "**Version:** \`$NEW_VERSION\`"
499512

@@ -597,7 +610,7 @@ main() {
597610
exit 1
598611
}
599612

600-
log_info "Bumping opentelemetry-collector to version $NEW_VERSION"
613+
log_info "Bumping $DEPENDENCY_NAME to version $NEW_VERSION"
601614
if [[ "$DRY_RUN" == "true" ]]; then
602615
log_warn "DRY RUN mode enabled"
603616
fi

0 commit comments

Comments
 (0)