forked from Meghthedev/Releases
-
Notifications
You must be signed in to change notification settings - Fork 2
/
multi_upload.sh
executable file
·51 lines (40 loc) · 1.43 KB
/
multi_upload.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Check if gh command-line tool is installed
if ! command -v gh &> /dev/null; then
echo "Error: GitHub CLI (gh) is not installed. Please install it from https://cli.github.com/ and try again."
exit 1
fi
# Ensure the user is authenticated with GitHub
gh auth login
# Ask for the release tag name
read -p "Enter the release tag name: " version
# Check if the tag already exists
if git rev-parse "$version" &> /dev/null; then
echo "Error: The release tag '$version' already exists."
exit 1
fi
# Create the tag and push it to GitHub
git tag -a "$version" -m "Release $version"
git push origin "$version"
# Ask the user if they want to upload all .zip files or provide filenames
read -p "Do you want to upload all .zip files in the current directory? (y/n): " upload_all
# Initialize an array to store the filenames
declare -a filenames
if [[ "$upload_all" =~ ^[Yy]$ ]]; then
# Upload all .zip files in the current directory
filenames=(*.zip)
else
# Ask the user to input the filenames
read -p "Enter the filenames (separated by spaces): " -a filenames
fi
# Create the release on GitHub
if ! gh release create "$version" --title "Release $version" --notes "Release notes"; then
echo "Error: Failed to create the release."
exit 1
fi
# Upload the files to the release
for filename in "${filenames[@]}"; do
gh release upload "$version" "$filename" --clobber
done
# Display success message
echo "Files uploaded successfully."