Advertisement
plirof2

fetch latest version

Dec 2nd, 2023 (edited)
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.02 KB | None | 0 0
  1. ===========bash ============================
  2. #!/bin/bash
  3.  
  4. # GitHub repository owner and name
  5. OWNER="ivan-hc"
  6. REPO="Chromium-Web-Browser-appimage"
  7.  
  8. # Fetch the latest release information using the GitHub API
  9. API_URL="https://api.github.com/repos/$OWNER/$REPO/releases/latest"
  10. RELEASE_INFO=$(curl -s "$API_URL")
  11.  
  12. # Check if the request was successful
  13. if [[ $RELEASE_INFO == *"Not Found"* ]]; then
  14.     echo "Error: Repository or release not found. Please check the repository owner and name."
  15.     exit 1
  16. fi
  17.  
  18. # Extract the latest release version and asset download URL without jq
  19. LATEST_VERSION=$(grep -oP '"tag_name": "\K[^"]+' <<< "$RELEASE_INFO")
  20. DOWNLOAD_URL=$(grep -oP '"browser_download_url": "\K[^"]+' <<< "$RELEASE_INFO")
  21.  
  22. # Download the latest version
  23. #wget "$DOWNLOAD_URL" -O "Chromium_Web_Browser-$LATEST_VERSION.AppImage"
  24. wget "$DOWNLOAD_URL"
  25.  
  26. echo "Downloaded Chromium Web Browser version $LATEST_VERSION to Chromium_Web_Browser-$LATEST_VERSION.AppImage"
  27.  
  28.  
  29. =================PHP=======================
  30. #!/bin/bash
  31.  
  32. # GitHub repository owner and name
  33. OWNER="ivan-hc"
  34. REPO="Chromium-Web-Browser-appimage"
  35.  
  36. # Fetch the latest release information using the GitHub API
  37. API_URL="https://api.github.com/repos/$OWNER/$REPO/releases/latest"
  38. RELEASE_INFO=$(curl -s "$API_URL")
  39.  
  40. # Check if the request was successful
  41. if [[ $RELEASE_INFO == *"Not Found"* ]]; then
  42.     echo "Error: Repository or release not found. Please check the repository owner and name."
  43.     exit 1
  44. fi
  45.  
  46. # Extract the latest release version and asset download URL using php
  47. LATEST_VERSION=$(php -r 'echo json_decode(file_get_contents("php://stdin"))->tag_name;' <<< "$RELEASE_INFO")
  48. DOWNLOAD_URL=$(php -r 'echo json_decode(file_get_contents("php://stdin"))->assets[0]->browser_download_url;' <<< "$RELEASE_INFO")
  49.  
  50. # Download the latest version
  51. #wget "$DOWNLOAD_URL" -O "Chromium_Web_Browser-$LATEST_VERSION.AppImage"
  52. wget "$DOWNLOAD_URL"
  53. echo "Downloaded Chromium Web Browser version $LATEST_VERSION to Chromium_Web_Browser-$LATEST_VERSION.AppImage"
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement