name: Next Channel

# workflow_dispatch: set "Use workflow from branch" to `main` so reusable-channel-publish.yml
# is the latest (tag guards, etc.). The tree built for artifacts is always ref `next` below.
on:
  push:
    branches: [next]
    # Merging auto PR "chore(nix): refresh lock …" only touches these paths — do not
    # re-run the full channel (would loop: publish → verify-nix PR → merge → push → publish).
    paths-ignore:
      - "flake.lock"
      - "nix/**"
  workflow_dispatch:
    inputs:
      source_only:
        description: "Create/refresh tagged release only (skip platform builds and verify-nix)"
        required: false
        default: false
        type: boolean

jobs:
  publish-next:
    uses: ./.github/workflows/reusable-channel-publish.yml
    with:
      channel: next
      # Always build from channel branch; do not tie checkout to workflow_dispatch UI branch.
      source_ref: next
      target_branch: next
      prerelease: true
      draft_release: true
      verify_nix: ${{ !((github.event_name == 'workflow_dispatch' && github.event.inputs.source_only == 'true') || (github.event_name == 'push' && contains(github.event.head_commit.message, '[source-only]'))) }}
      build_platform_artifacts: ${{ !((github.event_name == 'workflow_dispatch' && github.event.inputs.source_only == 'true') || (github.event_name == 'push' && contains(github.event.head_commit.message, '[source-only]'))) }}
    secrets: inherit
