Skip to content

Commit a58150a

Browse files
authored
Add version verification and pull request creation steps
1 parent 68ac5bb commit a58150a

1 file changed

Lines changed: 59 additions & 1 deletion

File tree

.github/workflows/update-project-version.yml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,62 @@ jobs:
7878
fi
7979
fi
8080
81-
- name:
81+
- name: verify version macros
82+
id: verify
83+
run: |
84+
FILE="include/json/version.h"
85+
if [ -f "$FILE" ]; then
86+
V_STR=$(grep "JSONCPP_VERSION_STRING" $FILE | awk -F'"' '{print $2}')
87+
V_MAJ=$(grep "JSONCPP_VERSION_MAJOR" $FILE | awk '{print $3}')
88+
V_MIN=$(grep "JSONCPP_VERSION_MINOR" $FILE | awk '{print $3}')
89+
V_PAT=$(grep "JSONCPP_VERSION_PATCH" $FILE | awk '{print $3}')
90+
V_QUA=$(grep "JSONCPP_VERSION_QUALIFIER" $FILE | awk '{print $3}')
91+
92+
echo "### version.h verification" >> $GITHUB_STEP_SUMMARY
93+
echo "| macro | value |" >> $GITHUB_STEP_SUMMARY
94+
echo "| :--- | :--- |" >> $GITHUB_STEP_SUMMARY
95+
echo "| string | $V_STR |" >> $GITHUB_STEP_SUMMARY
96+
echo "| major | $V_MAJ |" >> $GITHUB_STEP_SUMMARY
97+
echo "| minor | $V_MIN |" >> $GITHUB_STEP_SUMMARY
98+
echo "| patch | $V_PAT |" >> $GITHUB_STEP_SUMMARY
99+
echo "| qualifier | ${V_QUA:-*(empty)*} |" >> $GITHUB_STEP_SUMMARY
100+
101+
# pass values to the pr body
102+
{
103+
echo "header_report<<EOF"
104+
echo "| Macro | Value |"
105+
echo "| :--- | :--- |"
106+
echo "| STRING | \`$V_STR\` |"
107+
echo "| MAJOR | \`$V_MAJ\` |"
108+
echo "| MINOR | \`$V_MIN\` |"
109+
echo "| PATCH | \`$V_PAT\` |"
110+
echo "| QUALIFIER | \`${V_QUA:-empty}\` |"
111+
echo "EOF"
112+
} >> $GITHUB_OUTPUT
113+
fi
114+
115+
- name: sanity check (cmake configure)
116+
run: |
117+
if [ -f CMakeLists.txt ]; then
118+
mkdir build_check
119+
cd build_check
120+
cmake .. -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF
121+
cd ..
122+
rm -rf build_check
123+
fi
124+
125+
- name: create pull request
126+
uses: peter-evans/create-pull-request@v7
127+
with:
128+
token: ${{ secrets.GITHUB_TOKEN }}
129+
commit-message: "chore: bump version to ${{ github.event.inputs.target_version }}"
130+
branch: "bump-to-${{ github.event.inputs.target_version }}"
131+
title: "chore: bump version to ${{ github.event.inputs.target_version }}"
132+
body: |
133+
automated version bump.
134+
- new version: `${{ github.event.inputs.target_version }}`
135+
- new soversion: `${{ github.event.inputs.target_soversion || 'no change' }}`
136+
137+
### header verification
138+
${{ steps.verify.outputs.header_report }}
139+
labels: "maintenance"

0 commit comments

Comments
 (0)