Skip to content

Commit fb3e750

Browse files
authored
Refactor version bump workflow for clarity and functionality
Updated the workflow name and added target_soversion input. Modified version update commands for CMakeLists.txt, meson.build, and include/json/version.h.
1 parent 3b8f743 commit fb3e750

1 file changed

Lines changed: 25 additions & 34 deletions

File tree

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "update project version"
1+
name: "Manual Version Bump"
22

33
on:
44
workflow_dispatch:
@@ -7,9 +7,12 @@ on:
77
description: 'Next Version (e.g., 1.9.7)'
88
required: true
99
default: '1.9.7'
10+
target_soversion:
11+
description: 'Next SOVERSION (e.g., 28). Leave blank to keep current.'
12+
required: false
1013

1114
jobs:
12-
create-bump-pr:
15+
bump-and-verify:
1316
runs-on: ubuntu-latest
1417
permissions:
1518
contents: write
@@ -22,38 +25,26 @@ jobs:
2225
id: update_files
2326
run: |
2427
VER="${{ github.event.inputs.target_version }}"
25-
echo "Updating files to $VER"
26-
27-
# 1. CMakeLists.txt
28-
sed -i "s/VERSION [0-9.]*/VERSION $VER/" CMakeLists.txt
29-
30-
# 2. meson.build
31-
sed -i "s/version : '[0-9.]*'/version : '$VER'/" meson.build
32-
33-
# 3. vcpkg.json (Using jq for safety)
28+
SOVER="${{ github.event.inputs.target_soversion }}"
29+
echo "Bumping version to $VER"
30+
31+
# 1. CMakeLists.txt: Match only the project declaration
32+
# This prevents touching comments, policies, or SOVERSION
33+
sed -i "s/project(jsoncpp VERSION [0-9.]*/project(jsoncpp VERSION $VER/" CMakeLists.txt
34+
35+
# Only update SOVERSION if provided
36+
if [ -n "$SOVER" ]; then
37+
echo "Bumping SOVERSION to $SOVER"
38+
sed -i "s/set(PROJECT_SOVERSION [0-9]*/set(PROJECT_SOVERSION $SOVER/" CMakeLists.txt
39+
fi
40+
41+
# 2. meson.build: Match the project line specifically
42+
sed -i "s/project('jsoncpp', 'cpp', version : '[0-9.]*'/project('jsoncpp', 'cpp', version : '$VER'/" meson.build
43+
44+
# 3. vcpkg.json: Using jq for syntax safety
3445
jq ".version = \"$VER\"" vcpkg.json > vcpkg.json.tmp && mv vcpkg.json.tmp vcpkg.json
3546
36-
# 4. include/json/version.h
37-
# Parse X.Y.Z into separate variables
47+
# 4. include/json/version.h: Match specific #define macros
3848
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
45-
uses: peter-evans/create-pull-request@v7
46-
with:
47-
token: ${{ secrets.GITHUB_TOKEN }}
48-
commit-message: "chore: bump version to ${{ github.event.inputs.target_version }}"
49-
branch: "bump-to-${{ github.event.inputs.target_version }}"
50-
title: "chore: bump version to ${{ github.event.inputs.target_version }}"
51-
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`
59-
labels: "maintenance"
49+
sed -i "s/#define JSONCPP_VERSION_STRING \"[^\"]*\"/#define JSONCPP_VERSION_STRING \"$VER\"/" include/json/version.h
50+
sed -i "s/#define JSONCPP_VERSION_MAJOR [0-9]*/

0 commit comments

Comments
 (0)