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