Skip to content

Commit 968c54c

Browse files
Merge pull request #5 from tracel-ai/feat/auto-publish
feat: auto release
2 parents 09f904d + cfe6f95 commit 968c54c

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

.github/workflows/auto-release.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Auto Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
# Prevent concurrent runs but don't cancel in-progress ones
9+
# This avoids race conditions while ensuring all pushes are processed
10+
concurrency:
11+
group: auto-release
12+
cancel-in-progress: false
13+
14+
permissions:
15+
contents: write # Required for creating tags and releases
16+
17+
jobs:
18+
create-release:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # Fetch all history for accurate tag checking
26+
27+
- name: Extract version from Cargo.toml
28+
id: version
29+
run: |
30+
VERSION=$(grep -A 10 '^\[workspace.package\]' Cargo.toml | grep '^version' | cut -d'"' -f2)
31+
32+
if [ -z "$VERSION" ]; then
33+
echo "Error: Could not extract version from Cargo.toml"
34+
exit 1
35+
fi
36+
37+
# Validate semver format (basic check)
38+
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+'; then
39+
echo "Error: Invalid version format: $VERSION"
40+
exit 1
41+
fi
42+
43+
echo "version=$VERSION" >> $GITHUB_OUTPUT
44+
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
45+
echo "Extracted version: $VERSION"
46+
47+
- name: Create GitHub Release
48+
env:
49+
GH_TOKEN: ${{ github.token }}
50+
run: |
51+
TAG="${{ steps.version.outputs.tag }}"
52+
53+
if git ls-remote --tags origin | grep -q "refs/tags/${TAG}$"; then
54+
echo "Release $TAG already exists, nothing to do."
55+
else
56+
echo "Creating release for $TAG..."
57+
58+
gh release create "$TAG" \
59+
--title "$TAG" \
60+
--generate-notes \
61+
--target main
62+
63+
echo "Successfully created release $TAG"
64+
fi

0 commit comments

Comments
 (0)