2016-03-17 18:49:48 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
[[ -n $GITHUB_TOKEN ]] || { echo >&2 "GITHUB_TOKEN variable is undefined, please provide token"; exit 1; }
|
|
|
|
|
2016-04-13 22:03:41 +00:00
|
|
|
# Set OS specific asset ID and package name
|
|
|
|
case "$OSTYPE" in
|
|
|
|
linux*)
|
|
|
|
asset='1536045'
|
|
|
|
package='powershell_0.3.0-1_amd64.deb'
|
2016-04-13 22:36:15 +00:00
|
|
|
# Install curl and wget to download package
|
|
|
|
sudo apt-get install -y curl wget
|
2016-04-13 22:03:41 +00:00
|
|
|
;;
|
|
|
|
darwin*)
|
|
|
|
asset='1536063'
|
|
|
|
package='powershell-0.3.0.pkg'
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
exit 2 >&2 "$OSTYPE not supported!"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2016-03-17 18:49:48 +00:00
|
|
|
# Authorizes with read-only access to GitHub API
|
2016-04-11 19:41:58 +00:00
|
|
|
# Retrieves URL of v0.3.0 release asset
|
2016-03-17 18:49:48 +00:00
|
|
|
curl -s -i \
|
|
|
|
-H "Authorization: token $GITHUB_TOKEN " \
|
|
|
|
-H 'Accept: application/octet-stream' \
|
2016-04-13 22:03:41 +00:00
|
|
|
"https://api.github.com/repos/PowerShell/PowerShell/releases/assets/$asset" |
|
2016-03-17 18:49:48 +00:00
|
|
|
grep location |
|
|
|
|
sed 's/location: //g' |
|
2016-04-13 22:03:41 +00:00
|
|
|
wget -i - -O $package
|
|
|
|
|
|
|
|
# Installs PowerShell package
|
|
|
|
case "$OSTYPE" in
|
|
|
|
linux*)
|
2016-04-13 22:36:15 +00:00
|
|
|
# Install dependencies
|
|
|
|
sudo apt-get install -y libunwind8 libicu52
|
2016-04-13 22:03:41 +00:00
|
|
|
sudo dpkg -i ./$package
|
|
|
|
;;
|
|
|
|
darwin*)
|
|
|
|
sudo installer -pkg ./$package -target /
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
echo "Congratulations! PowerShell is now installed."
|