Skip to content

Installer with version #502

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

Merged
merged 2 commits into from Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions installer/bash-installer
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ CLI_CONFIG_DIR=".symfony5"
CLI_EXECUTABLE="symfony"
CLI_TMP_NAME="$CLI_EXECUTABLE-"$(date +"%s")
CLI_NAME="Symfony CLI"
CLI_DOWNLOAD_URL_PATTERN="https://github.com/symfony-cli/symfony-cli/releases/latest/download/symfony-cli_~platform~.tar.gz"
CLI_VERSION="${CLI_VERSION:-latest}"
CLI_DOWNLOAD_URL_LATEST_PATTERN="https://github.com/symfony-cli/symfony-cli/releases/latest/download/symfony-cli_~platform~.tar.gz"
CLI_DOWNLOAD_URL_VERSION_PATTERN="https://github.com/symfony-cli/symfony-cli/releases/download/v~version~/symfony-cli_~platform~.tar.gz"

CLI_TMPDIR="${TMPDIR:-/tmp}"

function output {
Expand Down Expand Up @@ -53,7 +56,6 @@ function output {
}

output "${CLI_NAME} installer" "heading"

binary_dest="${HOME}/${CLI_CONFIG_DIR}/bin"
custom_dir="false"

Expand All @@ -79,6 +81,16 @@ case $1 in
esac
done

output "\nSanity check" "heading"

# Check that the version is valid
if [[ "$CLI_VERSION" =~ ^[0-9]+(\.[0-9]+)*$ || "$CLI_VERSION" == 'latest' ]]; then
output " [*] Version has valid format" "success"
else
output " [ ] ERROR: Version has invalid format." "error"
exit 1
fi

# Run environment checks.
output "\nEnvironment check" "heading"

Expand Down Expand Up @@ -163,14 +175,19 @@ platform="${kernel}_${machine}"
# The necessary checks have passed. Start downloading the right version.
output "\nDownload" "heading"

latest_url=${CLI_DOWNLOAD_URL_PATTERN/~platform~/${platform}}
output " Downloading ${latest_url}...";
download_url="${CLI_DOWNLOAD_URL_LATEST_PATTERN}"
if [[ "$CLI_VERSION" != 'latest' ]]; then
download_url=${CLI_DOWNLOAD_URL_VERSION_PATTERN/~version~/${CLI_VERSION}}
fi

download_url=${download_url/~platform~/${platform}}
output " Downloading ${download_url}...";
case $downloader in
"curl")
curl --fail --location "${latest_url}" > "${CLI_TMPDIR}/${CLI_TMP_NAME}.tar.gz"
curl --fail --location "${download_url}" > "${CLI_TMPDIR}/${CLI_TMP_NAME}.tar.gz"
;;
"wget")
wget -q --show-progress "${latest_url}" -O "${CLI_TMPDIR}/${CLI_TMP_NAME}.tar.gz"
wget -q --show-progress "${download_url}" -O "${CLI_TMPDIR}/${CLI_TMP_NAME}.tar.gz"
;;
esac

Expand Down