Skip to content

Commit 588930e

Browse files
committed
feat: added composite action for fetching latest tag information
1 parent bf56634 commit 588930e

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "Get Latest Tag Info"
2+
description: "Fetch the latest git tag and extract tag name, author name, and author email"
3+
4+
outputs:
5+
tag-name:
6+
description: "The name of the latest tag"
7+
value: ${{ steps.get_tag_info.outputs.tag-name }}
8+
author-name:
9+
description: "The name of the tag author"
10+
value: ${{ steps.get_tag_info.outputs.author-name }}
11+
author-email:
12+
description: "The email of the tag author"
13+
value: ${{ steps.get_tag_info.outputs.author-email }}
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v5
20+
with:
21+
fetch-depth: 0
22+
fetch-tags: true
23+
24+
- name: Get tag information
25+
id: get_tag_info
26+
shell: bash
27+
run: |
28+
# Get the latest tag
29+
TAG=$(git describe --tags --abbrev=0)
30+
echo "tag-name=$TAG" >> $GITHUB_OUTPUT
31+
32+
# Try to get author info from annotated tag
33+
AUTHOR=$(git tag -l --format='%(taggername)' "$TAG")
34+
EMAIL=$(git tag -l --format='%(taggeremail)' "$TAG")
35+
36+
# If empty (lightweight tag), fall back to commit author
37+
if [ -z "$AUTHOR" ]; then
38+
AUTHOR=$(git log -1 --format='%an' "$TAG")
39+
EMAIL=$(git log -1 --format='%ae' "$TAG")
40+
fi
41+
42+
# Clean up email (remove <>)
43+
EMAIL=$(echo "$EMAIL" | sed 's/[<>]//g')
44+
45+
echo "author-name=$AUTHOR" >> $GITHUB_OUTPUT
46+
echo "author-email=$EMAIL" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)