Update README.md #1
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: Create Release | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| types: [closed] | |
| jobs: | |
| release: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Fetch all tags | |
| run: git fetch --tags | |
| - name: Get latest tag | |
| id: get_latest_tag | |
| run: | | |
| TAG=$(git tag --sort=-v:refname | grep '^v' | head -n 1 || echo "v0.0.0") | |
| echo "Latest tag: $TAG" | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| - name: Determine bump type from PR labels | |
| id: bump_type | |
| run: | | |
| labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') | |
| echo "Labels: $labels" | |
| if echo "$labels" | grep -q 'release:major'; then | |
| echo "Bumping major" | |
| echo "bump=major" >> $GITHUB_OUTPUT | |
| elif echo "$labels" | grep -q 'release:minor'; then | |
| echo "Bumping minor" | |
| echo "bump=minor" >> $GITHUB_OUTPUT | |
| else | |
| echo "Bumping patch" | |
| echo "bump=patch" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Calculate next version | |
| id: bump_version | |
| run: | | |
| version=${{ steps.get_latest_tag.outputs.tag }} | |
| version=${version#v} | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$version" | |
| case "${{ steps.bump_type.outputs.bump }}" in | |
| major) | |
| MAJOR=$((MAJOR + 1)) | |
| MINOR=0 | |
| PATCH=0 | |
| ;; | |
| minor) | |
| MINOR=$((MINOR + 1)) | |
| PATCH=0 | |
| ;; | |
| patch) | |
| PATCH=$((PATCH + 1)) | |
| ;; | |
| esac | |
| NEW_TAG="v$MAJOR.$MINOR.$PATCH" | |
| echo "New version: $NEW_TAG" | |
| echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT | |
| - name: Create Git tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@github.com" | |
| git tag ${{ steps.bump_version.outputs.new_tag }} | |
| git push origin ${{ steps.bump_version.outputs.new_tag }} | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.bump_version.outputs.new_tag }} | |
| name: Release ${{ steps.bump_version.outputs.new_tag }} | |
| generate_release_notes: true |