uploadArtifact.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  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: GITHUB_TOKEN
  7. DAV_URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-artifacts/
  8. PUBLIC_URL=https://www.kaminsky.me/nc-dev/android-artifacts
  9. USER=$1
  10. PASS=$2
  11. BUILD=$3
  12. PR=$4
  13. GITHUB_TOKEN=$5
  14. if ! test -e app/build/outputs/apk/qa/debug/app-qa-*.apk ; then
  15. exit 1
  16. fi
  17. echo "Uploaded artifact to $DAV_URL/$BUILD-talk.apk"
  18. # delete all old comments, starting with "APK file:"
  19. oldComments=$(curl 2>/dev/null --header "authorization: Bearer $GITHUB_TOKEN" -X GET https://api.github.com/repos/nextcloud/talk-android/issues/$PR/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("github-actions") | tostring) + "|" + (.body | test("APK file:.*") | tostring)' | grep "true|true" | tr -d "\"" | cut -f1 -d"|")
  20. echo $oldComments | while read comment ; do
  21. curl 2>/dev/null --header "authorization: Bearer $GITHUB_TOKEN" -X DELETE https://api.github.com/repos/nextcloud/talk-android/issues/comments/$comment
  22. done
  23. apt-get -y install qrencode
  24. qrencode -o $PR.png "$PUBLIC_URL/$BUILD-talk.apk"
  25. curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD-talk.apk --upload-file app/build/outputs/apk/qa/debug/app-qa-*.apk
  26. curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD-talk.png --upload-file $PR.png
  27. curl --header "authorization: Bearer $GITHUB_TOKEN" -X POST https://api.github.com/repos/nextcloud/talk-android/issues/$PR/comments -d "{ \"body\" : \"APK file: $PUBLIC_URL/$BUILD-talk.apk <br/><br/> ![qrcode]($PUBLIC_URL/$BUILD-talk.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 Talk app. \" }"