name: Release

on:
  push:
    tags:
      - "[0-9]+.[0-9]+.[0-9]+*"

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code # to upload release assets
        uses: actions/checkout@v4
      - id: major_version
        run: >
          echo major_version=$(
            echo ${{ github.ref }} | cut -d'v' -f2 | cut -d'.' -f1
          ) >> $GITHUB_OUTPUT
      - id: is_release_candidate
        run: >
          echo is_release_candidate=$(
            echo ${{ github.ref }} | grep -c 'rc'
          ) >> $GITHUB_OUTPUT
      - name: Create release
        uses: softprops/action-gh-release@v2
        with:
          prerelease: ${{ steps.major_version.outputs.major_version == 0 || steps.is_release_candidate.outputs.is_release_candidate == 1 }}
          generate_release_notes: true
          files: nb
