#!/bin/bash # Function to remove files, run yarn dist, and push snap package handle_directory() { local dir_name="$1" # Navigate to dir_name/dist and remove specific files cd "$dir_name/dist" sudo rm -r ./"$dir_name"* cd .. # Run packaging with yarn in the directory sudo yarn dist # If we are dealing with exodus, tezor, or ledgerlive, push the snap package if [[ "$dir_name" == "exodus" || "$dir_name" == "tezor" || "$dir_name" == "ledgerlive" ]]; then # Find the .snap file. Assumes there's only one snap file in the directory. SNAP_FILE=$(ls dist/"$dir_name"*.snap) if [ ! -z "$SNAP_FILE" ]; then snapcraft push "$SNAP_FILE" else echo "No snap file found for $dir_name to push." fi fi cd .. } # Logout from snapcraft and login again snapcraft logout snapcraft login --with /path/to/your/snapcraft.login # Handle each directory handle_directory exodus handle_directory tezor handle_directory ledgerlive # Logout from snapcraft at the end snapcraft logout