Skip to content

Instantly share code, notes, and snippets.

@svor
Last active October 23, 2024 07:51
Show Gist options
  • Save svor/d818ea04921f13a5a89041d564e119aa to your computer and use it in GitHub Desktop.
Save svor/d818ea04921f13a5a89041d564e119aa to your computer and use it in GitHub Desktop.
#!/bin/bash
# Path to the extensions.txt file
EXTENSIONS_FILE="extensions.txt"
listOfPublishers=()
containsElement () { for e in "${@:2}"; do [[ "$e" = "$1" ]] && return 0; done; return 1; }
# Read the file line by line
while IFS= read -r line; do
# Extract the vsix file name from the URL
vsix_url="$line"
vsix_filename=$(basename "$vsix_url")
# Download the vsix file into the /tmp directory
echo "Downloading $vsix_url"
wget -q "$vsix_url" -O "/tmp/$vsix_filename"
# Extract namespace_name (everything before the first .)
namespace_name=$(echo "$vsix_filename" | cut -d. -f1)
# Extract extension_name (everything between namespace_name and .vsix)
extension_name=$(echo "$vsix_filename" | sed "s/$namespace_name\.//" | sed 's/\.vsix$//')
# Execute ovsx commands
# check if publisher is in the list of publishers
if ! containsElement "${namespace_name}" "${listOfPublishers[@]}"; then
listOfPublishers+=("${namespace_name}")
# create namespace
ovsx create-namespace "$namespace_name"
fi
# publish extension
ovsx publish "/tmp/$vsix_filename"
echo "Published $extension_name to $namespace_name"
# remove the downloaded file
rm "/tmp/$vsix_filename"
done < "$EXTENSIONS_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment