diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 898c667..cfa9f65 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: release on: push: tags: - - 'v*' + - '*' permissions: contents: write diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 093f340..c76d558 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -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 diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..af57314 --- /dev/null +++ b/install.sh @@ -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!" \ No newline at end of file