Merge pull request #11 from tracel-ai/feat/add-cancellation-handling #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |