Skip to content

Commit

Permalink
build: Improve install scripts. (#1096)
Browse files Browse the repository at this point in the history
* Update moon.

* Update proto.

* Fixes.

* Test versions.
  • Loading branch information
milesj committed Oct 5, 2023
1 parent fc88425 commit cc380ea
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ jobs:
# Unix
- run: bash ./website/static/install/moon.sh
if: ${{ runner.os != 'Windows' }}
- run: bash ./website/static/install/moon.sh 1.14.0
if: ${{ runner.os != 'Windows' }}
- run: bash ./website/static/install/proto.sh
if: ${{ runner.os != 'Windows' }}
env:
SHELL: bash
- run: bash ./website/static/install/proto.sh 0.19.0
if: ${{ runner.os != 'Windows' }}
# Windows
- run: pwsh.exe ./website/static/install/moon.ps1
if: ${{ runner.os == 'Windows' }}
- run: pwsh.exe ./website/static/install/moon.ps1 1.14.0
if: ${{ runner.os == 'Windows' }}
- run: pwsh.exe ./website/static/install/proto.ps1
if: ${{ runner.os == 'Windows' }}
env:
SHELL: powershell
- run: pwsh.exe ./website/static/install/proto.ps1 0.19.0
if: ${{ runner.os == 'Windows' }}
7 changes: 6 additions & 1 deletion website/static/install/moon.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ $DownloadUrl = if ($Version -eq "latest") {
"https://github.com/moonrepo/moon/releases/download/v${Version}/${Target}"
}

$InstallDir = "${Home}\.moon\bin"
$InstallDir = if ($env:MOON_INSTALL_DIR) {
$env:MOON_INSTALL_DIR
} else {
"${Home}\.moon\bin"
}

$BinPath = "${InstallDir}\moon.exe"

if (!(Test-Path $InstallDir)) {
Expand Down
27 changes: 13 additions & 14 deletions website/static/install/moon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
# Thanks to Deno for the original script:
# https://github.com/denoland/deno_install/blob/master/install.sh

set -e
set -eo pipefail

bin="moon"
arch=$(uname -sm)
version="${1:-latest}"

if [ "$OS" = "Windows_NT" ]; then
if [[ "$OS" == "Windows_NT" ]]; then
target="moon-x86_64-pc-windows-msvc.exe"
bin="moon.exe"
else
Expand Down Expand Up @@ -43,13 +43,18 @@ else
is_wsl=false
fi

if [ $# -eq 0 ]; then
if [[ "$version" == "latest" ]]; then
download_url="https://github.com/moonrepo/moon/releases/latest/download/${target}"
else
download_url="https://github.com/moonrepo/moon/releases/download/v${version}/${target}"
fi

install_dir="$HOME/.moon/bin"
if [ -z "$MOON_INSTALL_DIR" ]; then
install_dir="$HOME/.moon/bin"
else
install_dir="$MOON_INSTALL_DIR"
fi

bin_path="$install_dir/$bin"

if [ ! -d "$install_dir" ]; then
Expand All @@ -60,19 +65,13 @@ curl --fail --location --progress-bar --output "$bin_path" "$download_url"
chmod +x "$bin_path"

echo "Successfully installed moon to $bin_path"

if ln -sf "$bin_path" "/usr/local/bin/$bin" &> /dev/null; then
echo "Run 'moon --help' to get started!"
else
echo "Manually update PATH in your shell to get started!"
echo
echo " export PATH=\"\$HOME/.moon/bin:\$PATH\""
fi

echo "Manually update PATH in your shell to get started!"
echo
echo " export PATH=\"$install_dir:\$PATH\""
echo
echo "Need help? Join our Discord https://discord.gg/qCh9MEynv2"

if [ "$MOON_DEBUG" = "true" ]; then
if [[ "$MOON_DEBUG" == "true" ]]; then
echo
echo "arch=$arch"
echo "target=$target"
Expand Down
10 changes: 5 additions & 5 deletions website/static/install/proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# Thanks to Deno for the original script:
# https://github.com/denoland/deno_install/blob/master/install.sh

set -e
set -eo pipefail

bin="proto"
arch=$(uname -sm)
version="${1:-latest}"
ext=".tar.xz"

if [ "$OS" = "Windows_NT" ]; then
if [[ "$OS" == "Windows_NT" ]]; then
target="proto_cli-x86_64-pc-windows-msvc"
bin="proto.exe"
ext=".zip"
Expand Down Expand Up @@ -43,7 +43,7 @@ else
is_wsl=false
fi

if [ $# -eq 0 ]; then
if [[ "$version" == "latest" ]]; then
download_url="https://github.com/moonrepo/proto/releases/latest/download/$target$ext"
else
download_url="https://github.com/moonrepo/proto/releases/download/v$version/$target$ext"
Expand All @@ -62,7 +62,7 @@ fi

curl --fail --location --progress-bar --output "$download_file" "$download_url"

if [ "$ext" = ".zip" ]; then
if [[ "$ext" == ".zip" ]]; then
unzip -d "$temp_dir" "$download_file"

# Unzip doesnt remove components folder
Expand Down Expand Up @@ -91,7 +91,7 @@ echo "Launch a new terminal window to start using proto!"
echo
echo "Need help? Join our Discord https://discord.gg/qCh9MEynv2"

if [ "$PROTO_DEBUG" = "true" ]; then
if [[ "$PROTO_DEBUG" == "true" ]]; then
echo
echo "arch=$arch"
echo "target=$target"
Expand Down

0 comments on commit cc380ea

Please sign in to comment.