uploadArtifact.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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: AGPL-3.0-or-later OR GPL-2.0-only
  6. #
  7. #1: LOG_USERNAME
  8. #2: LOG_PASSWORD
  9. #3: DRONE_BUILD_NUMBER
  10. #4: DRONE_PULL_REQUEST
  11. PUBLIC_URL=https://www.kaminsky.me/nc-dev/android-artifacts
  12. USER=$1
  13. PASS=$2
  14. BUILD=$3
  15. PR=$4
  16. GITHUB_TOKEN=$5
  17. DAV_URL=https://nextcloud.kaminsky.me/remote.php/dav/files/$USER/android-artifacts/
  18. source scripts/lib.sh
  19. if ! test -e app/build/outputs/apk/qa/debug/qa-debug-*.apk ; then
  20. exit 1
  21. fi
  22. echo "Uploaded artifact to $DAV_URL/$BUILD.apk"
  23. # delete all old comments, starting with "APK file:"
  24. 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"|")
  25. echo $oldComments | while read comment ; do
  26. curl_gh -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
  27. done
  28. sudo apt-get -y install qrencode
  29. qrencode -o $PR.png "$PUBLIC_URL/$BUILD.apk"
  30. curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD.apk --upload-file app/build/outputs/apk/qa/debug/qa-debug-*.apk
  31. curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD.png --upload-file $PR.png
  32. 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. \" }"