midenup 1.2.1

The Miden toolchain manager
name: 'Install Miden toolchain'
description: 'Install midenup and a Miden toolchain, and make it the default'
branding:
  icon: 'download'
  color: 'orange'

inputs:
  toolchain:
    description: 'Network or version to install, e.g. `mainnet` or `0.15.0`. If unspecified, it defaults to the active toolchain.'
    required: false
    default: ''
  profile:
    description: 'Toolchain profile to install: `empty`, `minimal` or `complete`. Ignored if a toolchain was not specified and a `miden-toolchain.toml` is present.'
    required: false
    default: 'minimal'
  components:
    description: 'Comma-separated components to install in addition to the profile, e.g. `client,vm`. Ignored if a toolchain was not specified and a `miden-toolchain.toml` is present.'
    required: false
    default: ''
  midenup-version:
    description: 'midenup release to install, e.g. `1.0.0`. Defaults to the latest release'
    required: false
    default: ''
  github-token:
    description: 'Token used to verify the attestation of the downloaded midenup release'
    required: false
    default: ${{ github.token }}

runs:
  using: 'composite'
  steps:
    - name: Install midenup
      shell: bash
      env:
        GH_TOKEN: ${{ inputs.github-token }}
        MIDENUP_VERSION: ${{ inputs.midenup-version }}
      run: |
        args=()
        if [ -n "$MIDENUP_VERSION" ]; then args+=(--version "$MIDENUP_VERSION"); fi
        "${{ github.action_path }}/bin/installer.sh" "${args[@]}"

    - name: Install toolchain
      shell: bash
      env:
        TOOLCHAIN: ${{ inputs.toolchain }}
        PROFILE: ${{ inputs.profile }}
        COMPONENTS: ${{ inputs.components }}
      run: |
        # The miden-toolchain.toml file takes precedence when no toolchain is specified
        if [ -z "$TOOLCHAIN" ] && [ -f miden-toolchain.toml ]; then
          midenup install
          exit 0
        fi

        # Otherwise, use the specified toolchain or default to mainnet
        toolchain="${TOOLCHAIN:-mainnet}"
        args=(--profile "$PROFILE")
        IFS=',' read -ra components <<< "$COMPONENTS"
        for component in "${components[@]}"; do
          component="${component// /}"
          if [ -n "$component" ]; then args+=(--component "$component"); fi
        done
        midenup install "$toolchain" "${args[@]}"
        midenup override "$toolchain"