@@ -22,13 +22,12 @@ jobs:
2222 uses : actions/checkout@v4
2323
2424 - name : update project files
25- id : update_files
2625 run : |
2726 VER="${{ github.event.inputs.target_version }}"
2827 SOVER="${{ github.event.inputs.target_soversion }}"
2928 echo "bumping version to $VER"
3029
31- # 1. CMakeLists .txt: surgical update inside project()
30+ # 1. cmakelists .txt
3231 if [ -f CMakeLists.txt ]; then
3332 echo "updating cmakelists.txt"
3433 sed -i "/project[[:space:]]*([[:space:]]*jsoncpp/,/)/ s/VERSION [0-9.]*/VERSION $VER/" CMakeLists.txt
@@ -37,27 +36,66 @@ jobs:
3736 fi
3837 fi
3938
40- # 2. meson.build: surgical update inside project()
39+ # 2. meson.build
4140 if [ -f meson.build ]; then
4241 echo "updating meson.build"
4342 sed -i "/project('jsoncpp'/,/)/ s/version[[:space:]]*:[[:space:]]*['\"][0-9.]*['\"]/version : '$VER'/" meson.build
4443 if [ -n "$SOVER" ]; then
45- # matches soversion : '26'
4644 sed -i "s/soversion[[:space:]]*:[[:space:]]*['\"][0-9]*['\"]/soversion : '$SOVER'/" meson.build
4745 fi
4846 fi
4947
50- # 3. MODULE .bazel: surgical update inside module() only
48+ # 3. module .bazel
5149 if [ -f MODULE.bazel ]; then
52- echo "updating MODULE .bazel"
50+ echo "updating module .bazel"
5351 sed -i "/module(/,/)/ s/version[[:space:]]*=[[:space:]]*['\"][0-9.]*['\"]/version = \"$VER\"/" MODULE.bazel
5452 fi
5553
5654 # 4. vcpkg.json
5755 if [ -f vcpkg.json ]; then
5856 echo "updating vcpkg.json"
59- jq " .version = \"$VER\"" vcpkg.json > vcpkg.json.tmp && mv vcpkg.json.tmp vcpkg.json
57+ jq --arg ver "$VER" ' .version = $ver' vcpkg.json > vcpkg.json.tmp && mv vcpkg.json.tmp vcpkg.json
6058 fi
6159
62- # 5. include/json/version.h: split 4-part version safely
60+ # 5. include/json/version.h
6361 if [ -f include/json/version.h ]; then
62+ echo "updating version.h"
63+ MAJOR=$(echo "$VER" | cut -d. -f1)
64+ MINOR=$(echo "$VER" | cut -d. -f2)
65+ PATCH=$(echo "$VER" | cut -d. -f3)
66+ QUALIFIER=$(echo "$VER" | cut -d. -f4 -s)
67+
68+ sed -i "s/#define JSONCPP_VERSION_STRING \".*\"/#define JSONCPP_VERSION_STRING \"$VER\"/" include/json/version.h
69+ sed -i "s/#define JSONCPP_VERSION_MAJOR [0-9]*/#define JSONCPP_VERSION_MAJOR $MAJOR/" include/json/version.h
70+ sed -i "s/#define JSONCPP_VERSION_MINOR [0-9]*/#define JSONCPP_VERSION_MINOR $MINOR/" include/json/version.h
71+ sed -i "s/#define JSONCPP_VERSION_PATCH [0-9]*/#define JSONCPP_VERSION_PATCH $PATCH/" include/json/version.h
72+
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"
0 commit comments