Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSVersionTable should have Release type field denoting Prerelease, Stable, or LTS #23984

Open
ThomasNieto opened this issue Jun 24, 2024 · 4 comments
Labels
Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group.

Comments

@ThomasNieto
Copy link
Contributor

Summary of the new feature / enhancement

$PSVersionTable should have a property (Release) field denoting if the version is Prerelease, Stable, or LTS.

Proposed technical implementation details (optional)

$PSVersionTable.Release = if ($PSVersionTable.PSVersion.PreReleaseLabel) {
    'Prerelease'
} elseif ($PSVersionTable.PSVersion.Minor % 2 -eq 0) {
    'LTS'
} else {
    'Stable'
}
@ThomasNieto ThomasNieto added Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group. labels Jun 24, 2024
@237dmitry
Copy link

$PSVersionTable.PSVersion.PreReleaseLabel

Why define the release status using PreReleasLabel property when $PSVersionTable.Release returns it?

$ $PSVersionTable.Release
Prerelease

@mklement0
Copy link
Contributor

mklement0 commented Jun 24, 2024

@237dmitry, there is currently no $PSVersionTable.Release entry - except after running the code in the initial post (I don't know how easy it would be to enforce it, but conceptually, $PSVersionTable should be read-only).

@ThomasNieto, I like the idea, but I suggest the following tweaks:

  • To lessen ambiguity and to align with existing key names, I suggest PSReleaseType as the name.
  • Also support detecting custom builds, such as during development (I'm not sure if there's a better way to detect them than what I use below).
  • Use an enum type for the values, for type safety in programmatic use.

Thus, something like the following:

enum PSReleaseType {
  Stable = 0
  LTS
  Prerelease
  Custom
}

$PSVersionTable.PSReleaseType = 
  if ($PSVersionTable.GitCommitId -like '*-*-*') {  # There may be  a better way to detect this
    [PSReleaseType]::Custom
  } elseif ($PSVersionTable.PSVersion.PreReleaseLabel) {
    [PSReleaseType]::Prerelease
  } elseif ($PSVersionTable.PSVersion.Minor % 2 -eq 0) {
    [PSReleaseType]::LTS
  } else {
    [PSReleaseType]::Stable
  }

@237dmitry
Copy link

there is currently no $PSVersionTable.Release entry - except after running the code in the initial post (I don't know how easy it would be to enforce it, but conceptually, $PSVersionTable should be read-only).

Yes, I actually ran the original code and then looked at the output of $PSVersionTable

ArcoLinux_2024-06-24_20-55-12

I agree it should be read-only

@ThomasNieto ThomasNieto changed the title PSVersionTable should have Release field denoting Prerelease, Stable, or LTS PSVersionTable should have Release type field denoting Prerelease, Stable, or LTS Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group.
Projects
None yet
Development

No branches or pull requests

3 participants