uploadArtifact.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bash
  2. #
  3. # SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
  4. # SPDX-FileCopyrightText: 2019-2022 Tobias Kaminsky <tobias@kaminsky.me>
  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. DAV_URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-artifacts/
  12. PUBLIC_URL=https://www.kaminsky.me/nc-dev/android-artifacts
  13. USER=$1
  14. PASS=$2
  15. BUILD=$3
  16. PR=$4
  17. source scripts/lib.sh
  18. if ! test -e app/build/outputs/apk/qa/debug/qa-debug-*.apk ; then
  19. exit 1
  20. fi
  21. echo "Uploaded artifact to $DAV_URL/$BUILD.apk"
  22. # delete all old comments, starting with "APK file:"
  23. oldComments=$(curl_gh -X GET https://api.github.com/repos/nextcloud/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"|")
  24. echo $oldComments | while read comment ; do
  25. curl_gh -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
  26. done
  27. sudo apt-get -y install qrencode
  28. qrencode -o $PR.png "$PUBLIC_URL/$BUILD.apk"
  29. curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD.apk --upload-file app/build/outputs/apk/qa/debug/qa-debug-*.apk
  30. curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD.png --upload-file $PR.png
  31. curl_gh -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. \" }"