-
Notifications
You must be signed in to change notification settings - Fork 183
77 lines (63 loc) · 2.13 KB
/
tag-version.yml
File metadata and controls
77 lines (63 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Tag livekit-agents version
on:
push:
branches: [main]
paths:
- 'pyproject.toml'
permissions:
contents: write
jobs:
tag-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2
fetch-tags: true
- name: Detect livekit-agents version change
id: version
run: |
set -euo pipefail
extract_version() {
local ref="$1"
git show "$ref:pyproject.toml" 2>/dev/null \
| grep -oE '"livekit-agents(\[[^]]*\])?==[^"]+"' \
| head -n1 \
| sed -E 's/.*==([^"]+)"/\1/' \
|| true
}
current=$(extract_version HEAD)
previous=$(extract_version HEAD^ || true)
echo "current=$current"
echo "previous=$previous"
if [ -z "$current" ]; then
echo "No livekit-agents==X.Y.Z pin found in pyproject.toml; skipping."
echo "should_tag=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ "$current" = "$previous" ]; then
echo "livekit-agents version unchanged ($current); skipping."
echo "should_tag=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "livekit-agents bumped: ${previous:-<none>} -> $current"
echo "should_tag=true" >> "$GITHUB_OUTPUT"
echo "version=$current" >> "$GITHUB_OUTPUT"
- name: Create and push tag
if: steps.version.outputs.should_tag == 'true'
run: |
set -euo pipefail
tag="v${{ steps.version.outputs.version }}"
if git rev-parse --verify "refs/tags/$tag" >/dev/null 2>&1; then
existing=$(git rev-list -n1 "$tag")
if [ "$existing" = "$GITHUB_SHA" ]; then
echo "Tag $tag already points at $GITHUB_SHA; nothing to do."
exit 0
fi
echo "Error: tag $tag already exists on a different commit ($existing)."
exit 1
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "$tag" -m "livekit-agents $tag"
git push origin "$tag"