Skip to content

Commit 215a0ac

Browse files
authored
Update main.yaml
1 parent e1b5dce commit 215a0ac

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

.github/workflows/main.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,42 @@ jobs:
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 }}"

0 commit comments

Comments
 (0)