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:
@@ -12,6 +12,8 @@ concurrency:
|
||||
jobs:
|
||||
update-cursor:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CI: true
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
@@ -65,9 +67,13 @@ jobs:
|
||||
|
||||
# Create commit message based on version info
|
||||
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)
|
||||
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
|
||||
COMMIT_MSG="Update Cursor to latest version"
|
||||
fi
|
||||
|
||||
+30
-9
@@ -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,19 +307,30 @@ 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
|
||||
@@ -318,11 +340,10 @@ main() {
|
||||
|
||||
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\""
|
||||
|
||||
Reference in New Issue
Block a user