File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 2626 go-version : ' 1.22.5'
2727
2828 - name : Run comparison script
29+ id : compare_control
2930 run : |
3031 cd .github/scripts
3132 go mod download
3233 go run .
34+
35+ # Conditional step: Bump version and create tag only if the comparison script passes
36+ - name : Bump Version and Create Tag
37+ if : ${{ success() && steps.compare_control.outcome == 'success' }}
38+ id : versioning
39+ run : |
40+ # Fetch tags from the repository
41+ git fetch --tags
42+
43+ # Get the latest tag and increment based on semantic versioning rules
44+ latest_tag=$(git tag --sort=-v:refname | head -n 1)
45+ if [ -z "$latest_tag" ]; then
46+ # If no tags exist, start at v0.1.0
47+ new_tag="v0.1.0"
48+ else
49+ # Split the latest tag into major, minor, and patch
50+ IFS='.' read -r major minor patch <<< "${latest_tag//v/}"
51+ # Increment the patch version
52+ patch=$((patch + 1))
53+ new_tag="v${major}.${minor}.${patch}"
54+ fi
55+
56+ # Create and push the new tag
57+ git tag "$new_tag"
58+ git push origin "$new_tag"
59+
60+ # Required to push changes to the repository
61+ env :
62+ GITHUB_TOKEN : ${{ secrets.GH_REPO_TOKEN }}
63+
64+ # Output the new tag
65+ - name : Display new tag
66+ if : ${{ success() && steps.versioning.outcome == 'success' }}
67+ run : echo "Created new tag: ${{ steps.versioning.outputs.new_tag }}"
You can’t perform that action at this time.
0 commit comments