-
-
Notifications
You must be signed in to change notification settings - Fork 395
Add support for mago tool as custom package #975
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
shivammathur
merged 6 commits into
main
from
copilot/fix-dd2d33a9-156f-4338-aab6-3134252b8b72
Jul 17, 2025
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8d11cf0
Initial plan
Copilot 26dc9b4
Add mago tool support as custom package
Copilot de4f59c
Address PR review feedback - simplify validation and remove license d…
Copilot 5581e61
Update test and README for mago tool - remove 'latest' from test and …
Copilot ec1e2c6
Fix mago extraction paths for binary location in subdirectories
Copilot 20169f8
Add -Force to Move-Item in mago.ps1 to handle workflow reruns
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| Function Get-MagoTag() { | ||
| $releases = 'https://github.com/carthage-software/mago/releases' | ||
| if("$mago_tag" -eq "latest") { | ||
| $mago_tag = (Get-File -Url $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1] | ||
| } else { | ||
| try { | ||
| [net.httpWebRequest] $request = [net.webRequest]::create("$releases/tag/$mago_tag") | ||
| $request.Method = "HEAD" | ||
| [net.httpWebResponse] $response = $request.getResponse() | ||
| $response.Close() | ||
| $mago_tag = "$mago_tag" | ||
| } catch { | ||
| $mago_tag = (Get-File -Url $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1] | ||
| } | ||
| } | ||
| return $mago_tag | ||
| } | ||
|
|
||
| Function Add-Mago() { | ||
| param( | ||
| [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'The mago version to be installed')] | ||
| [ValidatePattern('^latest$|^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$')] | ||
shivammathur marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| [string] $mago_tag | ||
| ) | ||
| $mago_tag = Get-MagoTag | ||
| $arch_name = 'x86_64' | ||
| if(-not([Environment]::Is64BitOperatingSystem)) { | ||
| $arch_name = 'i686' | ||
| } | ||
| $url = "https://github.com/carthage-software/mago/releases/download/$mago_tag/mago-$mago_tag-$arch_name-pc-windows-msvc.zip" | ||
| Get-File -Url $url -OutFile $bin_dir\mago.zip >$null 2>&1 | ||
| Expand-Archive -Path $bin_dir\mago.zip -DestinationPath $bin_dir\mago -Force >$null 2>&1 | ||
| Move-Item -Path $bin_dir\mago\mago.exe -Destination $bin_dir\mago.exe | ||
shivammathur marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Add-ToProfile $current_profile 'mago' "New-Alias mago $bin_dir\mago.exe" | ||
| Add-Log $tick "mago" "Added mago $mago_tag" | ||
| printf "$env:GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "mago" "Click to read the mago related license information" | ||
| Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/carthage-software/mago/main/LICENSE).Content | ||
| Write-Output "$env:END_GROUP" | ||
shivammathur marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
shivammathur marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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" | ||
shivammathur marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.