Skip to content

Commit 51a3241

Browse files
authored
Automate maintenance branch creation [DI-669] (#1372)
- creates `z` branch if major/minor release, based on release branch with updated (dynamically calculated) version - creates milestone Testing (in my fork): - [example execution](https://github.com/JackPGreen/hazelcast-cpp-client/actions/runs/19483707385) - [branch created](https://github.com/JackPGreen/hazelcast-cpp-client/tree/5.6.z) - [version update PR raised](JackPGreen#15) - [milestone created](https://github.com/JackPGreen/hazelcast-cpp-client/milestone/3) Fixes: #1371, [DI-669](https://hazelcast.atlassian.net/browse/DI-669) [DI-669]: https://hazelcast.atlassian.net/browse/DI-669?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 6d47098 commit 51a3241

File tree

3 files changed

+69
-16
lines changed

3 files changed

+69
-16
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Update project version
2+
3+
inputs:
4+
NEXT_VERSION:
5+
required: true
6+
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Update `vcpkg.json`
11+
shell: bash
12+
run: |
13+
cat <<< $(jq --arg ver "${{ inputs.NEXT_VERSION }}" '.version = $ver' vcpkg.json) > vcpkg.json
14+
15+
- name: Update `CMakeLists.txt`s
16+
shell: bash
17+
run: |
18+
find . -name 'CMakeLists.txt' | \
19+
xargs perl -0777 -i -pe 's/(project\s*\([^)]*?\bVERSION\s+)\S+/\1$ENV{NEXT_VERSION}/s'
20+
env:
21+
NEXT_VERSION: ${{ inputs.NEXT_VERSION }}
22+
23+
- name: Get current branch name
24+
id: get-current-branch-name
25+
shell: bash
26+
run: |
27+
echo "name=$(git rev-parse --abbrev-ref HEAD)" >> ${GITHUB_OUTPUT}
28+
29+
- name: Create Pull Request
30+
# https://github.com/peter-evans/create-pull-request/releases/tag/v7.0.8
31+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
32+
with:
33+
branch: Update_version_to_${{ inputs.NEXT_VERSION }}_run_${{ github.run_id }}
34+
title: Update version to `${{ inputs.NEXT_VERSION }}` in `${{ steps.get-current-branch-name.outputs.name }}`
35+
body: ""

.github/workflows/create-release-branch.yml

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,45 @@ jobs:
2929
git checkout -b ${{ steps.project_version.outputs.version }}
3030
git push origin ${{ steps.project_version.outputs.version }}
3131
32+
# https://github.com/madhead/semver-utils/releases/tag/v4.3.0
33+
- uses: madhead/semver-utils@36d1e0ed361bd7b4b77665de8093092eaeabe6ba
34+
id: parse-version
35+
with:
36+
version: ${{ steps.project_version.outputs.version }}
37+
38+
- name: Compute Z-Branch name
39+
if: steps.parse-version.outputs.patch == '0'
40+
id: compute-z-branch-name
41+
run: |
42+
echo "name=${{ steps.parse-version.outputs.major }}.${{ steps.parse-version.outputs.minor }}.z" >> ${GITHUB_OUTPUT}
43+
44+
- name: Create `${{ steps.compute-z-branch-name.outputs.name }}` branch
45+
if: steps.parse-version.outputs.patch == '0'
46+
run: |
47+
git checkout -b ${{ steps.compute-z-branch-name.outputs.name }}
48+
git push origin ${{ steps.compute-z-branch-name.outputs.name }}
49+
50+
- if: steps.parse-version.outputs.patch == '0'
51+
uses: hazelcast/hazelcast-cpp-client/.github/actions/update-project-version@master
52+
with:
53+
NEXT_VERSION: ${{ steps.parse-version.outputs.inc-patch }}
54+
3255
update-version:
3356
name: Update next version in `${{ inputs.BRANCH_NAME }}` to `${{ inputs.NEXT_VERSION }}`
3457
runs-on: ubuntu-latest
35-
env:
36-
NEW_VERSION: ${{ inputs.NEXT_VERSION }}
3758
steps:
3859
- uses: actions/checkout@v5
3960
with:
4061
ref: ${{ inputs.BRANCH_NAME }}
4162

42-
- name: Update `vcpkg.json`
43-
run: |
44-
cat <<< $(jq --arg ver "${NEW_VERSION}" '.version = $ver' vcpkg.json) > vcpkg.json
63+
- uses: hazelcast/hazelcast-cpp-client/.github/actions/update-project-version@master
64+
with:
65+
NEXT_VERSION: ${{ inputs.NEXT_VERSION }}
4566

46-
- name: Update `CMakeLists.txt`s
67+
- name: Create milestone
4768
run: |
48-
find . -name 'CMakeLists.txt' | \
49-
xargs perl -0777 -i -pe 's/(project\s*\([^)]*?\bVERSION\s+)\S+/\1$ENV{NEW_VERSION}/s'
50-
51-
- name: Create Pull Request
52-
uses: peter-evans/create-pull-request@v7
53-
with:
54-
branch: Update_version_to_${{ inputs.NEXT_VERSION }}_run_${{ github.run_id }}
55-
title: Update development version to `${{ inputs.NEXT_VERSION }}`
56-
body: ""
69+
gh api \
70+
/repos/${GITHUB_REPOSITORY}/milestones \
71+
--field title='${{ inputs.NEXT_VERSION }}'
72+
env:
73+
GH_TOKEN: ${{ github.token }}

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ jobs:
7979
"${GH_PAGES_BRANCH}/api-index.html"
8080
8181
- name: Create Pull Request
82-
uses: peter-evans/create-pull-request@v7
82+
# https://github.com/peter-evans/create-pull-request/releases/tag/v7.0.8
83+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
8384
with:
8485
branch: ${{ needs.prepare.outputs.tag_name }}_doc_update_run_${{ github.run_id }}
8586
title: Add the new C++ client release (`${{ needs.prepare.outputs.tag_name }}`) documentation

0 commit comments

Comments
 (0)