|
| 1 | +name: "update project version" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + target_version: |
| 7 | + description: 'Next Version (e.g., 1.9.7)' |
| 8 | + required: true |
| 9 | + default: '1.9.7' |
| 10 | + |
| 11 | +jobs: |
| 12 | + create-bump-pr: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: write |
| 16 | + pull-requests: write |
| 17 | + steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Update Project Files |
| 22 | + id: update_files |
| 23 | + run: | |
| 24 | + 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) |
| 34 | + jq ".version = \"$VER\"" vcpkg.json > vcpkg.json.tmp && mv vcpkg.json.tmp vcpkg.json |
| 35 | +
|
| 36 | + # 4. include/json/version.h |
| 37 | + # Parse X.Y.Z into separate variables |
| 38 | + 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" |
0 commit comments