Skip to content

Commit fd8232a

Browse files
committed
fix ci releases
1 parent bbccd01 commit fd8232a

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
push:
55
branches: [ "main" ]
66
tags:
7-
- 'v*.*.*'
8-
workflow_dispatch: # allows manual trigger
7+
- 'v*.*.*' # Trigger on tag pushes
8+
workflow_dispatch:
99
inputs:
1010
tag:
1111
description: 'Optional tag to release (e.g., v2.0.0)'
@@ -90,16 +90,13 @@ jobs:
9090
- name: Determine Tag
9191
id: version
9292
run: |
93-
# Use manual tag if provided
9493
if [ -n "${{ github.event.inputs.tag }}" ]; then
94+
# Use manual tag if provided
9595
new_tag="${{ github.event.inputs.tag }}"
96-
else
96+
elif [[ "${GITHUB_REF}" == refs/heads/main ]]; then
97+
# Auto-increment patch version for main branch
9798
latest_tag=$(git describe --tags --abbrev=0 || echo "v0.0.0")
98-
echo "Latest tag: $latest_tag"
99-
10099
IFS='.' read -r major minor patch <<<"${latest_tag#v}"
101-
102-
# Increment patch
103100
if [ "$patch" -lt 9 ]; then
104101
patch=$((patch + 1))
105102
else
@@ -111,14 +108,14 @@ jobs:
111108
major=$((major + 1))
112109
fi
113110
fi
114-
115111
new_tag="v${major}.${minor}.${patch}"
112+
else
113+
# Use pushed tag for tag-triggered workflow
114+
new_tag="${GITHUB_REF##*/}"
116115
fi
117116
118-
# Ensure tag does not already exist
119-
if git rev-parse "$new_tag" >/dev/null 2>&1; then
120-
echo "Tag $new_tag already exists, skipping creation."
121-
else
117+
# Ensure tag exists
118+
if ! git rev-parse "$new_tag" >/dev/null 2>&1; then
122119
git tag "$new_tag"
123120
git push origin "$new_tag"
124121
fi

0 commit comments

Comments
 (0)