uploadArtifact.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env bash
  2. #1: LOG_USERNAME
  3. #2: LOG_PASSWORD
  4. #3: DRONE_BUILD_NUMBER
  5. #4: DRONE_PULL_REQUEST
  6. #5: GIT_USERNAME
  7. #6: GIT_TOKEN
  8. DAV_URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-artifacts/
  9. PUBLIC_URL=https://www.kaminsky.me/nc-dev/android-artifacts
  10. USER=$1
  11. PASS=$2
  12. BUILD=$3
  13. PR=$4
  14. GIT_USERNAME=$5
  15. GIT_TOKEN=$6
  16. if ! test -e build/outputs/apk/qa/debug/qa-debug-*.apk ; then
  17. exit 1
  18. fi
  19. echo "Uploaded artifact to $DAV_URL/$BUILD.apk"
  20. # delete all old comments, starting with "APK file:"
  21. oldComments=$(curl 2>/dev/null -u $GIT_USERNAME:$GIT_TOKEN -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test("APK file:.*") | tostring)' | grep "true|true" | tr -d "\"" | cut -f1 -d"|")
  22. echo $oldComments | while read comment ; do
  23. curl 2>/dev/null -u $GIT_USERNAME:$GIT_TOKEN -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
  24. done
  25. apt-get -y install qrencode
  26. qrencode -o $PR.png "$PUBLIC_URL/$BUILD.apk"
  27. curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD.apk --upload-file build/outputs/apk/qa/debug/qa-debug-*.apk
  28. curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD.png --upload-file $PR.png
  29. curl -u $GIT_USERNAME:$GIT_TOKEN -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments -d "{ \"body\" : \"APK file: $PUBLIC_URL/$BUILD.apk <br/><br/> ![qrcode]($PUBLIC_URL/$BUILD.png) <br/><br/>To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app. \" }"