1+ #! /bin/bash
2+ set -e
3+
4+ # Default to current latest
5+ VERSION=" $HTTP_SERVER_RS_VERSION "
6+ if [ " $VERSION " = " " ]; then
7+ VERSION=$( curl --silent " https://api.github.com/repos/alshdavid/http-server-rs/releases/latest" | jq -r ' .tag_name' )
8+ fi
9+
10+ if [ " $VERSION " = " " ]; then
11+ echo " Unable to fetch version"
12+ exit 1
13+ fi
14+
15+ # Default to home directory
16+ if [ " $OUT_DIR " = " " ]; then
17+ OUT_DIR=" $HOME /.local/http-server-rs"
18+ fi
19+
20+ >&2 echo VERSION: $VERSION
21+ >&2 echo OUT_DIR: $OUT_DIR
22+
23+ ARCH=" "
24+ case " $( uname -m) " in
25+ x86_64 | x86-64 | x64 | amd64) ARCH=" amd64" ;;
26+ aarch64 | arm64) ARCH=" arm64" ;;
27+ * ) ARCH=" " ;;
28+ esac
29+
30+ OS=" "
31+ case " $( uname -s) " in
32+ Darwin) OS=" macos" ;;
33+ Linux) OS=" linux" ;;
34+ MINGW64_NT* | Windows_NT) OS=" windows" ;;
35+ * ) OS=" " ;;
36+ esac
37+
38+ >&2 echo ARCH: $ARCH
39+ >&2 echo OS: $OS
40+
41+ URL=" "
42+ case " $OS -$ARCH " in
43+ linux-amd64) URL=" https://github.com/alshdavid/http-server-rs/releases/download/${VERSION} /http-server-linux-amd64.tar.gz" ;;
44+ linux-arm64) URL=" https://github.com/alshdavid/http-server-rs/releases/download/${VERSION} /http-server-linux-arm64.tar.gz" ;;
45+ macos-amd64) URL=" https://github.com/alshdavid/http-server-rs/releases/download/${VERSION} /http-server-macos-amd64.tar.gz" ;;
46+ macos-arm64) URL=" https://github.com/alshdavid/http-server-rs/releases/download/${VERSION} /http-server-macos-arm64.tar.gz" ;;
47+ windows-amd64) URL=" https://github.com/alshdavid/http-server-rs/releases/download/${VERSION} /http-server-windows-amd64.tar.gz" ;;
48+ windows-arm64) URL=" https://github.com/alshdavid/http-server-rs/releases/download/${VERSION} /http-server-windows-arm64.tar.gz" ;;
49+ esac
50+
51+ if [ " $URL " = " " ]; then
52+ echo " Cannot find archive"
53+ exit 1
54+ fi
55+
56+ >&2 echo URL: $URL
57+
58+ test -d $OUT_DIR && rm -rf $OUT_DIR
59+ mkdir -p $OUT_DIR
60+
61+ if [ -z " ${URL##* .tar.gz} " ]; then
62+ curl -s -L --url $URL | tar -xzf - -C $OUT_DIR
63+ fi
64+
65+ echo " export PATH=\" ${OUT_DIR} :\$ PATH\" "
66+
67+ if [ " $GITHUB_PATH " != " " ]; then
68+ echo " ${OUT_DIR} " >> $GITHUB_PATH
69+ fi
0 commit comments