-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up: Removed all previous commits and reset commit date to the p…
…roject's creation date.
- Loading branch information
0 parents
commit abb1808
Showing
7 changed files
with
999 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Release miunlock | ||
|
||
on: | ||
push: | ||
paths: | ||
- MiUnlockTool.py | ||
pull_request: | ||
paths: | ||
- MiUnlockTool.py | ||
workflow_dispatch: | ||
|
||
jobs: | ||
linux: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get version | ||
id: get_version | ||
run: | | ||
version=$(grep -oP '(?<=version = ")(.*)(?=")' MiUnlockTool.py) | ||
echo "VERSION=$version" >> $GITHUB_ENV | ||
- name: tag | ||
run: | | ||
if ! git ls-remote --tags origin | grep -q "$VERSION"; then | ||
git tag "$VERSION" | ||
git push origin "$VERSION" | ||
else | ||
echo "Tag $VERSION already exists, skipping tag creation." | ||
fi | ||
- name: release | ||
run: | | ||
if ! gh release view $VERSION; then | ||
gh release create $VERSION --title "Release $VERSION" | ||
else | ||
echo "Release $VERSION already exists, skipping release creation." | ||
fi | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
VERSION: ${{ env.VERSION }} | ||
|
||
- name: upload | ||
run: | | ||
if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then | ||
if git diff --name-only HEAD~1 HEAD | grep -q "MiUnlockTool.py"; then | ||
commit_message=$(git log -1 --pretty=format:"%s" -- MiUnlockTool.py) | ||
old_notes=$(gh release view $VERSION --json body -q '.body') | ||
if [ -z "$old_notes" ]; then | ||
notes="$commit_message" | ||
else | ||
if [ "$old_notes" = "$commit_message" ]; then | ||
notes="$commit_message" | ||
else | ||
notes="${old_notes}\n$commit_message" | ||
fi | ||
fi | ||
new_notes=$(echo -e "$notes") | ||
gh release edit $VERSION --notes "$new_notes" | ||
else | ||
echo "MiUnlockTool.py was not modified in the last commit, skipping notes update." | ||
fi | ||
else | ||
echo "No previous commit to compare with." | ||
fi | ||
gh release upload $VERSION ./MiUnlockTool.py --clobber | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
VERSION: ${{ env.VERSION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/venv | ||
/platform-tools | ||
|
||
/data.json | ||
/encryptData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
#!/data/data/com.termux/files/usr/bin/bash | ||
|
||
echo | ||
|
||
if [ ! -d "/data/data/com.termux.api" ]; then | ||
echo -e "\ncom.termux.api app is not installed\nPlease install it first\n" | ||
exit 1 | ||
fi | ||
|
||
arch=$(uname -m) | ||
|
||
if [ "$arch" = "aarch64" ]; then | ||
arch="aarch64" | ||
elif [ "$arch" = "armv7l" ]; then | ||
arch="arm" | ||
elif [ "$arch" = "armv8l" ]; then | ||
arch="arm" | ||
else | ||
echo -e "\nArchitecture $arch not supported\n" | ||
exit 1 | ||
fi | ||
|
||
echo -ne "\rurl check ..." | ||
|
||
main_repo=$(grep -E '^deb ' /data/data/com.termux/files/usr/etc/apt/sources.list | awk '{print $2}' | head -n 1) | ||
|
||
curl -s --retry 4 $main_repo > /dev/null | ||
exit_code=$? | ||
|
||
if [ $exit_code -eq 6 ]; then | ||
echo -e "\nRequest to $main_repo failed. Please check your internet connection.\n" | ||
exit 6 | ||
elif [ $exit_code -eq 35 ]; then | ||
echo -e "\nThe $main_repo is blocked in your current country.\n" | ||
exit 35 | ||
fi | ||
|
||
git_repo="https://raw.githubusercontent.com" | ||
|
||
curl -s --retry 4 $git_repo > /dev/null | ||
exit_code=$? | ||
|
||
if [ $exit_code -eq 6 ]; then | ||
echo -e "\nRequest to $git_repo failed. Please check your internet connection.\n" | ||
exit 6 | ||
elif [ $exit_code -eq 35 ]; then | ||
echo -e "\nThe $git_repo is blocked in your current country.\n" | ||
exit 35 | ||
fi | ||
|
||
echo -ne "\rapt update ..." | ||
apt update > /dev/null 2> >(grep -v "apt does not have a stable CLI interface") | ||
|
||
charit=-1 | ||
total=22 | ||
start_time=$(date +%s) | ||
|
||
_progress() { | ||
charit=$((charit + 1)) | ||
percentage=$((charit * 100 / total)) | ||
echo -ne "\rProgress: $charit/$total ($percentage%)" | ||
if [ $percentage -eq 100 ]; then | ||
end_time=$(date +%s) | ||
elapsed_time=$((end_time - start_time)) | ||
echo -ne "\rProgress: $charit/$total ($percentage%) Took: $elapsed_time seconds" | ||
else | ||
echo -ne "\rProgress: $charit/$total ($percentage%)" | ||
fi | ||
} | ||
|
||
_progress | ||
|
||
url="https://raw.githubusercontent.com/nohajc/nohajc.github.io/master/dists/termux/extras/binary-${arch}" | ||
|
||
get_version() { | ||
package_name="$1" | ||
local __resultvar=$2 | ||
|
||
version=$(curl -s "$url/Packages" | awk -v package="$package_name" ' | ||
$0 ~ "^Package: " package {found=1} | ||
found && /^Version:/ {print $2; exit} | ||
') | ||
eval $__resultvar="'$version'" | ||
} | ||
|
||
libprotobuf_version_c="" | ||
termux_adb_version_c="" | ||
|
||
get_version "libprotobuf-tadb-core" libprotobuf_version_c | ||
get_version "termux-adb" termux_adb_version_c | ||
|
||
libprotobuf_version_i=$(pkg show libprotobuf-tadb-core 2>/dev/null | grep Version | cut -d ' ' -f 2) | ||
termux_adb_version_i=$(pkg show termux-adb 2>/dev/null | grep Version | cut -d ' ' -f 2) | ||
|
||
# Function to compare versions without printing anything if the package is already updated | ||
compare_versions() { | ||
package_name="$1" | ||
available_version="$2" | ||
installed_version="$3" | ||
if [ "$installed_version" != "$available_version" ]; then | ||
curl -s -O "$url/${package_name}_${available_version}_${arch}.deb" | ||
dpkg --force-overwrite -i "${package_name}_${available_version}_${arch}.deb" >/dev/null 2>&1 | ||
rm -f "${package_name}_${available_version}_${arch}.deb" | ||
fi | ||
|
||
_progress | ||
|
||
} | ||
|
||
compare_versions "libprotobuf-tadb-core" "$libprotobuf_version_c" "$libprotobuf_version_i" | ||
compare_versions "termux-adb" "$termux_adb_version_c" "$termux_adb_version_i" | ||
|
||
ln -sf "$PREFIX/bin/termux-fastboot" "$PREFIX/bin/fastboot" && ln -sf "$PREFIX/bin/termux-adb" "$PREFIX/bin/adb" | ||
|
||
packages=( | ||
"openssl" | ||
"libffi" | ||
"abseil-cpp" | ||
"termux-api" | ||
"libusb" | ||
"brotli" | ||
"python" | ||
"python-pip" | ||
"libexpat" | ||
"pkg-config" | ||
"libc++" | ||
"zlib" | ||
"zstd" | ||
"liblz4" | ||
"tur-repo" | ||
"python-pycryptodomex" | ||
) | ||
|
||
for package in "${packages[@]}"; do | ||
installed=$(apt policy "$package" 2>/dev/null | grep 'Installed' | awk '{print $2}') | ||
candidate=$(apt policy "$package" 2>/dev/null | grep 'Candidate' | awk '{print $2}') | ||
if [ "$installed" != "$candidate" ]; then | ||
apt download "$package" >/dev/null 2>&1 | ||
dpkg --force-overwrite -i "${package}"*.deb >/dev/null 2>&1 | ||
rm -f "${package}"*.deb | ||
fi | ||
|
||
_progress | ||
|
||
done | ||
|
||
libs=( | ||
"urllib3" | ||
"requests" | ||
"colorama" | ||
) | ||
|
||
for lib in "${libs[@]}"; do | ||
installed_version=$(pip show "$lib" 2>/dev/null | grep Version | awk '{print $2}') | ||
latest_version=$(pip index versions "$lib" 2>/dev/null | grep 'LATEST:' | awk '{print $2}') | ||
if [ -z "$installed_version" ]; then | ||
pip install "$lib" -q | ||
elif [ "$installed_version" != "$latest_version" ]; then | ||
pip install --upgrade "$lib" -q | ||
fi | ||
|
||
_progress | ||
|
||
done | ||
|
||
curl -sSL -o "$PREFIX/bin/miunlock" https://github.com/offici5l/MiUnlockTool/releases/latest/download/MiUnlockTool.py && chmod +x "$PREFIX/bin/miunlock" | ||
|
||
_progress | ||
|
||
echo | ||
|
||
printf "\nuse command: \e[1;32mmiunlock\e[0m\n\n" |
Oops, something went wrong.