Skip to content

Commit 728ad03

Browse files
authored
Clarify version update comments in workflow script
Updated comments in the version bumping script to clarify that only the version inside the project() or module() blocks is updated for CMakeLists.txt, meson.build, and MODULE.bazel. Removed unnecessary version updates for include/json/version.h and related sanity checks.
1 parent c4a1e4c commit 728ad03

1 file changed

Lines changed: 9 additions & 50 deletions

File tree

.github/workflows/update-project-version.yml

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
SOVER="${{ github.event.inputs.target_soversion }}"
2929
echo "bumping version to $VER"
3030
31-
# 1. CMakeLists.txt
31+
# 1. CMakeLists.txt: Only update version inside the project() block
3232
if [ -f CMakeLists.txt ]; then
3333
echo "updating cmakelists.txt"
3434
sed -i "/project[[:space:]]*([[:space:]]*jsoncpp/,/)/ s/VERSION [0-9.]*/VERSION $VER/" CMakeLists.txt
@@ -37,65 +37,24 @@ jobs:
3737
fi
3838
fi
3939
40-
# 2. meson.build
40+
# 2. meson.build: Only update version inside the project() block
4141
if [ -f meson.build ]; then
4242
echo "updating meson.build"
43-
sed -i "s/version[[:space:]]*:[[:space:]]*['\"][0-9.]*['\"]/version : '$VER'/" meson.build
43+
sed -i "/project('jsoncpp'/,/)/ s/version[[:space:]]*:[[:space:]]*['\"][0-9.]*['\"]/version : '$VER'/" meson.build
4444
if [ -n "$SOVER" ]; then
45+
# update soversion only within the library() or where defined
4546
sed -i "s/soversion[[:space:]]*:[[:space:]]*['\"][0-9]*['\"]/soversion : '$SOVER'/" meson.build
4647
fi
4748
fi
4849
49-
# 3. MODULE.bazel
50+
# 3. MODULE.bazel: Only update version inside the module() block
5051
if [ -f MODULE.bazel ]; then
5152
echo "updating MODULE.bazel"
52-
# matches: version = "1.9.6"
53-
sed -i "s/version[[:space:]]*=[[:space:]]*['\"][0-9.]*['\"]/version = \"$VER\"/" MODULE.bazel
53+
# match range from 'module(' to the first ')'
54+
sed -i "/module(/,/)/ s/version[[:space:]]*=[[:space:]]*['\"][0-9.]*['\"]/version = \"$VER\"/" MODULE.bazel
5455
fi
5556
56-
# 4. vcpkg.json
57+
# 4. vcpkg.json: jq is inherently surgical
5758
if [ -f vcpkg.json ]; then
5859
echo "updating vcpkg.json"
59-
jq ".version = \"$VER\"" vcpkg.json > vcpkg.json.tmp && mv vcpkg.json.tmp vcpkg.json
60-
fi
61-
62-
# 5. include/json/version.h
63-
if [ -f include/json/version.h ]; then
64-
echo "updating version.h"
65-
IFS='.' read -r MAJOR MINOR PATCH QUALIFIER <<< "$VER"
66-
67-
sed -i "s|#define JSONCPP_VERSION_STRING \"[^\"]*\"|#define JSONCPP_VERSION_STRING \"$VER\"|" include/json/version.h
68-
sed -i "s|#define JSONCPP_VERSION_MAJOR [0-9]*|#define JSONCPP_VERSION_MAJOR $MAJOR|" include/json/version.h
69-
sed -i "s|#define JSONCPP_VERSION_MINOR [0-9]*|#define JSONCPP_VERSION_MINOR $MINOR|" include/json/version.h
70-
sed -i "s|#define JSONCPP_VERSION_PATCH [0-9]*|#define JSONCPP_VERSION_PATCH $PATCH|" include/json/version.h
71-
72-
# set qualifier to the number if 4th part exists, otherwise leave blank
73-
if [ -n "$QUALIFIER" ]; then
74-
sed -i "s|#define JSONCPP_VERSION_QUALIFIER.*|#define JSONCPP_VERSION_QUALIFIER $QUALIFIER|" include/json/version.h
75-
else
76-
sed -i "s|#define JSONCPP_VERSION_QUALIFIER.*|#define JSONCPP_VERSION_QUALIFIER|" include/json/version.h
77-
fi
78-
fi
79-
80-
- name: sanity check (cmake configure)
81-
run: |
82-
if [ -f CMakeLists.txt ]; then
83-
mkdir build_check
84-
cd build_check
85-
cmake .. -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF
86-
cd ..
87-
rm -rf build_check
88-
fi
89-
90-
- name: create pull request
91-
uses: peter-evans/create-pull-request@v7
92-
with:
93-
token: ${{ secrets.GITHUB_TOKEN }}
94-
commit-message: "chore: bump version to ${{ github.event.inputs.target_version }}"
95-
branch: "bump-to-${{ github.event.inputs.target_version }}"
96-
title: "chore: bump version to ${{ github.event.inputs.target_version }}"
97-
body: |
98-
automated version bump.
99-
- new version: `${{ github.event.inputs.target_version }}`
100-
- new soversion: `${{ github.event.inputs.target_soversion || 'no change' }}`
101-
labels: "maintenance"
60+
jq ".version = \"$VER\"" vcpkg.json > vcpkg.json.tmp && mv vcpkg.json.

0 commit comments

Comments
 (0)