blob: b60c7b96723afb9802c18ca27cf9f494d8c7905a [file]
name: "Bump Project Version"
on:
workflow_dispatch:
inputs:
version_base:
description: 'Target Version (e.g., 1.9.7)'
required: true
default: '1.9.7'
jobs:
bump-version:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Construct Version String
id: get_ver
run: |
BASE="${{ github.event.inputs.version_base }}"
RUN_NUM="${{ github.run_number }}"
FULL_VER="$BASE.$RUN_NUM"
echo "full_version=$FULL_VER" >> $GITHUB_OUTPUT
echo "base_version=$BASE" >> $GITHUB_OUTPUT
- name: Update Project Files
run: |
VER="${{ steps.get_ver.outputs.full_version }}"
echo "Bumping all files to $VER"
# 1. CMakeLists.txt (Matches 'VERSION X.Y.Z.W' or 'X.Y.Z')
sed -i "s/VERSION [0-9.]*/VERSION $VER/" CMakeLists.txt
# 2. meson.build
sed -i "s/version : '[0-9.]*'/version : '$VER'/" meson.build
# 3. vcpkg.json
jq ".version = \"$VER\"" vcpkg.json > vcpkg.json.tmp && mv vcpkg.json.tmp vcpkg.json
# 4. include/json/version.h
# We parse the base version for the numeric macros (MAJOR.MINOR.PATCH)
# while the 4-part string goes into JSONCPP_VERSION_STRING.
IFS='.' read -r MAJOR MINOR PATCH <<< "${{ steps.get_ver.outputs.base_version }}"
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]*/# define JSONCPP_VERSION_MAJOR $MAJOR/" include/json/version.h
sed -i "s/# define JSONCPP_VERSION_MINOR [0-9]*/# define JSONCPP_VERSION_MINOR $MINOR/" include/json/version.h
sed -i "s/# define JSONCPP_VERSION_PATCH [0-9]*/# define JSONCPP_VERSION_PATCH $PATCH/" include/json/version.h
- name: Commit and Push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "chore: bump version to ${{ steps.get_ver.outputs.full_version }} (Run #${{ github.run_number }})"
git push