44 workflow_dispatch :
55 inputs :
66 target_version :
7- description : ' Next Version (e.g., 1.9.7 or 1.9.7.123)'
7+ description : ' next version (e.g., 1.9.7 or 1.9.7.123)'
88 required : true
99 default : ' 1.9.7'
1010 target_soversion :
11- description : ' Next SOVERSION (e.g., 28). Leave blank to keep current.'
11+ description : ' next soversion (e.g., 28). leave blank to keep current.'
1212 required : false
1313
1414jobs :
@@ -28,19 +28,25 @@ jobs:
2828 SOVER="${{ github.event.inputs.target_soversion }}"
2929 echo "bumping version to $VER"
3030
31- # 1. CMakeLists.txt
31+ # 1. CMakeLists.txt (handles multi-line project() call)
3232 if [ -f CMakeLists.txt ]; then
3333 echo "updating cmakelists.txt"
34- sed -i "s/project(jsoncpp VERSION [0-9.]*/project(jsoncpp VERSION $VER/" CMakeLists.txt
34+ # match VERSION only if it follows 'project(jsoncpp'
35+ sed -i "/project(jsoncpp/,/)/ s/VERSION [0-9.]*/VERSION $VER/" CMakeLists.txt
3536 if [ -n "$SOVER" ]; then
3637 sed -i "s/set(PROJECT_SOVERSION [0-9]*/set(PROJECT_SOVERSION $SOVER/" CMakeLists.txt
3738 fi
3839 fi
3940
40- # 2. meson.build
41+ # 2. meson.build (handles multi-line project() and lowercase soversion)
4142 if [ -f meson.build ]; then
4243 echo "updating meson.build"
43- sed -i "s/project('jsoncpp', 'cpp', version : '[0-9.]*'/project('jsoncpp', 'cpp', version : '$VER'/" meson.build
44+ # update version in project()
45+ sed -i "/project('jsoncpp'/,/)/ s/version : '[0-9.]*'/version : '$VER'/" meson.build
46+ if [ -n "$SOVER" ]; then
47+ # update soversion in library()
48+ sed -i "s/soversion : [0-9]*/soversion : $SOVER/" meson.build
49+ fi
4450 fi
4551
4652 # 3. vcpkg.json
@@ -52,15 +58,16 @@ jobs:
5258 # 4. include/json/version.h
5359 if [ -f include/json/version.h ]; then
5460 echo "updating version.h"
55- # Split version into components (handles 3 or 4 parts)
61+ # split version into components (e.g., 1.9.7.123 -> MAJOR=1, MINOR=9, PATCH=7, QUALIFIER=123)
62+ # if 1.9.7 -> QUALIFIER is empty
5663 IFS='.' read -r MAJOR MINOR PATCH QUALIFIER <<< "$VER"
5764
5865 sed -i "s|#define JSONCPP_VERSION_STRING \"[^\"]*\"|#define JSONCPP_VERSION_STRING \"$VER\"|" include/json/version.h
5966 sed -i "s|#define JSONCPP_VERSION_MAJOR [0-9]*|#define JSONCPP_VERSION_MAJOR $MAJOR|" include/json/version.h
6067 sed -i "s|#define JSONCPP_VERSION_MINOR [0-9]*|#define JSONCPP_VERSION_MINOR $MINOR|" include/json/version.h
6168 sed -i "s|#define JSONCPP_VERSION_PATCH [0-9]*|#define JSONCPP_VERSION_PATCH $PATCH|" include/json/version.h
6269
63- # If QUALIFIER exists, append it; otherwise, leave macro empty
70+ # handle qualifier macro
6471 if [ -n "$QUALIFIER" ]; then
6572 sed -i "s|#define JSONCPP_VERSION_QUALIFIER.*|#define JSONCPP_VERSION_QUALIFIER $QUALIFIER|" include/json/version.h
6673 else
7582 cd build_check
7683 cmake .. -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF
7784 cd ..
78- # CRITICAL: Remove the build folder so it isn't included in the PR
7985 rm -rf build_check
8086 fi
8187
0 commit comments