Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
run: |
cp src/wd.sh wd
sed -i 's/WD_VERSION="dev"/WD_VERSION="'"${{ github.ref_name }}"'"/' wd
sed -i 's/VERSION="latest"/VERSION="'"${{ github.ref_name }}"'"/' install.sh
sha256sum wd > wd.sha256

- name: Upload release assets
Expand Down
19 changes: 11 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eu
# wd installer
# Usage: curl -fsSL https://github.com/shokkunrf/wd/releases/latest/download/install.sh | sh

REPO="shokkunrf/wd"
VERSION="latest"
INSTALL_DIR="${WD_INSTALL_DIR:-/usr/local/bin}"

die() {
Expand Down Expand Up @@ -52,14 +52,17 @@ verify_checksum() {
main() {
echo "Installing wd..."

# Get latest release tag
_latest=$(fetch "https://api.github.com/repos/$REPO/releases/latest" | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p')
if [ -z "$_latest" ]; then
die "Failed to detect latest release"
if [ "$VERSION" = "latest" ]; then
_version=$(fetch "https://api.github.com/repos/shokkunrf/wd/releases/latest" | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p')
if [ -z "$_version" ]; then
die "Failed to detect latest release"
fi
else
_version="$VERSION"
fi
echo "Latest version: $_latest"
echo "Installing version: $_version"

_base_url="https://github.com/$REPO/releases/download/$_latest"
_base_url="https://github.com/shokkunrf/wd/releases/download/$_version"
_tmpdir=$(mktemp -d)
trap 'rm -rf "$_tmpdir"' EXIT

Expand All @@ -83,7 +86,7 @@ main() {
sudo cp "$_tmpdir/wd" "$INSTALL_DIR/wd"
fi

echo "wd $_latest installed to $INSTALL_DIR/wd"
echo "wd $VERSION installed to $INSTALL_DIR/wd"
"$INSTALL_DIR/wd" --version
}

Expand Down