mirror of
https://github.com/LukeZGD/Legacy-iOS-Kit.git
synced 2024-11-23 16:39:17 +01:00
Fix update check
This commit is contained in:
parent
dff3dbdf6a
commit
643bb1b0f2
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@ -84,10 +84,10 @@ jobs:
|
|||||||
- name: Zip complete files
|
- name: Zip complete files
|
||||||
run: zip -r ${{ github.event.repository.name }}_complete_v${{ env.DATE }}.${{ env.COUNT }}.zip bin/ LICENSE resources/ restore.cmd restore.sh README.md
|
run: zip -r ${{ github.event.repository.name }}_complete_v${{ env.DATE }}.${{ env.COUNT }}.zip bin/ LICENSE resources/ restore.cmd restore.sh README.md
|
||||||
|
|
||||||
- name: Create this file to make upgrading backward-compatible
|
- name: Create this file to get latest git hash
|
||||||
run: |
|
run: |
|
||||||
echo "This file is for compatibility purposes only. Get Legacy-iOS-Kit_complete instead." > README.txt
|
echo "This file is for compatibility purposes only. Get Legacy-iOS-Kit_complete instead." > README.txt
|
||||||
zip -r iOS-OTA-Downgrader_complete_${{ env.DATE_OLD }}-${{ env.SHA_SHORT }}.zip README.txt
|
zip -r git-hash_${{ env.DATE_OLD }}-${{ env.SHA_SHORT }}.zip README.txt
|
||||||
|
|
||||||
- name: Update latest release
|
- name: Update latest release
|
||||||
uses: pyTooling/Actions/releaser@main
|
uses: pyTooling/Actions/releaser@main
|
||||||
@ -96,7 +96,7 @@ jobs:
|
|||||||
rm: true
|
rm: true
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
files: |
|
files: |
|
||||||
iOS-OTA-Downgrader_complete_${{ env.DATE_OLD }}-${{ env.SHA_SHORT }}.zip
|
git-hash_${{ env.DATE_OLD }}-${{ env.SHA_SHORT }}.zip
|
||||||
${{ github.event.repository.name }}_complete_v${{ env.DATE }}.${{ env.COUNT }}.zip
|
${{ github.event.repository.name }}_complete_v${{ env.DATE }}.${{ env.COUNT }}.zip
|
||||||
${{ github.event.repository.name }}_macos_v${{ env.DATE }}.${{ env.COUNT }}.zip
|
${{ github.event.repository.name }}_macos_v${{ env.DATE }}.${{ env.COUNT }}.zip
|
||||||
${{ github.event.repository.name }}_linux_armhf_v${{ env.DATE }}.${{ env.COUNT }}.zip
|
${{ github.event.repository.name }}_linux_armhf_v${{ env.DATE }}.${{ env.COUNT }}.zip
|
||||||
|
16
restore.sh
16
restore.sh
@ -356,7 +356,9 @@ install_depends() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
version_check() {
|
version_check() {
|
||||||
|
local github_api
|
||||||
local version_latest
|
local version_latest
|
||||||
|
local git_hash_latest
|
||||||
|
|
||||||
pushd .. >/dev/null
|
pushd .. >/dev/null
|
||||||
if [[ -d .git ]]; then
|
if [[ -d .git ]]; then
|
||||||
@ -367,7 +369,7 @@ version_check() {
|
|||||||
version_current=v$(date +%y.%m).$(git rev-list --count HEAD --since=$(date --date="$(date +%Y-%m-01) - 1 second" +%s) | xargs printf "%02d")
|
version_current=v$(date +%y.%m).$(git rev-list --count HEAD --since=$(date --date="$(date +%Y-%m-01) - 1 second" +%s) | xargs printf "%02d")
|
||||||
fi
|
fi
|
||||||
elif [[ -e ./resources/git_hash ]]; then
|
elif [[ -e ./resources/git_hash ]]; then
|
||||||
version="$(cat ./resources/version)"
|
version_current="$(cat ./resources/version)"
|
||||||
git_hash="$(cat ./resources/git_hash)"
|
git_hash="$(cat ./resources/git_hash)"
|
||||||
else
|
else
|
||||||
log ".git directory and git_hash file not found, cannot determine version."
|
log ".git directory and git_hash file not found, cannot determine version."
|
||||||
@ -385,16 +387,18 @@ version_check() {
|
|||||||
warn "No version check flag detected, update check will be disabled and no support may be provided."
|
warn "No version check flag detected, update check will be disabled and no support may be provided."
|
||||||
else
|
else
|
||||||
log "Checking for updates..."
|
log "Checking for updates..."
|
||||||
version_latest=$(curl https://api.github.com/repos/LukeZGD/Legacy-iOS-Kit/releases/latest 2>/dev/null | grep "latest/Legacy-iOS-Kit_complete" | cut -c 123- | cut -c -9 | sed -r 's/\.$//')
|
github_api=$(curl https://api.github.com/repos/LukeZGD/Legacy-iOS-Kit/releases/latest 2>/dev/null)
|
||||||
|
version_latest=$(echo "$github_api" | grep "latest/Legacy-iOS-Kit_complete" | cut -c 123- | cut -c -9 | sed -r 's/\.$//')
|
||||||
|
git_hash_latest=$(echo "$github_api" | grep "latest/git-hash" | cut -c 119- | cut -c -7)
|
||||||
if [[ -z $version_latest ]]; then
|
if [[ -z $version_latest ]]; then
|
||||||
: warn "Failed to check for updates. GitHub may be down or blocked by your network."
|
: warn "Failed to check for updates. GitHub may be down or blocked by your network."
|
||||||
elif [[ $version_latest != "$version_current" ]]; then
|
elif [[ $version_latest != "$version_current" ]]; then
|
||||||
if (( $(echo $version_current | cut -c 2- | sed -e 's/\.//g') >= $(echo $version_latest | cut -c 2- | sed -e 's/\.//g') )); then
|
if (( $(echo $version_current | cut -c 2- | sed -e 's/\.//g') >= $(echo $version_latest | cut -c 2- | sed -e 's/\.//g') )); then
|
||||||
warn "Current version is newer/different than remote: $version_latest ($(curl https://api.github.com/repos/LukeZGD/Legacy-iOS-Kit/releases/latest 2>/dev/null | grep "latest/iOS-OTA-Downgrader_complete" | cut -c 138- | cut -c -7))"
|
warn "Current version is newer/different than remote: $version_latest ($git_hash_latest)"
|
||||||
elif [[ $(echo $version_current | cut -c 12-) != $(echo $version_latest | cut -c 12-) ]]; then
|
else
|
||||||
print "* A newer version of Legacy iOS Kit is available."
|
print "* A newer version of Legacy iOS Kit is available."
|
||||||
print "* Current version: $version_current"
|
print "* Current version: $version_current ($git_hash)"
|
||||||
print "* Latest version: $version_latest"
|
print "* Latest version: $version_latest ($git_hash_latest)"
|
||||||
print "* Please download/pull the latest version before proceeding."
|
print "* Please download/pull the latest version before proceeding."
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user