update project version #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "update project version" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| target_version: | |
| description: 'Next Version (e.g., 1.9.7)' | |
| required: true | |
| default: '1.9.7' | |
| jobs: | |
| create-bump-pr: | |
| 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 }}" | |
| echo "Updating files to $VER" | |
| # 1. CMakeLists.txt | |
| 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 (Using jq for safety) | |
| jq ".version = \"$VER\"" vcpkg.json > vcpkg.json.tmp && mv vcpkg.json.tmp vcpkg.json | |
| # 4. include/json/version.h | |
| # Parse X.Y.Z into separate variables | |
| 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]*/# 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: Create Pull Request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "chore: bump version to ${{ github.event.inputs.target_version }}" | |
| branch: "bump-to-${{ github.event.inputs.target_version }}" | |
| title: "chore: bump version to ${{ github.event.inputs.target_version }}" | |
| body: | | |
| Manual version bump to `${{ github.event.inputs.target_version }}` to start the next development cycle. | |
| **Files updated:** | |
| - `CMakeLists.txt` | |
| - `meson.build` | |
| - `vcpkg.json` | |
| - `include/json/version.h` | |
| labels: "maintenance" |