buildDev 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/bash
  2. #
  3. # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
  4. # SPDX-FileCopyrightText: 2017 Tobias Kaminsky <tobias@kaminsky.me>
  5. # SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
  6. #
  7. date=$(date +%Y%m%d)
  8. oldLibraryCommit=$(grep "androidLibraryVersion\ =" build.gradle)
  9. libraryCommit=$(curl https://api.github.com/repos/nextcloud/android-library/commits/master | jq .sha | sed s'/\"//g')
  10. # use current date for version code/name
  11. sed -i "/versionDev/,/\}/ s/versionCode .*/versionCode $date/" app/build.gradle
  12. sed -i "/versionDev/,/\}/ s/versionName .*/versionName \"$date\"/" app/build.gradle
  13. # change library
  14. sed -i s"#androidLibraryVersion\ =.*#androidLibraryVersion =\"$libraryCommit\"#" build.gradle
  15. ./gradlew --console=plain --dependency-verification lenient -q --write-verification-metadata sha256,pgp help
  16. # build signed apk
  17. source ndk.env
  18. yes | sdkmanager --licenses
  19. if [ ! -e ~/android-sdk/ndk/${NDK_VERSION} ]; then
  20. sdkmanager "ndk;${NDK_VERSION}"
  21. fi
  22. if [ ! -e ~/android-sdk/cmake/${CMAKE_VERSION} ]; then
  23. sdkmanager "cmake;${CMAKE_VERSION}"
  24. fi
  25. ./gradlew assembleVersionDevRelease >> /tmp/dev.log 2>&1
  26. if [ $? != 0 ] ; then
  27. echo "Build error!"
  28. exit 1
  29. fi
  30. # sign
  31. mkdir -p ~/apks
  32. source ~/.gradle/devVersionSecrets
  33. apksigner sign --ks-pass env:VERSION_DEV_STORE_PASSWORD \
  34. --key-pass env:VERSION_DEV_KEY_PASSWORD \
  35. --ks $VERSION_DEV_STORE_FILE \
  36. --out ~/apks/nextcloud-dev-$date.apk \
  37. ./app/build/outputs/apk/versionDev/release/versionDev-release-$date.apk
  38. # use the current date
  39. echo $date > ~/apks/latest
  40. ln -s nextcloud-dev-$date.apk latest.apk
  41. mv latest.apk ~/apks/
  42. # remove all but the latest 5 apks
  43. /bin/ls -t ~/apks/*.apk | awk 'NR>6' | xargs rm -f
  44. lastBuildTag=$(git tag | grep dev | tail -n1)
  45. # Show only the commit subject in the changelog and filter out:
  46. # * Merges
  47. # * Dependabot commits
  48. # * Commits touching only non-user-facing stuff like tests
  49. # * Version bump commits
  50. # * Anything reachable from the previous dev edition tag
  51. changelog=$(git log --no-merges --invert-grep --author=dependabot --pretty='format:%s' HEAD "^$lastBuildTag" -- ':!app/src/androidTest' ':!.*' ':!scripts/' ':!screenshots' ':!CHANGELOG.md' | grep -vE '^daily dev [[:digit:]]{8}$')
  52. # Make Transifex updates have a nicer description
  53. if echo "$changelog" | grep -q 'tx-robot'; then
  54. changelog=$(echo "$changelog" | grep -v 'tx-robot')
  55. # This is a funky bashism - preceding a single-quote string with $ lets you put escape chars in it
  56. changelog="${changelog}"$'\nUpdate translations'
  57. fi
  58. # Check if the library was updated
  59. if ! echo $oldLibraryCommit | grep -q $libraryCommit; then
  60. changelog="${changelog}"$'\nUpdate Nextcloud Android library'
  61. fi
  62. # Collapse dependency updates into a single "Update dependencies" entry
  63. if git log --pretty='format:%an' HEAD "^$lastBuildTag" | grep -q dependabot; then
  64. changelog="${changelog}"$'\nUpdate 3rd-party dependencies'
  65. fi
  66. # changelog
  67. echo "$changelog" > src/versionDev/fastlane/metadata/android/en-US/changelogs/$date.txt
  68. git add .
  69. git commit -m "daily dev $date" -m "$changelog"
  70. git push
  71. git tag dev-$date
  72. git push origin dev-$date