serpl 0.3.10

A simple terminal UI for search and replace, ala VS Code
name: Bump Version

on:
  push:
    branches:
      - main

jobs:
  test:
    name: Test Suite
    runs-on: ubuntu-latest
    if: "!contains(github.event.head_commit.message, 'Bump version to ')"
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@nightly
      - uses: Swatinem/rust-cache@v2
      - name: Run tests
        run: cargo test --all-features --workspace

  # clippy:
  #   name: Clippy
  #   runs-on: ubuntu-latest
  #   if: "!contains(github.event.head_commit.message, 'Bump version to ')"
  #   steps:
  #     - name: Checkout repository
  #       uses: actions/checkout@v4
  #     - name: Install Rust toolchain
  #       uses: dtolnay/rust-toolchain@nightly
  #       with:
  #         components: clippy
  #     - uses: Swatinem/rust-cache@v2
  #     - name: Clippy check
  #       run: cargo clippy --all-targets --all-features --workspace -- -D warnings

  docs:
    name: Docs
    runs-on: ubuntu-latest
    if: "!contains(github.event.head_commit.message, 'Bump version to ')"
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@nightly
      - uses: Swatinem/rust-cache@v2
      - name: Check documentation
        env:
          RUSTDOCFLAGS: -D warnings
        run: cargo doc --no-deps --document-private-items --all-features --workspace --examples

  bump-version:
    name: Bump Version
    runs-on: ubuntu-latest
    needs: [test, docs]
    if: "!contains(github.event.head_commit.message, 'Bump version to ')"
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

      - name: Setup Git
        run: |
          git config --global user.name "github-actions"
          git config --global user.email "github-actions@github.com"

      - name: Bump Version
        id: bump_version
        run: |
          CURRENT_VERSION=$(grep -E '^version = "[0-9]+\.[0-9]+\.[0-9]+"' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
          NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{print $1"."$2"."$3+1}')
          sed -i "s/version = \"$CURRENT_VERSION\"/version = \"$NEW_VERSION\"/" Cargo.toml
          echo "Bumped version from $CURRENT_VERSION to $NEW_VERSION"
          echo "::set-output name=new_version::$NEW_VERSION"
      
      - name: Update Cargo.lock
        run: cargo update
         
      # - name: Format Code
      #   run: cargo fmt --all

      - name: Commit and Tag
        run: |
          NEW_VERSION=${{ steps.bump_version.outputs.new_version }}
          git add .
          git commit -m "Bump version to $NEW_VERSION"
          git tag -a "$NEW_VERSION" -m "Release version $NEW_VERSION"
          git push origin main --tags
        env:
          GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}