Skip to content

Commit

Permalink
feat: detect latest github release
Browse files Browse the repository at this point in the history
  • Loading branch information
Ph0enixKM committed May 23, 2024
1 parent 6c3b5a1 commit de55e3c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion setup/install.ab
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { has_failed, includes, exit, chars } from "std"

let name = "AmberNative"
let target = "amber"
let tag = "0.3.1-alpha"
let place = "/opt/amber"
let bins_folder = "/usr/local/bin"
let agent = has_failed("uname -a")
Expand All @@ -11,6 +10,17 @@ let agent = has_failed("uname -a")

echo ""

fun get_latest_release_tag() {
let tag_url = "https://api.github.com/repos/Ph0enixKM/{name}/releases/latest"
let tag_json = silent $curl -L "{tag_url}"$?
// Get the tag name from the JSON
let tag = $echo "\${nameof tag_json}" \
| grep -Eo "tag_name\\"[^\\"]*\\"([^\\"]+)\\"" \
| grep -Eo "\\"[^\\"]+\\"\$" \
| grep -Eo "[^\\"\\s]+"$?
return tag
}

main(args) {
// Determine OS type
let os_type = $uname -s$ failed {
Expand Down Expand Up @@ -86,6 +96,12 @@ main(args) {
}
}

let tag = get_latest_release_tag() failed {
echo "Failed to get the latest release tag."
echo "Please try again or use another download method."
exit(1)
}

// Set the download link
let url = "https://github.com/Ph0enixKM/{name}/releases/download/{tag}/amber_{os}_{arch}"

Expand Down

0 comments on commit de55e3c

Please sign in to comment.