Skip to content

Commit 01bdb87

Browse files
authored
Switch to Tommy's bump fork script (#3100)
1 parent cd16b12 commit 01bdb87

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

bump-fork.sh

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1-
#!/bin/sh
2-
go mod edit -replace go.opentelemetry.io/ebpf-profiler=github.com/parca-dev/opentelemetry-ebpf-profiler@latest
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Configuration
6+
REPO="parca-dev/opentelemetry-ebpf-profiler"
7+
BRANCH="main"
8+
9+
echo "Fetching latest SHA from ${REPO} on branch ${BRANCH}..."
10+
11+
# Get the latest commit SHA from GitHub API
12+
LATEST_SHA=$(curl -s "https://api.github.com/repos/${REPO}/commits/${BRANCH}" | grep '"sha"' | head -1 | cut -d'"' -f4)
13+
14+
if [ -z "$LATEST_SHA" ]; then
15+
echo "Error: Failed to fetch latest SHA from GitHub API"
16+
exit 1
17+
fi
18+
19+
# Truncate SHA to first 12 characters (Go convention for pseudo-versions)
20+
SHORT_SHA="${LATEST_SHA:0:12}"
21+
22+
echo "Latest SHA: ${LATEST_SHA}"
23+
echo "Short SHA: ${SHORT_SHA}"
24+
25+
# Get commit timestamp from GitHub API for pseudo-version
26+
COMMIT_DATE=$(curl -s "https://api.github.com/repos/${REPO}/commits/${LATEST_SHA}" | python3 -c "import sys, json; data = json.load(sys.stdin); print(data['commit']['committer']['date'])")
27+
TIMESTAMP=$(date -d "${COMMIT_DATE}" -u +%Y%m%d%H%M%S)
28+
29+
# Construct the new replace directive
30+
NEW_REPLACE="replace go.opentelemetry.io/ebpf-profiler => github.com/${REPO} v0.0.0-${TIMESTAMP}-${SHORT_SHA}"
31+
32+
echo "New replace directive: ${NEW_REPLACE}"
33+
34+
# Check if go.mod exists
35+
if [ ! -f "go.mod" ]; then
36+
echo "Error: go.mod not found in current directory"
37+
exit 1
38+
fi
39+
40+
# Update the replace directive in go.mod
41+
sed -i "s|^replace go.opentelemetry.io/ebpf-profiler.*|${NEW_REPLACE}|" go.mod
42+
43+
echo "Updated go.mod with new replace directive"
44+
45+
# Run go mod tidy to fetch the module and update go.sum
46+
echo "Running go mod tidy..."
347
go mod tidy
48+
49+
echo "Successfully updated OpenTelemetry eBPF profiler to latest SHA: ${SHORT_SHA}"
50+
echo "Full commit: ${LATEST_SHA}"

0 commit comments

Comments
 (0)