Skip to content

Commit 7e2ab4a

Browse files
sachiniyerclaude
andcommitted
ci: auto-tag releases when Cargo.toml version changes on main
Adds a workflow that reads the version from Cargo.toml on pushes to main, and creates a git tag if one doesn't already exist. This triggers the existing release workflow automatically, so merging a version bump PR is all that's needed to cut a release. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1b46016 commit 7e2ab4a

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

‎.github/workflows/auto-tag.yml‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Auto-tag release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths: [Cargo.toml]
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
tag:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Read version from Cargo.toml
18+
id: version
19+
run: |
20+
version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
21+
echo "version=$version" >> "$GITHUB_OUTPUT"
22+
echo "tag=v$version" >> "$GITHUB_OUTPUT"
23+
24+
- name: Check if tag exists
25+
id: check
26+
run: |
27+
if git ls-remote --tags origin "refs/tags/${{ steps.version.outputs.tag }}" | grep -q .; then
28+
echo "exists=true" >> "$GITHUB_OUTPUT"
29+
else
30+
echo "exists=false" >> "$GITHUB_OUTPUT"
31+
fi
32+
33+
- name: Create and push tag
34+
if: steps.check.outputs.exists == 'false'
35+
run: |
36+
git tag "${{ steps.version.outputs.tag }}"
37+
git push origin "${{ steps.version.outputs.tag }}"

0 commit comments

Comments
 (0)