Skip to content

update project version #21

update project version

update project version #21

name: "update project version"
on:
workflow_dispatch:
inputs:
target_version:
description: 'next version (e.g., 1.9.7 or 1.9.7.12)'
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: Only update version inside the project() block
if [ -f CMakeLists.txt ]; then
echo "updating cmakelists.txt"
sed -i "/project[[:space:]]*([[:space:]]*jsoncpp/,/)/ s/VERSION [0-9.]*/VERSION $VER/" CMakeLists.txt
if [ -n "$SOVER" ]; then
sed -i "s/set(PROJECT_SOVERSION [0-9]*/set(PROJECT_SOVERSION $SOVER/" CMakeLists.txt
fi
fi
# 2. meson.build: Only update version inside the project() block
if [ -f meson.build ]; then
echo "updating meson.build"
sed -i "/project('jsoncpp'/,/)/ s/version[[:space:]]*:[[:space:]]*['\"][0-9.]*['\"]/version : '$VER'/" meson.build
if [ -n "$SOVER" ]; then
# update soversion only within the library() or where defined
sed -i "s/soversion[[:space:]]*:[[:space:]]*['\"][0-9]*['\"]/soversion : '$SOVER'/" meson.build
fi
fi
# 3. MODULE.bazel: Only update version inside the module() block
if [ -f MODULE.bazel ]; then
echo "updating MODULE.bazel"
# match range from 'module(' to the first ')'
sed -i "/module(/,/)/ s/version[[:space:]]*=[[:space:]]*['\"][0-9.]*['\"]/version = \"$VER\"/" MODULE.bazel
fi
# 4. vcpkg.json: jq is inherently surgical
if [ -f vcpkg.json ]; then
echo "updating vcpkg.json"
jq ".version = \"$VER\"" vcpkg.json > vcpkg.json.tmp && mv vcpkg.json.