tummychow / git-absorb

git commit --fixup, but automatic
https://crates.io/crates/git-absorb
BSD 3-Clause "New" or "Revised" License
3.35k stars 59 forks source link

update script #77

Closed Konfekt closed 1 year ago

Konfekt commented 1 year ago

For those distributions without a package, here's a simple update script of a folder ~/bin/git-absorb:

#!/usr/bin/env sh

# debug output and exit on error or use of undeclared variable or pipe error:
set -o xtrace -o errtrace -o errexit -o nounset -o pipefail

latest_tag="$(curl --location --head https://github.com/tummychow/git-absorb/releases/latest | grep -i location: | sed 's/^.*\/tag\/\([^\/]*\)\r$/\1/')"
filename="git-absorb-${latest_tag}-x86_64-unknown-linux-musl.tar.gz"
uri_to_download="https://github.com/tummychow/git-absorb/releases/download/${latest_tag}/${filename}"

{
cd "$(mktemp --directory "${TMPDIR:-/tmp}/git-absorb-update.XXXXXXXXXX")"
    curl --fail --show-error --remote-name --location "$uri_to_download"
    tar xf "$filename"
    cp -ru "git-absorb-${latest_tag}-x86_64-unknown-linux-musl/"* "$HOME/bin/git-absorb"/

    tmpdir="$PWD"
    trap 'rm -rf "$tmpdir"' EXIT
}

if [ ! -x "$HOME/bin/git-absorb/git-absorb" ]; then
    echo '"git-absorb" was not successfully installed!' >&2
    exit 2
fi