buildDev 2.8 KB

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