name: Validate Install

# Runs after a release is published to verify the documented installation
# method (mise + github) actually works with the released binary.
on:
  release:
    types: [published]
  # Allow manual re-runs if a release asset was re-uploaded
  workflow_dispatch:
    inputs:
      tag:
        description: "Release tag to test (e.g. v0.21.1)"
        required: true

permissions:
  contents: read

jobs:
  validate-mise-install:
    name: Validate `mise use -g github:rise-deploy/rise`
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest]
    steps:
      - name: Resolve release tag
        id: tag
        run: |
          TAG="${{ github.event.release.tag_name || inputs.tag }}"
          if [ -z "$TAG" ]; then
            echo "No tag provided; cannot determine which version to test." >&2
            exit 1
          fi
          echo "value=$TAG" >> "$GITHUB_OUTPUT"

      - name: Install mise
        uses: jdx/mise-action@v2
        with:
          install: false

      - name: Install Rise CLI via mise
        run: mise use -g "github:rise-deploy/rise@${{ steps.tag.outputs.value }}"

      - name: Verify binary is on PATH and reports a version
        run: |
          which rise
          rise --version
