|
4 | 4 | workflow_dispatch: |
5 | 5 | inputs: |
6 | 6 | target_version: |
7 | | - description: 'Next Version (e.g., 1.9.7)' |
| 7 | + description: 'next version (e.g., 1.9.7 or 1.9.7.12)' |
8 | 8 | required: true |
9 | 9 | default: '1.9.7' |
| 10 | + target_soversion: |
| 11 | + description: 'next soversion (e.g., 28). leave blank to keep current.' |
| 12 | + required: false |
10 | 13 |
|
11 | 14 | jobs: |
12 | | - create-bump-pr: |
| 15 | + bump-and-verify: |
13 | 16 | runs-on: ubuntu-latest |
14 | 17 | permissions: |
15 | 18 | contents: write |
16 | 19 | pull-requests: write |
17 | 20 | steps: |
18 | | - - name: Checkout code |
| 21 | + - name: checkout code |
19 | 22 | uses: actions/checkout@v4 |
20 | 23 |
|
21 | | - - name: Update Project Files |
| 24 | + - name: update project files |
22 | 25 | id: update_files |
23 | 26 | run: | |
24 | 27 | VER="${{ github.event.inputs.target_version }}" |
25 | | - echo "Updating files to $VER" |
| 28 | + SOVER="${{ github.event.inputs.target_soversion }}" |
| 29 | + echo "bumping version to $VER" |
26 | 30 |
|
27 | 31 | # 1. CMakeLists.txt |
28 | | - sed -i "s/VERSION [0-9.]*/VERSION $VER/" CMakeLists.txt |
| 32 | + if [ -f CMakeLists.txt ]; then |
| 33 | + echo "updating cmakelists.txt" |
| 34 | + # match VERSION only within the project block |
| 35 | + sed -i "/project[[:space:]]*([[:space:]]*jsoncpp/,/)/ s/VERSION [0-9.]*/VERSION $VER/" CMakeLists.txt |
| 36 | + if [ -n "$SOVER" ]; then |
| 37 | + sed -i "s/set(PROJECT_SOVERSION [0-9]*/set(PROJECT_SOVERSION $SOVER/" CMakeLists.txt |
| 38 | + fi |
| 39 | + fi |
29 | 40 |
|
30 | 41 | # 2. meson.build |
31 | | - sed -i "s/version : '[0-9.]*'/version : '$VER'/" meson.build |
| 42 | + if [ -f meson.build ]; then |
| 43 | + echo "updating meson.build" |
| 44 | + # match version : 'x.y.z' with flexible quotes and spacing |
| 45 | + sed -i "s/version[[:space:]]*:[[:space:]]*['\"][0-9.]*['\"]/version : '$VER'/" meson.build |
| 46 | + if [ -n "$SOVER" ]; then |
| 47 | + # matches soversion : '26' |
| 48 | + sed -i "s/soversion[[:space:]]*:[[:space:]]*['\"][0-9]*['\"]/soversion : '$SOVER'/" meson.build |
| 49 | + fi |
| 50 | + fi |
32 | 51 |
|
33 | | - # 3. vcpkg.json (Using jq for safety) |
34 | | - jq ".version = \"$VER\"" vcpkg.json > vcpkg.json.tmp && mv vcpkg.json.tmp vcpkg.json |
| 52 | + # 3. vcpkg.json |
| 53 | + if [ -f vcpkg.json ]; then |
| 54 | + echo "updating vcpkg.json" |
| 55 | + jq ".version = \"$VER\"" vcpkg.json > vcpkg.json.tmp && mv vcpkg.json.tmp vcpkg.json |
| 56 | + fi |
35 | 57 |
|
36 | 58 | # 4. include/json/version.h |
37 | | - # Parse X.Y.Z into separate variables |
38 | | - IFS='.' read -r MAJOR MINOR PATCH <<< "$VER" |
39 | | - sed -i "s/# define JSONCPP_VERSION_STRING \"[^\"]*\"/# define JSONCPP_VERSION_STRING \"$VER\"/" include/json/version.h |
40 | | - sed -i "s/# define JSONCPP_VERSION_MAJOR [0-9]*/# define JSONCPP_VERSION_MAJOR $MAJOR/" include/json/version.h |
41 | | - sed -i "s/# define JSONCPP_VERSION_MINOR [0-9]*/# define JSONCPP_VERSION_MINOR $MINOR/" include/json/version.h |
42 | | - sed -i "s/# define JSONCPP_VERSION_PATCH [0-9]*/# define JSONCPP_VERSION_PATCH $PATCH/" include/json/version.h |
43 | | -
|
44 | | - - name: Create Pull Request |
| 59 | + if [ -f include/json/version.h ]; then |
| 60 | + echo "updating version.h" |
| 61 | + # 1.9.7.12 -> MAJOR=1, MINOR=9, PATCH=7, QUALIFIER=12 |
| 62 | + IFS='.' read -r MAJOR MINOR PATCH QUALIFIER <<< "$VER" |
| 63 | + |
| 64 | + sed -i "s|#define JSONCPP_VERSION_STRING \"[^\"]*\"|#define JSONCPP_VERSION_STRING \"$VER\"|" include/json/version.h |
| 65 | + sed -i "s|#define JSONCPP_VERSION_MAJOR [0-9]*|#define JSONCPP_VERSION_MAJOR $MAJOR|" include/json/version.h |
| 66 | + sed -i "s|#define JSONCPP_VERSION_MINOR [0-9]*|#define JSONCPP_VERSION_MINOR $MINOR|" include/json/version.h |
| 67 | + sed -i "s|#define JSONCPP_VERSION_PATCH [0-9]*|#define JSONCPP_VERSION_PATCH $PATCH|" include/json/version.h |
| 68 | + |
| 69 | + if [ -n "$QUALIFIER" ]; then |
| 70 | + sed -i "s|#define JSONCPP_VERSION_QUALIFIER.*|#define JSONCPP_VERSION_QUALIFIER $QUALIFIER|" include/json/version.h |
| 71 | + else |
| 72 | + sed -i "s|#define JSONCPP_VERSION_QUALIFIER.*|#define JSONCPP_VERSION_QUALIFIER|" include/json/version.h |
| 73 | + fi |
| 74 | + fi |
| 75 | +
|
| 76 | + - name: sanity check (cmake configure) |
| 77 | + run: | |
| 78 | + if [ -f CMakeLists.txt ]; then |
| 79 | + mkdir build_check |
| 80 | + cd build_check |
| 81 | + cmake .. -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF |
| 82 | + cd .. |
| 83 | + rm -rf build_check |
| 84 | + fi |
| 85 | +
|
| 86 | + - name: create pull request |
45 | 87 | uses: peter-evans/create-pull-request@v7 |
46 | 88 | with: |
47 | 89 | token: ${{ secrets.GITHUB_TOKEN }} |
48 | 90 | commit-message: "chore: bump version to ${{ github.event.inputs.target_version }}" |
49 | 91 | branch: "bump-to-${{ github.event.inputs.target_version }}" |
50 | 92 | title: "chore: bump version to ${{ github.event.inputs.target_version }}" |
51 | 93 | body: | |
52 | | - Manual version bump to `${{ github.event.inputs.target_version }}` to start the next development cycle. |
53 | | - |
54 | | - **Files updated:** |
55 | | - - `CMakeLists.txt` |
56 | | - - `meson.build` |
57 | | - - `vcpkg.json` |
58 | | - - `include/json/version.h` |
| 94 | + automated version bump. |
| 95 | + - new version: `${{ github.event.inputs.target_version }}` |
| 96 | + - new soversion: `${{ github.event.inputs.target_soversion || 'no change' }}` |
59 | 97 | labels: "maintenance" |
0 commit comments