Skip to content

update project version #2

update project version

update project version #2

name: "update project version"
on:
workflow_dispatch:
inputs:
target_version:
description: 'next version (e.g., 1.9.7)'
required: true
default: '1.9.7'
target_soversion:
description: 'next SOVERSION (e.g., 28) - leave blank to keep current.'
required: false
jobs:
bump-and-verify:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: checkout code
uses: actions/checkout@v4
- name: update project files
id: update_files
run: |
VER="${{ github.event.inputs.target_version }}"
SOVER="${{ github.event.inputs.target_soversion }}"
echo "Bumping version to $VER"
# 1. CMakeLists.txt: Match only the project declaration
# This prevents touching comments, policies, or SOVERSION
sed -i "s/project(jsoncpp VERSION [0-9.]*/project(jsoncpp VERSION $VER/" CMakeLists.txt
# Only update SOVERSION if provided
if [ -n "$SOVER" ]; then
echo "Bumping SOVERSION to $SOVER"
sed -i "s/set(PROJECT_SOVERSION [0-9]*/set(PROJECT_SOVERSION $SOVER/" CMakeLists.txt
fi
# 2. meson.build: Match the project line specifically
sed -i "s/project('jsoncpp', 'cpp', version : '[0-9.]*'/project('jsoncpp', 'cpp', version : '$VER'/" meson.build
# 3. vcpkg.json: Using jq for syntax safety
jq ".version = \"$VER\"" vcpkg.json > vcpkg.json.tmp && mv vcpkg.json.tmp vcpkg.json
# 4. include/json/version.h: Match specific #define macros
IFS='.' read -r MAJOR MINOR PATCH <<< "$VER"
sed -i "s/#define JSONCPP_VERSION_STRING \"[^\"]*\"/#define JSONCPP_VERSION_STRING \"$VER\"/" include/json/version.h
sed -i "s/#define JSONCPP_VERSION_MAJOR [0-9]*/