Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,28 @@ jobs:
cd .github/scripts
go mod download
go run .

# Conditional step: Bump version and create tag only if the comparison script passes
- name: Bump Version and Create Tag
if: ${{ success() && steps.compare_control.outcome == 'success' }}
id: versioning
run: |
# Fetch tags from the repository
git fetch --tags

# Get the latest tag and increment based on semantic versioning rules
latest_tag=$(git tag --sort=-v:refname | head -n 1)
if [ -z "$latest_tag" ]; then
# If no tags exist, start at v0.1.0
new_tag="v0.1.0"
else
# Split the latest tag into major, minor, and patch
IFS='.' read -r major minor patch <<< "${latest_tag//v/}"
echo "${latest_tag//v/}" | IFS='.' read -r major minor patch
# Increment the patch version
patch=$((patch + 1))
new_tag="v${major}.${minor}.${patch}"
fi

# Create and push the new tag
git tag "$new_tag"
git push origin "$new_tag"

# Set the new_tag as an output
echo "new_tag=$new_tag" >> $GITHUB_OUTPUT
env:
Expand All @@ -65,4 +61,4 @@ jobs:
# Output the new tag
- name: Display new tag
if: ${{ success() && steps.versioning.outcome == 'success' }}
run: echo "Created new tag: ${{ steps.versioning.outputs.new_tag }}"
run: echo "Created new tag: ${{ steps.versioning.outputs.new_tag }}"