Skip to content

Merge pull request #11 from tracel-ai/feat/add-cancellation-handling #7

Merge pull request #11 from tracel-ai/feat/add-cancellation-handling

Merge pull request #11 from tracel-ai/feat/add-cancellation-handling #7

Workflow file for this run

name: Auto Release
on:
push:
branches:
- main
# Prevent concurrent runs but don't cancel in-progress ones
# This avoids race conditions while ensuring all pushes are processed
concurrency:
group: auto-release
cancel-in-progress: false
permissions:
contents: write # Required for creating tags and releases
jobs:
create-release:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.version.outputs.tag }}
release_created: ${{ steps.release.outputs.created }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for accurate tag checking
- name: Extract version from Cargo.toml
id: version
run: |
VERSION=$(grep -A 10 '^\[workspace.package\]' Cargo.toml | grep '^version' | cut -d'"' -f2)
if [ -z "$VERSION" ]; then
echo "Error: Could not extract version from Cargo.toml"
exit 1
fi
# Validate semver format (basic check)
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+'; then
echo "Error: Invalid version format: $VERSION"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Create GitHub Release
id: release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ steps.version.outputs.tag }}"
if git ls-remote --tags origin | grep -q "refs/tags/${TAG}$"; then
echo "Release $TAG already exists, nothing to do."
echo "created=false" >> $GITHUB_OUTPUT
else
echo "Creating release for $TAG..."
gh release create "$TAG" \
--title "$TAG" \
--generate-notes \
--target main
echo "Successfully created release $TAG"
echo "created=true" >> $GITHUB_OUTPUT
fi
publish-crate:
needs: create-release
if: needs.create-release.outputs.release_created == 'true'
uses: tracel-ai/github-actions/.github/workflows/publish-crate.yml@v1
with:
crate: burn-central-client
secrets:
CRATES_IO_API_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }}