Enhance update-cursor.sh and GitHub Actions workflow for improved version handling
- Added CURSOR_VERSION_INFO output to track update status in update-cursor.sh - Implemented auto-confirmation for updates when running in CI mode - Updated GitHub Actions workflow to capture and utilize CURSOR_VERSION_INFO for conditional commits - Improved commit message generation based on actual version updates
This commit is contained in:
@@ -23,12 +23,18 @@ jobs:
|
|||||||
nix_path: nixpkgs=channel:nixpkgs-unstable
|
nix_path: nixpkgs=channel:nixpkgs-unstable
|
||||||
|
|
||||||
- name: Update Cursor using script
|
- name: Update Cursor using script
|
||||||
|
id: update-cursor
|
||||||
run: |
|
run: |
|
||||||
# Make the script executable
|
# Make the script executable
|
||||||
chmod +x update-cursor.sh
|
chmod +x update-cursor.sh
|
||||||
|
|
||||||
# Run the update script with auto-confirm
|
# Run the update script (it will auto-confirm in CI mode)
|
||||||
echo "y" | ./update-cursor.sh
|
./update-cursor.sh
|
||||||
|
|
||||||
|
# Capture version info from script output
|
||||||
|
if [[ -f "$GITHUB_OUTPUT" ]]; then
|
||||||
|
grep "CURSOR_VERSION_INFO=" "$GITHUB_OUTPUT" || echo "CURSOR_VERSION_INFO=no_update" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Update flake lock file
|
- name: Update flake lock file
|
||||||
run: |
|
run: |
|
||||||
@@ -41,15 +47,35 @@ jobs:
|
|||||||
|
|
||||||
- name: Commit and push changes
|
- name: Commit and push changes
|
||||||
run: |
|
run: |
|
||||||
|
# Get version info from the update step
|
||||||
|
VERSION_INFO="${{ steps.update-cursor.outputs.CURSOR_VERSION_INFO }}"
|
||||||
|
|
||||||
|
# Only commit if there was an actual update
|
||||||
|
if [[ "$VERSION_INFO" == "no_update" ]]; then
|
||||||
|
echo "No Cursor update needed, skipping commit"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if there are any changes to commit
|
# Check if there are any changes to commit
|
||||||
if git diff --quiet; then
|
if git diff --quiet; then
|
||||||
echo "No changes to commit"
|
echo "No changes to commit"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Create commit message based on version info
|
||||||
|
if [[ "$VERSION_INFO" == completed:* ]]; then
|
||||||
|
# Extract version from format: completed:old_version:new_version
|
||||||
|
NEW_VERSION=$(echo "$VERSION_INFO" | cut -d: -f3)
|
||||||
|
COMMIT_MSG="Update Cursor to version $NEW_VERSION"
|
||||||
|
else
|
||||||
|
COMMIT_MSG="Update Cursor to latest version"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Commit message: $COMMIT_MSG"
|
||||||
|
|
||||||
git config --local user.email "action@github.com"
|
git config --local user.email "action@github.com"
|
||||||
git config --local user.name "GitHub Action"
|
git config --local user.name "GitHub Action"
|
||||||
git add flake.nix flake.lock
|
git add flake.nix flake.lock
|
||||||
git commit -m "Update Cursor to latest version"
|
git commit -m "$COMMIT_MSG"
|
||||||
git push
|
git push
|
||||||
|
|
||||||
|
|||||||
@@ -103,17 +103,27 @@ main() {
|
|||||||
# Check if update is needed
|
# Check if update is needed
|
||||||
if [[ "$target_version" == "$current_version" ]]; then
|
if [[ "$target_version" == "$current_version" ]]; then
|
||||||
echo "No update needed. Current version is up to date."
|
echo "No update needed. Current version is up to date."
|
||||||
|
echo "CURSOR_VERSION_INFO=no_update" >> "$GITHUB_OUTPUT" 2>/dev/null || true
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Update needed: $current_version -> $target_version"
|
echo "Update needed: $current_version -> $target_version"
|
||||||
|
echo "CURSOR_VERSION_INFO=updated:$current_version:$target_version" >> "$GITHUB_OUTPUT" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Check if running in CI/GitHub Actions (auto-confirm)
|
||||||
|
if [[ -n "${CI:-}" ]] || [[ -n "${GITHUB_ACTIONS:-}" ]]; 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
|
read -p "Do you want to proceed with the update? (y/N): " -n 1 -r
|
||||||
echo
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
update_flake "$target_version"
|
update_flake "$target_version"
|
||||||
test_flake
|
test_flake
|
||||||
echo "Update completed successfully!"
|
echo "Update completed successfully!"
|
||||||
|
echo "CURSOR_VERSION_INFO=completed:$current_version:$target_version" >> "$GITHUB_OUTPUT" 2>/dev/null || true
|
||||||
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\""
|
||||||
|
|||||||
Reference in New Issue
Block a user