test workflow
This commit is contained in:
@@ -6,10 +6,19 @@ set -euo pipefail
|
|||||||
: "${DOWNLOAD_URL_TEMPLATE:?DOWNLOAD_URL_TEMPLATE is required}"
|
: "${DOWNLOAD_URL_TEMPLATE:?DOWNLOAD_URL_TEMPLATE is required}"
|
||||||
: "${RELEASE_API_REPO:?RELEASE_API_REPO 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}"
|
version_strip_prefix="${LATEST_VERSION_STRIP_PREFIX:-v}"
|
||||||
release_tag_template="${RELEASE_TAG_TEMPLATE:-{version}}"
|
release_tag_template="${RELEASE_TAG_TEMPLATE:-{version}}"
|
||||||
|
|
||||||
current_version=$(python - <<'PY'
|
current_version=$($PYTHON_BIN - <<'PY'
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
p=os.environ['FILE']
|
p=os.environ['FILE']
|
||||||
@@ -35,12 +44,12 @@ if [ -z "$latest_version" ] || [ "$latest_version" = "$current_version" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
download_url="${DOWNLOAD_URL_TEMPLATE//\{version\}/$latest_version}"
|
download_url="${DOWNLOAD_URL_TEMPLATE//\{version\}/$latest_version}"
|
||||||
new_hash=$(nix store prefetch-file --json "$download_url" | python -c 'import json,sys; print(json.load(sys.stdin)["hash"])')
|
new_hash=$(nix store prefetch-file --json "$download_url" | "$PYTHON_BIN" -c 'import json,sys; print(json.load(sys.stdin)["hash"])')
|
||||||
|
|
||||||
export LATEST_VERSION="$latest_version"
|
export LATEST_VERSION="$latest_version"
|
||||||
export NEW_HASH="$new_hash"
|
export NEW_HASH="$new_hash"
|
||||||
|
|
||||||
python - <<'PY'
|
"$PYTHON_BIN" - <<'PY'
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
p=os.environ['FILE']
|
p=os.environ['FILE']
|
||||||
@@ -55,12 +64,29 @@ echo "version=$latest_version" >> "$GITHUB_OUTPUT"
|
|||||||
echo "previous_version=$current_version" >> "$GITHUB_OUTPUT"
|
echo "previous_version=$current_version" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
release_tag="${release_tag_template//\{version\}/$latest_version}"
|
release_tag="${release_tag_template//\{version\}/$latest_version}"
|
||||||
release_notes=$(curl -fsSL "https://api.github.com/repos/${RELEASE_API_REPO}/releases/tags/${release_tag}" \
|
api_url="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)
|
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
|
||||||
|
|
||||||
if [ -z "$release_notes" ]; then
|
if [ -z "$release_notes" ]; then
|
||||||
release_notes="_No changelog found in upstream release notes._"
|
release_notes="_No changelog found in upstream release notes. Check ${LATEST_RELEASE_URL%/latest}/tag/${release_tag}._"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
delimiter="CHANGELOG_$(date +%s%N)"
|
delimiter="CHANGELOG_$(date +%s%N)"
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ jobs:
|
|||||||
DOWNLOAD_URL_TEMPLATE: https://github.com/cjpais/Handy/releases/download/v{version}/Handy_{version}_amd64.AppImage
|
DOWNLOAD_URL_TEMPLATE: https://github.com/cjpais/Handy/releases/download/v{version}/Handy_{version}_amd64.AppImage
|
||||||
RELEASE_API_REPO: cjpais/Handy
|
RELEASE_API_REPO: cjpais/Handy
|
||||||
RELEASE_TAG_TEMPLATE: v{version}
|
RELEASE_TAG_TEMPLATE: v{version}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.github_token || secrets.GITHUB_TOKEN }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: bash .gitea/scripts/update-appimage-nix.sh
|
run: bash .gitea/scripts/update-appimage-nix.sh
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ jobs:
|
|||||||
DOWNLOAD_URL_TEMPLATE: https://github.com/imputnet/helium-linux/releases/download/{version}/helium-{version}-x86_64.AppImage
|
DOWNLOAD_URL_TEMPLATE: https://github.com/imputnet/helium-linux/releases/download/{version}/helium-{version}-x86_64.AppImage
|
||||||
RELEASE_API_REPO: imputnet/helium-linux
|
RELEASE_API_REPO: imputnet/helium-linux
|
||||||
RELEASE_TAG_TEMPLATE: '{version}'
|
RELEASE_TAG_TEMPLATE: '{version}'
|
||||||
|
GITHUB_TOKEN: ${{ secrets.github_token || secrets.GITHUB_TOKEN }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: bash .gitea/scripts/update-appimage-nix.sh
|
run: bash .gitea/scripts/update-appimage-nix.sh
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ jobs:
|
|||||||
DOWNLOAD_URL_TEMPLATE: https://github.com/zen-browser/desktop/releases/download/{version}/zen-x86_64.AppImage
|
DOWNLOAD_URL_TEMPLATE: https://github.com/zen-browser/desktop/releases/download/{version}/zen-x86_64.AppImage
|
||||||
RELEASE_API_REPO: zen-browser/desktop
|
RELEASE_API_REPO: zen-browser/desktop
|
||||||
RELEASE_TAG_TEMPLATE: '{version}'
|
RELEASE_TAG_TEMPLATE: '{version}'
|
||||||
|
GITHUB_TOKEN: ${{ secrets.github_token || secrets.GITHUB_TOKEN }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: bash .gitea/scripts/update-appimage-nix.sh
|
run: bash .gitea/scripts/update-appimage-nix.sh
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user