command-vault 0.3.0

An advanced command history manager with tagging and search capabilities
Documentation
name: Version Bump

on:
  pull_request:
    types: [labeled, opened, synchronize, reopened]
  workflow_dispatch:
    inputs:
      bump:
        description: 'Version bump type (major, minor, patch)'
        required: true
        default: 'patch'
        type: choice
        options:
          - major
          - minor
          - patch

jobs:
  version-bump:
    if: |
      github.event_name == 'workflow_dispatch' ||
      (github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'bump:major') || contains(github.event.pull_request.labels.*.name, 'bump:minor') || contains(github.event.pull_request.labels.*.name, 'bump:patch')))
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Install cargo-edit
        run: cargo install cargo-edit

      - name: Determine version bump
        id: bump
        run: |
          if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
            echo "bump=${{ github.event.inputs.bump }}" >> $GITHUB_OUTPUT
          else
            if [[ "${{ join(github.event.pull_request.labels.*.name, ' ') }}" =~ "bump:major" ]]; then
              echo "bump=major" >> $GITHUB_OUTPUT
            elif [[ "${{ join(github.event.pull_request.labels.*.name, ' ') }}" =~ "bump:minor" ]]; then
              echo "bump=minor" >> $GITHUB_OUTPUT
            else
              echo "bump=patch" >> $GITHUB_OUTPUT
            fi
          fi

      - name: Get current version
        id: current_version
        run: |
          version=$(grep "^version" Cargo.toml | sed 's/version = "\(.*\)"/\1/')
          echo "version=$version" >> $GITHUB_OUTPUT

      - name: Bump version
        id: bump_version
        run: |
          cargo set-version --bump ${{ steps.bump.outputs.bump }}
          new_version=$(grep "^version" Cargo.toml | sed 's/version = "\(.*\)"/\1/')
          echo "version=$new_version" >> $GITHUB_OUTPUT

      - name: Commit changes
        run: |
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git add Cargo.toml Cargo.lock
          git commit -m "chore: bump version ${{ steps.current_version.outputs.version }} -> ${{ steps.bump_version.outputs.version }}"

      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: ${{ github.head_ref || github.ref_name }}