fix(ci): refresh AppImage hashes when Cursor version is unchanged

Cursor can republish the same semver with a new build; the updater
previously skipped prefetch when the version matched, leaving stale
sha256 values. In CI, always re-prefetch and commit when flake.nix drifts.
This commit is contained in:
2026-06-02 23:03:37 -03:00
parent 1104372b0b
commit fe9d8ba55a
2 changed files with 42 additions and 15 deletions
+33 -12
View File
@@ -111,6 +111,17 @@ is_pointer() {
[[ "${1:-}" == "latest" || "${1:-}" =~ ^[0-9]+\.[0-9]+$ ]]
}
is_ci() {
[[ -n "${CI:-}" || -n "${GITHUB_ACTIONS:-}" || -n "${GITEA_ACTIONS:-}" ]]
}
write_version_output() {
local value="$1"
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
echo "CURSOR_VERSION_INFO=$value" >> "$GITHUB_OUTPUT"
fi
}
# Function to get current version from flake.nix managed block
get_current_version() {
awk -v begin="$MANAGED_BEGIN" -v end="$MANAGED_END" '
@@ -296,33 +307,43 @@ main() {
echo "Resolved: latest=$v_latest pointer($current_track)=$v_current_track pointer($latest_track)=$v_latest_track -> chosen=$target_version"
fi
# Check if update is needed
# Same semver but Cursor may republish the AppImage (hash/url drift). In CI, always re-prefetch.
if [[ "$target_version" == "$current_version" ]]; then
echo "No update needed. Current version is up to date."
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
echo "CURSOR_VERSION_INFO=no_update" >> "$GITHUB_OUTPUT"
if is_ci; then
echo "Version unchanged ($current_version); re-prefetching URLs and hashes for upstream drift..."
update_release "$target_version"
rm -f "$FLAKE_FILE.backup"
if git diff --quiet -- "$FLAKE_FILE" 2>/dev/null; then
echo "Hashes and URLs already match upstream."
write_version_output "no_update"
exit 0
fi
test_flake
echo "Refreshed hashes for Cursor $target_version"
write_version_output "completed:$current_version:$target_version"
exit 0
fi
echo "No update needed. Current version is up to date."
write_version_output "no_update"
exit 0
fi
echo "Update needed: $current_version -> $target_version"
# Check if running in CI/GitHub Actions (auto-confirm)
if [[ -n "${CI:-}" ]] || [[ -n "${GITHUB_ACTIONS:-}" ]]; then
if is_ci; then
echo "Running in CI mode, auto-confirming update..."
REPLY="y"
else
read -p "Do you want to proceed with the update? (y/N): " -n 1 -r
echo
fi
if [[ $REPLY =~ ^[Yy]$ ]]; then
update_release "$target_version"
rm -f "$FLAKE_FILE.backup"
test_flake
echo "Update completed successfully!"
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
echo "CURSOR_VERSION_INFO=completed:$current_version:$target_version" >> "$GITHUB_OUTPUT"
fi
write_version_output "completed:$current_version:$target_version"
echo "You can now commit the changes:"
echo " git add flake.nix"
echo " git commit -m \"Update Cursor to version $target_version\""