Powershell: Publish Current Version Info Only in tools/currentversion.sh & tools/currentversion.ps1

Created on 10 Apr 2017  路  12Comments  路  Source: PowerShell/PowerShell

I am writing some scripts that need to pull the latest version of PowerShell (whether or not they are setup in a repo) - similar to tools/download.sh.

It would be great if you published something like tools/currentversion.sh (and currentversion.ps1) that contained:
release=v6.0.0-alpha.18
build=18

Then I could download and run that shell script in my code (at my own risk) and be able to pull the current version.

Other data might be helpful as well (maybe actual package files per platform target and their checksums?) - but at a minimum being able to auto-detect the current version would be very helpful!

Issue-Discussion Resolution-Fixed WG-Engine

Most helpful comment

Did a PR to make download.sh detect version rather than have hard codes: https://github.com/PowerShell/PowerShell/pull/3535

All 12 comments

Related Issues #1635 #1395
@DarwinJS Please clarify what do you use "current version" for? I believe that preferred way is always to test the availability of features.

@iSazonov - it would allow me to build something similar to download.sh - which pulls the latest version of PowerShell for the target environment - but I would be in control of the details of what happens in the download.sh equivalent.

So within my script I would call something similar to this:

wget -O latestsversion.sh https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/latestversion.sh
. latestversion.sh

For languages other than bash, the file could be pulled and parsed as key value pairs.

Can you use nuget?

@iSazonov - I wouldn't be interested in using nuget for Linux. As far as Windows goes, I am already the maintainer for the Chocolatey package for PowerShell core: https://chocolatey.org/packages/powershell-core and can pull down chocolatey and PowerShell core with a oneliner if it is needed.

I'm not sure that it makes sense to have yet another script to manually update every time we do a release.

(Invoke-RestMethod https://api.github.com/repos/powershell/powershell/releases/latest).tag_name should give you the latest version string today. If you need something else that's not provided there, I'd love to get some more info.

@joeyaiello - this script is to bootstrap PowerShell itself so I can't use invoke-restmethod - do you know a simple a bash equivalent using curl or wget? I think wget may be more prevalent - I am having to install it on Ubuntu.

This is on machines that were freshly built and like download.sh I want to use only utilities already on the system - not have to install git or other utilities just to pull the tag.

Thanks for any help!

curl will get you the JSON block just fine, but then you have to parse it. It's relatively painless if you've got Python, but if you're stuck with basic coreutils, check this out: http://stackoverflow.com/questions/1955505/parsing-json-with-unix-tools

Great link - I was able to craft a solution based on a pure curl + sed example!

FYI - I thought your build chain would have been capable of writing an updated currentversion.sh - wouldn't want to rely on someone remembering to update a manually edited file.

@DarwinJS It seems #3521 is related.

Did a PR to make download.sh detect version rather than have hard codes: https://github.com/PowerShell/PowerShell/pull/3535

The Issue was resolved in #3608

The best resolution is actually in: https://github.com/PowerShell/PowerShell/issues/3586

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SteveL-MSFT picture SteveL-MSFT  路  3Comments

garegin16 picture garegin16  路  3Comments

rkeithhill picture rkeithhill  路  3Comments

concentrateddon picture concentrateddon  路  3Comments

aragula12 picture aragula12  路  3Comments