mirror of
https://github.com/TommyFang2077/dsh-desktop.git
synced 2026-08-17 09:06:36 +08:00
Compare commits
1 Commits
33186b2ef9
...
v0.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| f1b41e989a |
@@ -14,18 +14,41 @@ API="${GITEA_BASE_URL%/}/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}"
|
|||||||
PACKAGE_BASE="${GITEA_BASE_URL%/}/api/packages/${GITEA_OWNER}/generic/dsh-easy-desktop-updater"
|
PACKAGE_BASE="${GITEA_BASE_URL%/}/api/packages/${GITEA_OWNER}/generic/dsh-easy-desktop-updater"
|
||||||
AUTH="Authorization: token ${GITEA_TOKEN}"
|
AUTH="Authorization: token ${GITEA_TOKEN}"
|
||||||
|
|
||||||
# The Gitea repository is a pull mirror. Sync the GitHub tag before creating
|
# Retry transient gateway errors (504) coming from the front proxy while the
|
||||||
# the matching Gitea release, then wait until the tag is queryable.
|
# NAS reaches github.com over a mainland link: requests can stall past the
|
||||||
curl --fail --silent --show-error -X POST -H "$AUTH" "$API/mirror-sync" >/dev/null
|
# proxy read timeout. 404s are NOT retried here (release/package state).
|
||||||
for _ in $(seq 1 30); do
|
curl_retry() {
|
||||||
|
local attempts=0
|
||||||
|
while ! "$@"; do
|
||||||
|
attempts=$((attempts + 1))
|
||||||
|
if (( attempts >= 4 )); then
|
||||||
|
echo "curl failed after 4 attempts: $*" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo "curl transient failure (attempt ${attempts}/3), retrying: $*" >&2
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# The Gitea repository is a pull mirror. Kick a background sync; the trigger
|
||||||
|
# response itself is irrelevant (it can 504 while the sync runs on Gitea).
|
||||||
|
# The tag poll below is the actual gate.
|
||||||
|
curl --silent --show-error -X POST -H "$AUTH" "$API/mirror-sync" >/dev/null || true
|
||||||
|
|
||||||
|
# Wait (up to 10 min) until the tag has synced; then fail loudly if it never did.
|
||||||
|
for _ in $(seq 1 60); do
|
||||||
if curl --fail --silent --show-error -H "$AUTH" "$API/tags/$RELEASE_TAG" >/dev/null 2>&1; then
|
if curl --fail --silent --show-error -H "$AUTH" "$API/tags/$RELEASE_TAG" >/dev/null 2>&1; then
|
||||||
|
synced=1
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
curl --fail --silent --show-error -H "$AUTH" "$API/tags/$RELEASE_TAG" >/dev/null
|
[[ "${synced:-0}" == 1 ]] || {
|
||||||
|
echo "tag $RELEASE_TAG did not appear on the Gitea mirror after 10 minutes" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
release_json=$(curl --silent --show-error -H "$AUTH" "$API/releases/tags/$RELEASE_TAG")
|
release_json=$(curl_retry curl --fail --silent --show-error -H "$AUTH" "$API/releases/tags/$RELEASE_TAG")
|
||||||
release_id=$(printf '%s' "$release_json" | jq -r '.id // empty')
|
release_id=$(printf '%s' "$release_json" | jq -r '.id // empty')
|
||||||
if [[ -z "$release_id" ]]; then
|
if [[ -z "$release_id" ]]; then
|
||||||
release_payload=$(jq -n \
|
release_payload=$(jq -n \
|
||||||
@@ -33,7 +56,7 @@ if [[ -z "$release_id" ]]; then
|
|||||||
--arg name "DeepSeek Harness Desktop $RELEASE_TAG" \
|
--arg name "DeepSeek Harness Desktop $RELEASE_TAG" \
|
||||||
--arg body "大陆镜像安装包;文件与 GitHub Release 同源。应用内更新包由 Tauri 签名校验。" \
|
--arg body "大陆镜像安装包;文件与 GitHub Release 同源。应用内更新包由 Tauri 签名校验。" \
|
||||||
'{tag_name:$tag,target_commitish:$tag,name:$name,body:$body,draft:false,prerelease:false}')
|
'{tag_name:$tag,target_commitish:$tag,name:$name,body:$body,draft:false,prerelease:false}')
|
||||||
release_json=$(curl --fail --silent --show-error \
|
release_json=$(curl_retry curl --fail --silent --show-error \
|
||||||
-X POST -H "$AUTH" -H 'Content-Type: application/json' \
|
-X POST -H "$AUTH" -H 'Content-Type: application/json' \
|
||||||
--data "$release_payload" "$API/releases")
|
--data "$release_payload" "$API/releases")
|
||||||
release_id=$(printf '%s' "$release_json" | jq -r '.id')
|
release_id=$(printf '%s' "$release_json" | jq -r '.id')
|
||||||
@@ -44,17 +67,17 @@ curl --silent --show-error -X DELETE -H "$AUTH" \
|
|||||||
"$PACKAGE_BASE/$RELEASE_VERSION" >/dev/null || true
|
"$PACKAGE_BASE/$RELEASE_VERSION" >/dev/null || true
|
||||||
for file in "$STAGING_DIR"/*; do
|
for file in "$STAGING_DIR"/*; do
|
||||||
[[ -f "$file" && "$(basename "$file")" != "latest.json" ]] || continue
|
[[ -f "$file" && "$(basename "$file")" != "latest.json" ]] || continue
|
||||||
curl --fail --silent --show-error -H "$AUTH" --upload-file "$file" \
|
curl_retry curl --fail --silent --show-error -H "$AUTH" --upload-file "$file" \
|
||||||
"$PACKAGE_BASE/$RELEASE_VERSION/$(basename "$file")" >/dev/null
|
"$PACKAGE_BASE/$RELEASE_VERSION/$(basename "$file")" >/dev/null
|
||||||
done
|
done
|
||||||
|
|
||||||
# Stable updater endpoint. Gitea generic packages are immutable, so replace
|
# Stable updater endpoint. Gitea generic packages are immutable, so replace
|
||||||
# the synthetic "latest" version on each completed release.
|
# the synthetic "latest" version on each completed release.
|
||||||
curl --silent --show-error -X DELETE -H "$AUTH" "$PACKAGE_BASE/latest" >/dev/null || true
|
curl --silent --show-error -X DELETE -H "$AUTH" "$PACKAGE_BASE/latest" >/dev/null || true
|
||||||
curl --fail --silent --show-error -H "$AUTH" --upload-file "$STAGING_DIR/latest.json" \
|
curl_retry curl --fail --silent --show-error -H "$AUTH" --upload-file "$STAGING_DIR/latest.json" \
|
||||||
"$PACKAGE_BASE/latest/latest.json" >/dev/null
|
"$PACKAGE_BASE/latest/latest.json" >/dev/null
|
||||||
|
|
||||||
assets=$(curl --fail --silent --show-error -H "$AUTH" "$API/releases/$release_id/assets")
|
assets=$(curl_retry curl --fail --silent --show-error -H "$AUTH" "$API/releases/$release_id/assets")
|
||||||
for file in "$STAGING_DIR"/*; do
|
for file in "$STAGING_DIR"/*; do
|
||||||
[[ -f "$file" ]] || continue
|
[[ -f "$file" ]] || continue
|
||||||
name=$(basename "$file")
|
name=$(basename "$file")
|
||||||
@@ -64,9 +87,9 @@ for file in "$STAGING_DIR"/*; do
|
|||||||
esac
|
esac
|
||||||
old_id=$(printf '%s' "$assets" | jq -r --arg name "$name" '[.[] | select(.name == $name) | .id][0] // empty')
|
old_id=$(printf '%s' "$assets" | jq -r --arg name "$name" '[.[] | select(.name == $name) | .id][0] // empty')
|
||||||
if [[ -n "$old_id" ]]; then
|
if [[ -n "$old_id" ]]; then
|
||||||
curl --fail --silent --show-error -X DELETE -H "$AUTH" \
|
curl_retry curl --fail --silent --show-error -X DELETE -H "$AUTH" \
|
||||||
"$API/releases/$release_id/assets/$old_id" >/dev/null
|
"$API/releases/$release_id/assets/$old_id" >/dev/null
|
||||||
fi
|
fi
|
||||||
curl --fail --silent --show-error -H "$AUTH" \
|
curl_retry curl --fail --silent --show-error -H "$AUTH" \
|
||||||
-F "attachment=@$file" "$API/releases/$release_id/assets?name=$name" >/dev/null
|
-F "attachment=@$file" "$API/releases/$release_id/assets?name=$name" >/dev/null
|
||||||
done
|
done
|
||||||
Reference in New Issue
Block a user