@devries-cameron20 / composio Mirror · read-only / commits / 70094d67c
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 20:45 UTC

feat\(ci\): programmatically retrieve latest release starting with "v*"

jkomyno committed Aug 30, 2025 at 23:44 UTC 70094d67c39e7b0ac91fa278072c63f39d93f290
1 file changed +64 -82
install.sh
+64 -82
@@ -101,8 +101,10 @@ if [[ $target = darwin-x64 ]]; then
101 fi
102 fi
103
104 -GITHUB=${GITHUB-"https://github.com"}
105 -github_repo="$GITHUB/ComposioHQ/composio"
104 +COMPOSIO_GITHUB_OWNER=${COMPOSIO_GITHUB_OWNER-"ComposioHQ"}
105 +COMPOSIO_GITHUB_REPO=${COMPOSIO_GITHUB_REPO-"composio"}
106 +COMPOSIO_GITHUB_URL=${COMPOSIO_GITHUB_URL-"https://github.com"}
107 +github_repo="$COMPOSIO_GITHUB_URL/$COMPOSIO_GITHUB_OWNER/$COMPOSIO_GITHUB_REPO"
108
109 exe_name=composio
110
@@ -110,28 +112,32 @@ exe_name=composio
112 if [[ $# = 0 ]]; then
113 info "Finding latest CLI release..."
114
113 - # Get the last 20 releases and find the latest one with CLI binaries
114 - releases_json=$(curl -s "https://api.github.com/repos/ComposioHQ/composio/releases?per_page=20")
115 - if [[ -z "$releases_json" ]]; then
116 - error "Failed to fetch releases from GitHub"
117 - fi
118 -
119 - version=""
120 - # Extract tag names and check each release for CLI binaries
121 - for tag in $(echo "$releases_json" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | head -20); do
122 - # Check if this release has CLI binaries by testing download URL
123 - test_url="$github_repo/releases/download/$tag/composio-$target.zip"
124 - if curl -s --head "$test_url" | grep -qE "(200 OK|302)"; then
125 - version="$tag"
126 - info "Found CLI release: $version"
127 - break
128 - fi
129 - done
115 + # Get the latest version tag using OS-specific grep patterns
116 + case $platform in
117 + 'Darwin'*)
118 + # BSD/MacOS: Use extended regex with -E
119 + version=$(git ls-remote --tags "$github_repo" \
120 + | awk -F'/' '{print $3}' \
121 + | grep -E "^v\d+\.\d+\.\d+.*" \
122 + | sort -V \
123 + | tail -n1)
124 + ;;
125 + *)
126 + # Unix/Linux: Use Perl-compatible regex with -P
127 + version=$(git ls-remote --tags "$github_repo" \
128 + | awk -F'/' '{print $3}' \
129 + | grep -P "^v\d+\.\d+\.\d+.*" \
130 + | sort -V \
131 + | tail -n1)
132 + ;;
133 + esac
134
135 if [[ -z "$version" ]]; then
132 - error "No CLI release found in the last 20 releases. Please specify a version manually."
136 + error "Failed to determine the latest version. Please specify a version manually."
137 fi
138
139 + info "Found latest version: $version"
140 +
141 composio_uri="$github_repo/releases/download/$version/composio-$target.zip"
142 else
143 version=$1
@@ -140,35 +146,31 @@ fi
146
147 info "Installing Composio CLI $version for $target"
148
143 -# Set up installation directory
144 -install_env=COMPOSIO_INSTALL
145 -bin_env=\$COMPOSIO_INSTALL/bin
149 +COMPOSIO_INSTALL_DIR=${COMPOSIO_INSTALL_DIR:-$HOME/.composio}
150 +exe=$COMPOSIO_INSTALL_DIR/composio
151
147 -install_dir=${!install_env:-$HOME/.composio}
148 -bin_dir=$install_dir/bin
149 -exe=$bin_dir/composio
150 -
151 -if [[ ! -d $bin_dir ]]; then
152 - mkdir -p "$bin_dir" ||
153 - error "Failed to create install directory \"$bin_dir\""
152 +if [[ ! -d $COMPOSIO_INSTALL_DIR ]]; then
153 + mkdir -p "$COMPOSIO_INSTALL_DIR" ||
154 + error "Failed to create install directory \"$COMPOSIO_INSTALL_DIR\""
155 fi
156
156 -# Download and extract
157 +# Download
158 info "Downloading Composio CLI..."
159 curl --fail --location --progress-bar --output "$exe.zip" "$composio_uri" ||
160 error "Failed to download Composio CLI from \"$composio_uri\""
161
162 +# Extract
163 info "Extracting Composio CLI..."
162 -unzip -oqd "$bin_dir" "$exe.zip" ||
164 +unzip -oqd "$COMPOSIO_INSTALL_DIR" "$exe.zip" ||
165 error 'Failed to extract Composio CLI'
166
167 # Move binary to final location
166 -if [[ -f "$bin_dir/composio-$target/$exe_name" ]]; then
167 - mv "$bin_dir/composio-$target/$exe_name" "$exe" ||
168 +if [[ -f "$COMPOSIO_INSTALL_DIR/composio-$target/$exe_name" ]]; then
169 + mv "$COMPOSIO_INSTALL_DIR/composio-$target/$exe_name" "$exe" ||
170 error 'Failed to move extracted binary to destination'
169 - rm -r "$bin_dir/composio-$target"
170 -elif [[ -f "$bin_dir/$exe_name" ]]; then
171 - mv "$bin_dir/$exe_name" "$exe" ||
171 + rm -r "$COMPOSIO_INSTALL_DIR/composio-$target"
172 +elif [[ -f "$COMPOSIO_INSTALL_DIR/$exe_name" ]]; then
173 + mv "$COMPOSIO_INSTALL_DIR/$exe_name" "$exe" ||
174 error 'Failed to move extracted binary to destination'
175 else
176 error 'Binary not found in extracted archive'
@@ -190,19 +192,13 @@ tildify() {
192
193 success "Composio CLI was installed successfully to $Bold_Green$(tildify "$exe")"
194
193 -# Check if composio is already in PATH
194 -if command -v composio >/dev/null; then
195 - echo "Run 'composio --help' to get started"
196 - exit
197 -fi
198 -
195 refresh_command=''
196
201 -tilde_bin_dir=$(tildify "$bin_dir")
202 -quoted_install_dir=\"${install_dir//\"/\\\"}\"
197 +tilde_bin_dir=$(tildify "$COMPOSIO_INSTALL_DIR")
198 +quoted_install_dir=\"${COMPOSIO_INSTALL_DIR//\"/\\\"}\"
199
200 if [[ $quoted_install_dir = \"$HOME/* ]]; then
205 - quoted_install_dir=${quoted_install_dir/$HOME\//\$HOME/}
201 + quoted_install_dir=${COMPOSIO_INSTALL_DIR/$HOME\//\$HOME/}
202 fi
203
204 echo
@@ -211,31 +207,28 @@ echo
207 case $(basename "$SHELL") in
208 fish)
209 commands=(
214 - "set --export $install_env $quoted_install_dir"
215 - "set --export PATH $bin_env \$PATH"
210 + "set --export COMPOSIO_INSTALL_DIR $COMPOSIO_INSTALL_DIR"
211 + "set --export PATH $COMPOSIO_INSTALL_DIR \$PATH"
212 )
213
214 fish_config=$HOME/.config/fish/config.fish
215 tilde_fish_config=$(tildify "$fish_config")
216
221 - # Create fish config directory and file if they don't exist
222 - if [[ ! -f $fish_config && -w $(dirname "$(dirname "$fish_config")") ]]; then
223 - mkdir -p "$(dirname "$fish_config")"
224 - touch "$fish_config"
225 - fi
226 -
217 if [[ -w $fish_config ]]; then
218 {
219 echo -e '\n# Composio CLI'
220 +
221 for command in "${commands[@]}"; do
222 echo "$command"
223 done
224 } >>"$fish_config"
225
226 info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_fish_config\""
227 +
228 refresh_command="source $tilde_fish_config"
229 else
230 echo "Manually add the directory to $tilde_fish_config (or similar):"
231 +
232 for command in "${commands[@]}"; do
233 info_bold " $command"
234 done
@@ -243,8 +236,8 @@ fish)
236 ;;
237 zsh)
238 commands=(
246 - "export $install_env=$quoted_install_dir"
247 - "export PATH=\"$bin_env:\$PATH\""
239 + "export COMPOSIO_INSTALL_DIR=$COMPOSIO_INSTALL_DIR"
240 + "export PATH=\"$COMPOSIO_INSTALL_DIR:\$PATH\""
241 )
242
243 zsh_config=$HOME/.zshrc
@@ -258,15 +251,18 @@ zsh)
251 if [[ -w $zsh_config ]]; then
252 {
253 echo -e '\n# Composio CLI'
254 +
255 for command in "${commands[@]}"; do
256 echo "$command"
257 done
258 } >>"$zsh_config"
259
260 info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_zsh_config\""
261 +
262 refresh_command="exec $SHELL"
263 else
264 echo "Manually add the directory to $tilde_zsh_config (or similar):"
265 +
266 for command in "${commands[@]}"; do
267 info_bold " $command"
268 done
@@ -296,32 +292,17 @@ bash)
292 for bash_config in "${bash_configs[@]}"; do
293 tilde_bash_config=$(tildify "$bash_config")
294
299 - # Check if file is writable OR if parent directory is writable (so we can create the file)
300 - if [[ -w "$bash_config" ]] || [[ ! -e "$bash_config" && -w "$(dirname "$bash_config")" ]]; then
301 - # For .bashrc, prepend the exports before any interactive checks
302 - if [[ "$bash_config" == *".bashrc" ]] && [[ -f "$bash_config" ]] && grep -q "case.*-.*in" "$bash_config"; then
303 - # Create a temporary file with our exports at the top
304 - temp_file=$(mktemp)
305 - {
306 - echo '# Composio CLI'
307 - for command in "${commands[@]}"; do
308 - echo "$command"
309 - done
310 - echo
311 - cat "$bash_config"
312 - } > "$temp_file"
313 - mv "$temp_file" "$bash_config"
314 - else
315 - # For other configs or if no interactive check found, append as before
316 - {
317 - echo -e '\n# Composio CLI'
318 - for command in "${commands[@]}"; do
319 - echo "$command"
320 - done
321 - } >>"$bash_config"
322 - fi
295 + if [[ -w $bash_config ]]; then
296 + {
297 + echo -e '\n# Composio CLI'
298 +
299 + for command in "${commands[@]}"; do
300 + echo "$command"
301 + done
302 + } >>"$bash_config"
303
304 info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_bash_config\""
305 +
306 refresh_command="source $bash_config"
307 set_manually=false
308 break
@@ -329,12 +310,14 @@ bash)
310 done
311
312 if [[ $set_manually = true ]]; then
332 - echo "Manually add the directory to ~/.bashrc (or similar):"
313 + echo "Manually add the directory to $tilde_bash_config (or similar):"
314 +
315 for command in "${commands[@]}"; do
316 info_bold " $command"
317 done
318 fi
319 ;;
320 +
321 *)
322 echo 'Manually add the directory to ~/.bashrc (or similar):'
323 info_bold " export $install_env=$quoted_install_dir"
@@ -352,4 +335,3 @@ fi
335
336 info_bold " composio --help"
337 info_bold " composio login"
355 -