uploadArtifact.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bash
  2. #
  3. # SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
  4. # SPDX-FileCopyrightText: 2021 Andy Scherzinger <info@andy-scherzinger.de>
  5. # SPDX-License-Identifier: GPL-3.0-or-later
  6. #
  7. #1: LOG_USERNAME
  8. #2: LOG_PASSWORD
  9. #3: DRONE_BUILD_NUMBER
  10. #4: DRONE_PULL_REQUEST
  11. #5: GITHUB_TOKEN
  12. DAV_URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-artifacts/
  13. PUBLIC_URL=https://www.kaminsky.me/nc-dev/android-artifacts
  14. USER=$1
  15. PASS=$2
  16. BUILD=$3
  17. PR=$4
  18. GITHUB_TOKEN=$5
  19. if ! test -e app/build/outputs/apk/qa/debug/app-qa-*.apk ; then
  20. exit 1
  21. fi
  22. echo "Uploaded artifact to $DAV_URL/$BUILD-talk.apk"
  23. # delete all old comments, starting with "APK file:"
  24. 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"|")
  25. echo $oldComments | while read comment ; do
  26. curl 2>/dev/null --header "authorization: Bearer $GITHUB_TOKEN" -X DELETE https://api.github.com/repos/nextcloud/talk-android/issues/comments/$comment
  27. done
  28. apt-get -y install qrencode
  29. qrencode -o $PR.png "$PUBLIC_URL/$BUILD-talk.apk"
  30. curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD-talk.apk --upload-file app/build/outputs/apk/qa/debug/app-qa-*.apk
  31. curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD-talk.png --upload-file $PR.png
  32. 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. \" }"