@@ -7,22 +7,49 @@ if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then
77 exit 1
88fi
99
10+ # Check that GITHUB_TOKEN is set
11+ if [ -z " $GITHUB_TOKEN " ]; then
12+ echo " GITHUB_TOKEN is not set. Trying to fetch it from gh"
13+ GITHUB_TOKEN=$( gh auth token)
14+ fi
15+
1016# First and only argument is the version number
1117VERSION=v$1 # The version number, prefixed with 'v'
18+ VERSION_NO_V=${1} # The version number without the 'v' prefix
19+
20+ # List of files and line numbers to update with version numbers
21+ # Format: "file:line_number"
22+ VERSION_FILES=(
23+ " core/CMakeLists.txt:3"
24+ " core/MODULE.bazel:3"
25+ " google_benchmark/MODULE.bazel:3"
26+ " google_benchmark/MODULE.bazel:6"
27+ )
28+
29+ # Get current version from core/CMakeLists.txt
30+ PREVIOUS_VERSION=$( grep " set(CODSPEED_VERSION" core/CMakeLists.txt | grep -oP ' \d+\.\d+\.\d+' )
31+
1232# Prompt the release version
33+ echo " Previous version: ${PREVIOUS_VERSION} "
1334echo " Release version: $VERSION "
1435read -p " Are you sure you want to release this version? (y/n): " confirm
1536if [ " $confirm " != " y" ]; then
1637 echo " Aborting release"
1738 exit 1
1839fi
1940
20- # Check that GITHUB_TOKEN is set
21- if [ -z " $GITHUB_TOKEN " ]; then
22- echo " GITHUB_TOKEN is not set. Trying to fetch it from gh"
23- GITHUB_TOKEN=$( gh auth token)
41+ # Update version in all relevant files
42+ echo " Updating version numbers in source files..."
2443
25- fi
44+ for entry in " ${VERSION_FILES[@]} " ; do
45+ IFS=' :' read -r file line_num <<< " $entry"
46+ sed -i " ${line_num} s/${PREVIOUS_VERSION} /${VERSION_NO_V} /" " $file "
47+ echo " Updated $file :$line_num "
48+ done
49+
50+ # Commit version changes
51+ FILES_TO_COMMIT=$( printf " %s\n" " ${VERSION_FILES[@]%%:* } " | sort -u | xargs)
52+ git add $FILES_TO_COMMIT
2653
2754git cliff -o CHANGELOG.md --tag $VERSION --github-token $GITHUB_TOKEN
2855git add CHANGELOG.md
0 commit comments