Skip to content

Commit

Permalink
fix match
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow committed Jul 28, 2024
1 parent a101101 commit 559b85a
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions __frzr-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ get_img_url() {
# CHANNEL 去掉最后一个 - 及其后面的内容
CHANNEL_STABLE=$(echo "${CHANNEL}" | sed 's/-[^-]*$//')
echo "CHANNEL_STABLE: $CHANNEL_STABLE" >&2
result_stable=$(echo "${result}" | jq '[ .[] | select(.name|test("['${CHANNEL_STABLE}']" ; "i")) ]')
result_stable=$(echo "${result}" | jq '[ .[] | select(.name|test("\\['${CHANNEL_STABLE}'\\]" ; "i")) ]')

if stable_release_date=$(echo "${result_stable}" | jq -er '[ .[] |
select(.name|test("['${CHANNEL_STABLE}']" ; "i")) ] |
select(.name|test("\\['${CHANNEL_STABLE}'\\]" ; "i")) ] |
first |
.created_at'
); then
stable_download_url=$(echo "${result_stable}" | jq -r '[ .[] |
select(.name|test("['${CHANNEL_STABLE}']" ; "i")) ] |
select(.name|test("\\['${CHANNEL_STABLE}'\\]" ; "i")) ] |
first |
.assets[] |
select(.browser_download_url | test("'$keywords'")) |
Expand All @@ -109,17 +109,20 @@ get_img_url() {
fi
fi

# echo "stable_download_url is $stable_download_url" >&2

# Match any release with CHANNEL as a tag (including unstable)
result=$(echo "${result}" | jq '[ .[] | select(.prerelease==true) | select(.name|test("['${CHANNEL}']" ; "i")) ]')
result=$(echo "${result}" | jq '[ .[] | select(.prerelease==true) | select(.name|test("\\['${CHANNEL}'\\]" ; "i")) ]')
# echo "result is $result" >&2
if unstable_release_date=$(echo "${result}" | jq -er '[ .[] |
select(.prerelease==true) |
select(.name|test("['${CHANNEL}']" ; "i")) ] |
select(.name|test("\\['${CHANNEL}'\\]" ; "i")) ] |
first |
.created_at'
); then
unstable_url=$(echo "${result}" | jq -r '[ .[] |
select(.prerelease==true) |
select(.name|test("['${CHANNEL}']" ; "i")) ] |
select(.name|test("\\['${CHANNEL}'\\]" ; "i")) ] |
first |
.assets[] |
select(.browser_download_url | test("'$keywords'")) |
Expand All @@ -132,11 +135,13 @@ get_img_url() {
unstable_release_time=$(date -d $unstable_release_date +%s)
stable_release_time=$(date -d $stable_release_date +%s)

echo "unstable_release_time: $unstable_release_time" >&2
echo "stable_release_time: $stable_release_time" >&2
# echo "unstable_release_time: $unstable_release_time" >&2
# echo "stable_release_time: $stable_release_time" >&2

# echo "unstable_url is $unstable_url" >&2

# CHANNEL 为 unstable 或者 CHANNEL_STABLE 不为空, 并且 unstable_release_time 小于等于 stable_release_time
if [[ "$CHANNEL" == "unstable" || ! -z "$CHANNEL_STABLE" ]] && [ $unstable_release_time -le $stable_release_time ]; then
if [[ "$CHANNEL" == "unstable" || -n "$CHANNEL_STABLE" ]] && [ $unstable_release_time -le $stable_release_time ]; then
result=$stable_download_url
else
result=$unstable_url
Expand Down

0 comments on commit 559b85a

Please sign in to comment.