Skip to content

Commit

Permalink
feat: installer
Browse files Browse the repository at this point in the history
  • Loading branch information
ekkinox committed Apr 12, 2023
1 parent 857b223 commit 07bf4b9
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: release
on:
push:
tags:
- 'v*'
- '*'

permissions:
contents: write
Expand Down
2 changes: 0 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
- go mod tidy
Expand Down
63 changes: 63 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

REPOOWNER="ekkinox"
REPONAME="yo"
RELEASETAG=$(curl -s "https://api.github.com/repos/$REPOOWNER/$REPONAME/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

KERNEL=$(uname -s 2>/dev/null || /usr/bin/uname -s)
case ${KERNEL} in
"Linux"|"linux")
KERNEL="linux"
;;
"Darwin"|"darwin")
KERNEL="darwin"
;;
*)
output "OS '${KERNEL}' not supported" "error"
exit 1
;;
esac


MACHINE=$(uname -m 2>/dev/null || /usr/bin/uname -m)
case ${MACHINE} in
arm|armv7*)
MACHINE="arm"
;;
aarch64*|armv8*|arm64)
MACHINE="arm64"
;;
i[36]86)
MACHINE="386"
if [ "darwin" = "${KERNEL}" ]; then
output " [ ] Your architecture (${MACHINE}) is not supported anymore" "error"
exit 1
fi
;;
x86_64)
MACHINE="amd64"
;;
*)
output " [ ] Your architecture (${MACHINE}) is not currently supported" "error"
exit 1
;;
esac

# Define the location of the binary and the directory to install it to (can be overridden by the user)
BINNAME="${BINNAME:-yo}"
BINDIR="${BINDIR:-/usr/local/bin}"

# Define the URLs for the release assets
URL="https://github.com/$REPOOWNER/$REPONAME/releases/download/yo_${RELEASETAG}_${KERNEL}_${MACHINE}.tar.gz"

echo "Downloading from $URL"
echo

curl -q --fail --location --progress-bar "$URL"
cd "$bin_dir"
tar xzf "$exe.tar.gz"
chmod +x "$exe"
rm "$exe.tar.gz"

echo
echo "Installation complete!"

0 comments on commit 07bf4b9

Please sign in to comment.