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
+8 -2
View File
@@ -12,6 +12,8 @@ concurrency:
jobs: jobs:
update-cursor: update-cursor:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
CI: true
permissions: permissions:
contents: write contents: write
@@ -65,9 +67,13 @@ jobs:
# Create commit message based on version info # Create commit message based on version info
if [[ "$VERSION_INFO" == completed:* ]]; then if [[ "$VERSION_INFO" == completed:* ]]; then
# Extract version from format: completed:old_version:new_version OLD_VERSION=$(echo "$VERSION_INFO" | cut -d: -f2)
NEW_VERSION=$(echo "$VERSION_INFO" | cut -d: -f3) NEW_VERSION=$(echo "$VERSION_INFO" | cut -d: -f3)
COMMIT_MSG="Update Cursor to version $NEW_VERSION" if [[ "$OLD_VERSION" == "$NEW_VERSION" ]]; then
COMMIT_MSG="Refresh Cursor $NEW_VERSION AppImage hashes"
else
COMMIT_MSG="Update Cursor to version $NEW_VERSION"
fi
else else
COMMIT_MSG="Update Cursor to latest version" COMMIT_MSG="Update Cursor to latest version"
fi fi
+30 -9
View File
@@ -111,6 +111,17 @@ is_pointer() {
[[ "${1:-}" == "latest" || "${1:-}" =~ ^[0-9]+\.[0-9]+$ ]] [[ "${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 # Function to get current version from flake.nix managed block
get_current_version() { get_current_version() {
awk -v begin="$MANAGED_BEGIN" -v end="$MANAGED_END" ' awk -v begin="$MANAGED_BEGIN" -v end="$MANAGED_END" '
@@ -296,19 +307,30 @@ main() {
echo "Resolved: latest=$v_latest pointer($current_track)=$v_current_track pointer($latest_track)=$v_latest_track -> chosen=$target_version" echo "Resolved: latest=$v_latest pointer($current_track)=$v_current_track pointer($latest_track)=$v_latest_track -> chosen=$target_version"
fi 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 if [[ "$target_version" == "$current_version" ]]; then
echo "No update needed. Current version is up to date." if is_ci; then
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then echo "Version unchanged ($current_version); re-prefetching URLs and hashes for upstream drift..."
echo "CURSOR_VERSION_INFO=no_update" >> "$GITHUB_OUTPUT" 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 fi
echo "No update needed. Current version is up to date."
write_version_output "no_update"
exit 0 exit 0
fi fi
echo "Update needed: $current_version -> $target_version" echo "Update needed: $current_version -> $target_version"
# Check if running in CI/GitHub Actions (auto-confirm) if is_ci; then
if [[ -n "${CI:-}" ]] || [[ -n "${GITHUB_ACTIONS:-}" ]]; then
echo "Running in CI mode, auto-confirming update..." echo "Running in CI mode, auto-confirming update..."
REPLY="y" REPLY="y"
else else
@@ -318,11 +340,10 @@ main() {
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
update_release "$target_version" update_release "$target_version"
rm -f "$FLAKE_FILE.backup"
test_flake test_flake
echo "Update completed successfully!" echo "Update completed successfully!"
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then write_version_output "completed:$current_version:$target_version"
echo "CURSOR_VERSION_INFO=completed:$current_version:$target_version" >> "$GITHUB_OUTPUT"
fi
echo "You can now commit the changes:" echo "You can now commit the changes:"
echo " git add flake.nix" echo " git add flake.nix"
echo " git commit -m \"Update Cursor to version $target_version\"" echo " git commit -m \"Update Cursor to version $target_version\""