@@ -41,15 +41,20 @@ case "$filename" in |
41 | 41 | ;; |
42 | 42 | esac |
43 | 43 |
|
44 | | -# Determine installation directory with priority order |
45 | | -if [ -n "${OPENCODE_INSTALL_DIR:-}" ]; then |
46 | | - INSTALL_DIR="$OPENCODE_INSTALL_DIR" |
47 | | -elif [ -n "${XDG_BIN_DIR:-}" ]; then |
48 | | - INSTALL_DIR="$XDG_BIN_DIR" |
49 | | -elif [ -d "$HOME/bin" ] || mkdir -p "$HOME/bin" 2>/dev/null; then |
50 | | - INSTALL_DIR="$HOME/bin" |
| 44 | +INSTALL_DIR=$HOME/.opencode/bin |
| 45 | +mkdir -p "$INSTALL_DIR" |
| 46 | + |
| 47 | +if [ -z "$requested_version" ]; then |
| 48 | + url="https://github.com/sst/opencode/releases/latest/download/$filename" |
| 49 | + specific_version=$(curl -s https://api.github.com/repos/sst/opencode/releases/latest | awk -F'"' '/"tag_name": "/ {gsub(/^v/, "", $4); print $4}') |
| 50 | + |
| 51 | + if [[ $? -ne 0 || -z "$specific_version" ]]; then |
| 52 | + echo "${RED}Failed to fetch version information${NC}" |
| 53 | + exit 1 |
| 54 | + fi |
51 | 55 | else |
52 | | - INSTALL_DIR="$HOME/.opencode/bin" |
| 56 | + url="https://github.com/sst/opencode/releases/download/v${requested_version}/$filename" |
| 57 | + specific_version=$requested_version |
53 | 58 | fi |
54 | 59 |
|
55 | 60 | print_message() { |
@@ -66,23 +71,6 @@ print_message() { |
66 | 71 | echo -e "${color}${message}${NC}" |
67 | 72 | } |
68 | 73 |
|
69 | | -mkdir -p "$INSTALL_DIR" |
70 | | - |
71 | | -print_message info "Installing to: ${YELLOW}$INSTALL_DIR${GREEN}" |
72 | | - |
73 | | -if [ -z "$requested_version" ]; then |
74 | | - url="https://github.com/sst/opencode/releases/latest/download/$filename" |
75 | | - specific_version=$(curl -s https://api.github.com/repos/sst/opencode/releases/latest | awk -F'"' '/"tag_name": "/ {gsub(/^v/, "", $4); print $4}') |
76 | | - |
77 | | - if [[ $? -ne 0 || -z "$specific_version" ]]; then |
78 | | - echo "${RED}Failed to fetch version information${NC}" |
79 | | - exit 1 |
80 | | - fi |
81 | | -else |
82 | | - url="https://github.com/sst/opencode/releases/download/v${requested_version}/$filename" |
83 | | - specific_version=$requested_version |
84 | | -fi |
85 | | - |
86 | 74 | check_version() { |
87 | 75 | if command -v opencode >/dev/null 2>&1; then |
88 | 76 | opencode_path=$(which opencode) |
@@ -198,4 +186,3 @@ if [ -n "${GITHUB_ACTIONS-}" ] && [ "${GITHUB_ACTIONS}" == "true" ]; then |
198 | 186 | echo "$INSTALL_DIR" >> $GITHUB_PATH |
199 | 187 | print_message info "Added $INSTALL_DIR to \$GITHUB_PATH" |
200 | 188 | fi |
201 | | - |