Skip to content

Make version optional in setup-cli action and support major-version channels #64855

Closed

Description

@JTrillo

Optional Version Input and Major-Version Channels for setup-cli action

Suggested issue title: Make version optional in setup-cli action and support major-version channels

Goal: Allow users of actions/setup-cli to omit version and receive the latest stable release by default. Add forward-looking major-version channels such as v1 and v2, while preserving exact release-tag installation. gh-aw has not released v1 yet, so these channels will have no matching release until stable releases for those majors exist.

Architecture: Keep install-gh-aw.sh and install-gh-aw.ps1 as the canonical installers. Both installers should resolve major-version channels to the highest stable semantic version in that major, then use the resolved full release tag consistently for gh extension install, binary download, and checksum verification. Keep the two implementations behaviorally aligned and sync their copies into actions/setup-cli/ using the existing Make target.

Tech Stack: GitHub composite actions, Bash, PowerShell, GitHub Releases API, shell installer tests.

Problem

actions/setup-cli/action.yml currently marks version as required and has no default, while actions/setup-cli/README.md describes it as accepting only a release tag.

The canonical installer scripts already default to latest when no version is provided. However, that behavior cannot currently be used through the action because its metadata requires an input. The installers also treat values other than latest as exact release tags, so values such as v1 are not resolved to a release.

Current release status: gh-aw is still on the v0.x release line and does not yet have a v1 release. Therefore, v1 and later major channels are preparatory and cannot install a matching release today. The generic vN contract would include v0, which can resolve to the existing stable v0.x releases.

Expected Usage

Install the latest stable release without specifying a version:

- uses: github/gh-aw/actions/setup-cli@main

Once a stable v1 release exists, install the latest stable release in that major-version channel:

- uses: github/gh-aw/actions/setup-cli@main
  with:
    version: v1

Continue to support exact release tags:

- uses: github/gh-aw/actions/setup-cli@main
  with:
    version: v1.2.3

Version Resolution Contract

  • An omitted version input is equivalent to latest.
  • latest continues to select the latest stable release overall.
  • A channel matching vN selects the highest stable SemVer release tag in major version N, for example, v1 may resolve to v1.10.0.
  • The vN syntax includes v0; v0 can resolve to the current stable v0.x release line. Channels such as v1 have no target until a stable release in that major is published.
  • Prereleases must not be selected for latest or a major-version channel.
  • Exact release tags continue to select that exact release.
  • If a major-version channel has no matching stable release, installation fails with a clear error before replacing an existing installation.
  • The resolved full tag is used consistently for installation, download, checksum verification, and version-mismatch checks.

Global Constraints

  • Preserve existing exact-tag behavior and checksum verification.
  • Keep Bash and PowerShell behavior consistent.
  • Do not add runtime dependencies solely for version resolution.
  • Do not change the installed-version output contract.
  • Continue to edit the root installer scripts as the canonical sources; generated copies under actions/setup-cli/ must be updated with make sync-action-scripts.
  • Preserve the installers' existing staging and replacement safeguards.

Implementation Plan

Task 1: Update the action input contract

Files:

  • Modify: actions/setup-cli/action.yml

Changes:

  • Set required: false for version.
  • Set default: latest.
  • Update the input description to list exact tags, latest, and major-version channels (vN).

Acceptance check: The action metadata allows a caller to omit version and passes latest to the installer.

Task 2: Add Bash channel resolution and regression coverage

Files:

  • Modify: install-gh-aw.sh
  • Test: scripts/test-install-script.sh

Changes:

  • Resolve a vN channel through the GitHub Releases API.
  • Consider only non-prerelease releases whose tags are valid stable versions in that major.
  • Select by SemVer ordering, not string ordering or API response order.
  • Handle API pagination so an older matching stable release is not missed.
  • Use the resolved tag for both the gh extension install --pin path and the direct-download fallback.
  • Fail clearly if no matching stable release exists.

Extend the existing mocked installer tests with cases covering:

  • INPUT_VERSION unset resolves to latest.
  • A channel selects the highest stable version, including a numeric-ordering case such as v1.9.0 versus v1.10.0.
  • A newer prerelease is ignored in favor of the latest stable release.
  • Releases from other major versions are ignored.
  • Pagination finds a matching release on a later page.
  • A channel with no stable release fails without replacing an existing binary.
  • A v1 request currently follows the no-matching-stable-release behavior; tests must not imply that a v1 release already exists.
  • Exact release tags retain their current behavior.

Task 3: Implement equivalent PowerShell behavior

Files:

  • Modify: install-gh-aw.ps1
  • Test: Add or extend focused PowerShell/Windows coverage using the repository's existing test conventions.

Changes:

  • Implement the same channel syntax, stable-release filtering, SemVer selection, pagination, and failure behavior as the Bash installer.
  • Ensure both the gh installation path and manual-download fallback use the same resolved tag.
  • Verify that exact tags and latest keep their existing behavior.

Task 4: Update action documentation and sync generated scripts

Files:

  • Modify: actions/setup-cli/README.md
  • Generated copies: actions/setup-cli/install.sh, actions/setup-cli/install.ps1

Changes:

  • Document that version is optional and defaults to latest.
  • Document exact tags and vN channels, including that major-version channels are beta and that v1 has no matching release yet.
  • Add examples for omitting version, using v1, and using an exact tag.
  • Regenerate the action script copies with make sync-action-scripts.

Validation Plan

  • Run bash scripts/test-install-script.sh install-gh-aw.sh.
  • Run bash actions/setup-cli/install_test.sh.
  • Run the focused PowerShell/Windows tests added or updated for this behavior.
  • Run make agent-finish as required by the repository's contribution guidance.

Acceptance Criteria

  • Callers can use the action without passing version; it installs the latest stable release.
  • vN selects the highest stable SemVer release in that major and never selects a prerelease.
  • The documentation and tests make clear that v1 and later channels are forward-looking until those stable release lines exist; v0 can resolve the current release line.
  • A channel without a matching stable release fails with a clear error and does not replace an existing installation.
  • Exact release tags continue to work.
  • Bash and PowerShell produce equivalent results and use the resolved release tag throughout installation.
  • The action README and generated installer copies are up to date.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions