Merge dev to main: community health files #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: Version Bump | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| jobs: | |
| tag-version: | |
| if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine latest version tag | |
| id: latest | |
| run: | | |
| # Find the latest v{major}.{minor}.{patch} tag reachable from HEAD | |
| latest_tag=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n1) | |
| if [ -z "$latest_tag" ]; then | |
| echo "major=1" >> "$GITHUB_OUTPUT" | |
| echo "minor=0" >> "$GITHUB_OUTPUT" | |
| echo "No existing version tags found — starting at 1.0" | |
| else | |
| version="${latest_tag#v}" | |
| major=$(echo "$version" | cut -d. -f1) | |
| minor=$(echo "$version" | cut -d. -f2) | |
| echo "major=$major" >> "$GITHUB_OUTPUT" | |
| echo "minor=$minor" >> "$GITHUB_OUTPUT" | |
| echo "Latest tag: $latest_tag (major=$major, minor=$minor)" | |
| fi | |
| - name: Compute new version | |
| id: new | |
| run: | | |
| major=${{ steps.latest.outputs.major }} | |
| minor=$(( ${{ steps.latest.outputs.minor }} + 1 )) | |
| patch=${{ github.event.pull_request.number }} | |
| new_version="${major}.${minor}.${patch}" | |
| echo "version=$new_version" >> "$GITHUB_OUTPUT" | |
| echo "New version: v$new_version" | |
| - name: Create and push tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git tag -a "v${{ steps.new.outputs.version }}" -m "Release v${{ steps.new.outputs.version }} (PR #${{ github.event.pull_request.number }})" | |
| git push origin "v${{ steps.new.outputs.version }}" |