File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Version Check
2
+ on :
3
+ release :
4
+ types : [published]
5
+
6
+ jobs :
7
+ validate_version :
8
+ runs-on : ubuntu-latest
9
+ steps :
10
+ - uses : actions/checkout@v4
11
+ with :
12
+ fetch-depth : 0 # Fetch complete git history for version comparison
13
+
14
+ # Extract last two tags for version comparison
15
+ - name : Get version history
16
+ id : versions
17
+ run : |
18
+ # Get previous tag (skip current tag)
19
+ PREV_TAG=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1))
20
+ # Current tag being published (extracted from GITHUB_REF)
21
+ CURRENT_TAG=${GITHUB_REF#refs/tags/}
22
+ echo "prev_tag=${PREV_TAG}" >> $GITHUB_OUTPUT
23
+ echo "current_tag=${CURRENT_TAG}" >> $GITHUB_OUTPUT
24
+
25
+ # Validate version.h matches the release tag
26
+ - name : Assert version increment
27
+ run : |
28
+ CODE_VERSION=$(grep -oP '#define\s+VERSION\s+"\K\d+(\.\d+){2,3}' source/version.h)
29
+
30
+ if [[ -z "$CODE_VERSION" ]]; then
31
+ echo "::error::Failed to extract version from source/version.h"
32
+ exit 1
33
+ fi
34
+
35
+ # Verify that the version in version.h matches the tag
36
+ if [[ "${{ steps.versions.outputs.current_tag }}" != "v${CODE_VERSION}" ]]; then
37
+ echo "::error::Version mismatch: tag=${{ steps.versions.outputs.current_tag }} ≠ code=${CODE_VERSION}"
38
+ exit 1
39
+ fi
40
+
41
+ # Ensure the version has been incremented
42
+ if [[ "${{ steps.versions.outputs.prev_tag}}" == "${{ steps.versions.outputs.current_tag }}" ]]; then
43
+ echo "::error::Version unchanged: ${{ steps.versions.outputs.current_tag }}"
44
+ exit 1
45
+ fi
You can’t perform that action at this time.
0 commit comments