update_allure.sh 989 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. # fail if any commands fails
  3. set -e
  4. # debug log
  5. #set -x
  6. # Set superuser privileges command if not set
  7. if [[ -z $su ]]; then
  8. export su="sudo"
  9. fi
  10. $su apt-get update -qq
  11. $su apt-get install -qq -y curl
  12. mkdir -p ~/bin
  13. cd ~/bin || return
  14. github_api_response=$(curl -s "https://api.github.com/repos/allure-framework/allure2/releases/latest")
  15. download_url=$(echo $github_api_response | jq -r ".assets[] | select(.name | test(\"tgz\")) | .browser_download_url")
  16. echo $download_url
  17. download_filename=$(echo ${github_api_response} | jq -r ".assets[] | select(.name | test(\"tgz\")) | .name")
  18. echo $download_filename
  19. # Remove previous file
  20. rm -rf allure-*.tgz
  21. # Download new version
  22. curl -O -L "$download_url"
  23. # Remove previous directory
  24. rm -rf allure-*/
  25. # Remove previous symlink
  26. rm -f allure
  27. # Extract new version
  28. tar -xzvf $download_filename
  29. directory_name=$(basename $download_filename .tgz)
  30. # Create new symlink
  31. ln -s ~/bin/$directory_name/bin/allure ~/bin/
  32. allure --version