Upload 2 files
Browse files- scripts/release-common.sh +36 -15
scripts/release-common.sh
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
#!/bin/sh
|
| 2 |
|
| 3 |
-
: "${
|
| 4 |
: "${RUNTIME_DIR:=/tmp/runtime}"
|
| 5 |
: "${RELEASES_DIR:=$RUNTIME_DIR/releases}"
|
| 6 |
: "${CURRENT_LINK:=$RUNTIME_DIR/current}"
|
|
@@ -39,28 +39,49 @@ current_binary_path() {
|
|
| 39 |
printf '%s/%s\n' "$CURRENT_LINK" "$CURRENT_BINARY_NAME"
|
| 40 |
}
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
tag_name=$(
|
| 46 |
-
printf '%s\n' "$
|
| 47 |
-
|
|
| 48 |
-
| head -n 1
|
| 49 |
-
| cut -d '"' -f 4 \
|
| 50 |
-
|| true
|
| 51 |
)
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
| grep -E '/[^/]*linux[-_]amd64(\.tar\.gz)?$' \
|
| 57 |
| head -n 1 \
|
| 58 |
|| true
|
| 59 |
)
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
printf '%s|%s\n' "$tag_name" "$asset_url"
|
| 66 |
}
|
|
|
|
| 1 |
#!/bin/sh
|
| 2 |
|
| 3 |
+
: "${REPO_RELEASES_URL:=https://github.com/caidaoli/ccLoad/releases}"
|
| 4 |
: "${RUNTIME_DIR:=/tmp/runtime}"
|
| 5 |
: "${RELEASES_DIR:=$RUNTIME_DIR/releases}"
|
| 6 |
: "${CURRENT_LINK:=$RUNTIME_DIR/current}"
|
|
|
|
| 39 |
printf '%s/%s\n' "$CURRENT_LINK" "$CURRENT_BINARY_NAME"
|
| 40 |
}
|
| 41 |
|
| 42 |
+
repo_base_url() {
|
| 43 |
+
# Strip a trailing "/releases" (and any trailing slash) to get the repo root.
|
| 44 |
+
printf '%s\n' "$REPO_RELEASES_URL" | sed -E 's#/+$##; s#/releases$##'
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
resolve_latest_tag() {
|
| 48 |
+
# The Atom feed is ordered newest-first and includes prereleases.
|
| 49 |
+
releases_feed=$(curl -fsSL "$(repo_base_url)/releases.atom") || return 1
|
| 50 |
|
| 51 |
tag_name=$(
|
| 52 |
+
printf '%s\n' "$releases_feed" \
|
| 53 |
+
| sed -n 's#.*href="[^"]*/releases/tag/\([^"]*\)".*#\1#p' \
|
| 54 |
+
| head -n 1
|
|
|
|
|
|
|
| 55 |
)
|
| 56 |
+
|
| 57 |
+
[ -n "$tag_name" ] || return 1
|
| 58 |
+
printf '%s\n' "$tag_name"
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
fetch_latest_release_info() {
|
| 62 |
+
tag_name=$(resolve_latest_tag) || return 1
|
| 63 |
+
|
| 64 |
+
base_url=$(repo_base_url)
|
| 65 |
+
|
| 66 |
+
# The expanded_assets fragment lists every asset as an <a href="..."> link.
|
| 67 |
+
assets_html=$(curl -fsSL "$base_url/releases/expanded_assets/$tag_name") || return 1
|
| 68 |
+
|
| 69 |
+
asset_path=$(
|
| 70 |
+
printf '%s\n' "$assets_html" \
|
| 71 |
+
| grep -Eo 'href="[^"]*/releases/download/[^"]+"' \
|
| 72 |
+
| cut -d '"' -f 2 \
|
| 73 |
| grep -E '/[^/]*linux[-_]amd64(\.tar\.gz)?$' \
|
| 74 |
| head -n 1 \
|
| 75 |
|| true
|
| 76 |
)
|
| 77 |
|
| 78 |
+
[ -n "$asset_path" ] || return 1
|
| 79 |
+
|
| 80 |
+
case "$asset_path" in
|
| 81 |
+
http://*|https://*) asset_url=$asset_path ;;
|
| 82 |
+
/*) asset_url="https://github.com$asset_path" ;;
|
| 83 |
+
*) asset_url="$base_url/$asset_path" ;;
|
| 84 |
+
esac
|
| 85 |
|
| 86 |
printf '%s|%s\n' "$tag_name" "$asset_url"
|
| 87 |
}
|