coodinates file #2
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: Release | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.13' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install bump2version | |
| - name: Configure Git | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| - name: Get latest tag | |
| id: get_tag | |
| run: | | |
| latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | |
| echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT | |
| echo "Latest tag: $latest_tag" | |
| - name: Check if there are new commits | |
| id: check_commits | |
| run: | | |
| commits=$(git log ${{ steps.get_tag.outputs.latest_tag }}..HEAD --oneline) | |
| if [ -z "$commits" ]; then | |
| echo "has_commits=false" >> $GITHUB_OUTPUT | |
| echo "No new commits since last tag" | |
| else | |
| echo "has_commits=true" >> $GITHUB_OUTPUT | |
| echo "New commits found:" | |
| echo "$commits" | |
| fi | |
| - name: Determine version bump | |
| id: version_bump | |
| if: steps.check_commits.outputs.has_commits == 'true' | |
| run: | | |
| # Get commits since last tag | |
| commits=$(git log ${{ steps.get_tag.outputs.latest_tag }}..HEAD --oneline) | |
| # Default to patch | |
| bump_type="patch" | |
| # Check for breaking changes or major features | |
| if echo "$commits" | grep -iE "(BREAKING CHANGE|!:)" > /dev/null; then | |
| bump_type="major" | |
| elif echo "$commits" | grep -iE "(^feat|^feature)" > /dev/null; then | |
| bump_type="minor" | |
| fi | |
| echo "bump_type=$bump_type" >> $GITHUB_OUTPUT | |
| echo "Determined bump type: $bump_type" | |
| - name: Bump version | |
| id: bump_version | |
| if: steps.check_commits.outputs.has_commits == 'true' | |
| run: | | |
| # Use bump2version to increment version | |
| bump2version ${{ steps.version_bump.outputs.bump_type }} | |
| # Get the new version | |
| new_version=$(grep -o 'version = "[^"]*"' pyproject.toml | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+') | |
| echo "new_version=$new_version" >> $GITHUB_OUTPUT | |
| echo "Bumped to version: $new_version" | |
| - name: Commit and tag | |
| if: steps.check_commits.outputs.has_commits == 'true' | |
| run: | | |
| git add -A | |
| git commit -m "chore: bump version to ${{ steps.bump_version.outputs.new_version }}" | |
| git tag "v${{ steps.bump_version.outputs.new_version }}" | |
| git push origin HEAD --tags | |
| - name: Create GitHub Release | |
| if: steps.check_commits.outputs.has_commits == 'true' | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.bump_version.outputs.new_version }} | |
| release_name: Release v${{ steps.bump_version.outputs.new_version }} | |
| draft: false | |
| prerelease: false |