version: "3"
internal: true

includes:
  platforms: ../config/platforms.yml

vars:
  ALEF: "alef"

tasks:
  sync:
    desc: "Synchronize version across all package manifests and regenerate everything"
    cmds:
      - "{{.ALEF}} sync-versions"
      - "{{.ALEF}} readme"
      - "{{.ALEF}} docs"
      - "{{.ALEF}} generate --clean"
      - "{{.ALEF}} stubs"
      - "{{.ALEF}} e2e generate"

  check:
    desc: "Check if versions are synchronized (dry-run)"
    cmds:
      - cmd: grep -m 1 'version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/'
        silent: false

  bump:major:
    desc: "Bump major version (X.0.0) and sync"
    cmds:
      - "{{.ALEF}} sync-versions --bump major"
      - task: sync

  bump:minor:
    desc: "Bump minor version (0.X.0) and sync"
    cmds:
      - "{{.ALEF}} sync-versions --bump minor"
      - task: sync

  bump:patch:
    desc: "Bump patch version (0.0.X) and sync"
    cmds:
      - "{{.ALEF}} sync-versions --bump patch"
      - task: sync

  set:
    desc: "Set explicit version and sync (usage: task version:set -- 4.10.0-rc.1)"
    requires:
      vars: [CLI_ARGS]
    cmds:
      - "{{.ALEF}} sync-versions --set {{.CLI_ARGS}}"
      - task: sync

  show:
    desc: "Show current version from Cargo.toml"
    cmds:
      - cmd: grep -m 1 'version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/'
        silent: false
