-
Notifications
You must be signed in to change notification settings - Fork 1
/
z.sh
54 lines (44 loc) · 1.68 KB
/
z.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
52
53
54
#!/bin/bash
# Check if gh command-line tool is installed
if ! command -v gh &> /dev/null; then
echo "GitHub CLI 'gh' not found. Downloading and installing..."
wget https://github.com/cli/cli/releases/download/v2.40.1/gh_2.40.1_linux_amd64.tar.gz
tar -xvf gh_2.40.1_linux_amd64.tar.gz
sudo mv gh_*_linux_amd64/bin/gh /usr/local/bin/
echo "GitHub CLI 'gh' installed successfully."
else
echo "GitHub CLI 'gh' is already installed."
fi
# Check if user is already authenticated
if ! gh auth status &> /dev/null; then
# User not authenticated, perform login
gh auth login
else
echo "Already authenticated with GitHub."
fi
# Set the version with default format
version="crDroidAndroid-14.0-$(date '+%Y%m%d')"
# Check if the tag already exists
while gh release view "$version" &> /dev/null; do
# Tag exists, increment the version number
echo "Tag $version already exists. Incrementing version number..."
version="${version%-*}-$((${version##*-} + 1))-$(date '+%Y%m%d')"
done
# Create the new tag and push it to GitHub
git tag -a "$version" -m "Release $version"
git push origin "$version" --force
# Initialize an array to store the filenames
declare -a filenames
# Uncomment the following block if you want to upload all .zip and .img files in the current directory
filenames=(*.zip *.img)
# 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."