mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-09-10 14:54:06 +07:00
Add mago tool support as custom package
Co-authored-by: shivammathur <1571086+shivammathur@users.noreply.github.com>
This commit is contained in:
32
src/scripts/tools/mago.sh
Normal file
32
src/scripts/tools/mago.sh
Normal file
@ -0,0 +1,32 @@
|
||||
get_mago_tag() {
|
||||
if [ "$mago_tag" = "latest" ]; then
|
||||
mago_tag=$(get -s -n "" https://github.com/carthage-software/mago/releases/latest 2<&1 | grep -m 1 -Eo "tag/([0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2)
|
||||
else
|
||||
status_code=$(get -v -n /tmp/mago.tmp "https://github.com/carthage-software/mago/releases/tag/$mago_tag")
|
||||
if [ "$status_code" = "200" ]; then
|
||||
mago_tag="$mago_tag"
|
||||
else
|
||||
mago_tag=$(get -s -n "" https://github.com/carthage-software/mago/releases/latest 2<&1 | grep -m 1 -Eo "tag/([0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2)
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
add_mago() {
|
||||
mago_tag=$1
|
||||
get_mago_tag
|
||||
(
|
||||
platform='unknown-linux-gnu'
|
||||
[ "$(uname -s)" = "Darwin" ] && platform='apple-darwin'
|
||||
arch="$(uname -m)"
|
||||
[[ "$arch" = 'arm64' || "$arch" = 'aarch64' ]] && arch='aarch64'
|
||||
[[ "$arch" = 'x86_64' || "$arch" = 'amd64' ]] && arch='x86_64'
|
||||
get -q -n /tmp/mago.tar.gz "https://github.com/carthage-software/mago/releases/download/$mago_tag/mago-$mago_tag-$arch-$platform.tar.gz"
|
||||
sudo tar -xzf /tmp/mago.tar.gz -C /tmp/
|
||||
sudo mv /tmp/mago /usr/local/bin/mago
|
||||
sudo chmod +x /usr/local/bin/mago
|
||||
) >/dev/null 2>&1
|
||||
add_log "${tick:?}" "mago" "Added mago $mago_tag"
|
||||
printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "mago" "Click to read the mago related license information"
|
||||
curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/carthage-software/mago/main/LICENSE
|
||||
echo "$END_GROUP"
|
||||
}
|
Reference in New Issue
Block a user