|
|
|
@@ -6,19 +6,10 @@ set -euo pipefail
|
|
|
|
|
: "${DOWNLOAD_URL_TEMPLATE:?DOWNLOAD_URL_TEMPLATE is required}"
|
|
|
|
|
: "${RELEASE_API_REPO:?RELEASE_API_REPO is required}"
|
|
|
|
|
|
|
|
|
|
if command -v python >/dev/null 2>&1; then
|
|
|
|
|
PYTHON_BIN=python
|
|
|
|
|
elif command -v python3 >/dev/null 2>&1; then
|
|
|
|
|
PYTHON_BIN=python3
|
|
|
|
|
else
|
|
|
|
|
echo "python is required but was not found"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
version_strip_prefix="${LATEST_VERSION_STRIP_PREFIX:-v}"
|
|
|
|
|
release_tag_template="${RELEASE_TAG_TEMPLATE:-{version}}"
|
|
|
|
|
|
|
|
|
|
current_version=$($PYTHON_BIN - <<'PY'
|
|
|
|
|
current_version=$(python - <<'PY'
|
|
|
|
|
import re
|
|
|
|
|
import os
|
|
|
|
|
p=os.environ['FILE']
|
|
|
|
@@ -44,12 +35,12 @@ if [ -z "$latest_version" ] || [ "$latest_version" = "$current_version" ]; then
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
download_url="${DOWNLOAD_URL_TEMPLATE//\{version\}/$latest_version}"
|
|
|
|
|
new_hash=$(nix store prefetch-file --json "$download_url" | "$PYTHON_BIN" -c 'import json,sys; print(json.load(sys.stdin)["hash"])')
|
|
|
|
|
new_hash=$(nix store prefetch-file --json "$download_url" | python -c 'import json,sys; print(json.load(sys.stdin)["hash"])')
|
|
|
|
|
|
|
|
|
|
export LATEST_VERSION="$latest_version"
|
|
|
|
|
export NEW_HASH="$new_hash"
|
|
|
|
|
|
|
|
|
|
"$PYTHON_BIN" - <<'PY'
|
|
|
|
|
python - <<'PY'
|
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
p=os.environ['FILE']
|
|
|
|
@@ -64,29 +55,12 @@ echo "version=$latest_version" >> "$GITHUB_OUTPUT"
|
|
|
|
|
echo "previous_version=$current_version" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
|
|
release_tag="${release_tag_template//\{version\}/$latest_version}"
|
|
|
|
|
api_url="https://api.github.com/repos/${RELEASE_API_REPO}/releases/tags/${release_tag}"
|
|
|
|
|
|
|
|
|
|
curl_headers=(
|
|
|
|
|
-H "Accept: application/vnd.github+json"
|
|
|
|
|
-H "X-GitHub-Api-Version: 2022-11-28"
|
|
|
|
|
)
|
|
|
|
|
if [ -n "${GITHUB_TOKEN:-}" ]; then
|
|
|
|
|
curl_headers+=( -H "Authorization: Bearer ${GITHUB_TOKEN}" )
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
api_response=$(curl -sS -w '\n%{http_code}' "${curl_headers[@]}" "$api_url" || true)
|
|
|
|
|
api_body=$(printf '%s\n' "$api_response" | sed '$d')
|
|
|
|
|
api_code=$(printf '%s\n' "$api_response" | tail -n1)
|
|
|
|
|
|
|
|
|
|
release_notes=""
|
|
|
|
|
if [ "$api_code" = "200" ]; then
|
|
|
|
|
release_notes=$(printf '%s' "$api_body" | "$PYTHON_BIN" -c 'import json,sys; d=json.load(sys.stdin); print((d.get("body") or "").strip())' || true)
|
|
|
|
|
else
|
|
|
|
|
echo "warning: failed to fetch release notes from GitHub API (status=$api_code, url=$api_url)"
|
|
|
|
|
fi
|
|
|
|
|
release_notes=$(curl -fsSL "https://api.github.com/repos/${RELEASE_API_REPO}/releases/tags/${release_tag}" \
|
|
|
|
|
| python -c 'import json,sys; d=json.load(sys.stdin); print((d.get("body") or "").strip())' \
|
|
|
|
|
|| true)
|
|
|
|
|
|
|
|
|
|
if [ -z "$release_notes" ]; then
|
|
|
|
|
release_notes="_No changelog found in upstream release notes. Check ${LATEST_RELEASE_URL%/latest}/tag/${release_tag}._"
|
|
|
|
|
release_notes="_No changelog found in upstream release notes._"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
delimiter="CHANGELOG_$(date +%s%N)"
|
|
|
|
|