drone-build.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #!/bin/bash
  2. set -xe
  3. shopt -s extglob
  4. env
  5. PPA=ppa:nextcloud-devs/client
  6. PPA_ALPHA=ppa:nextcloud-devs/client-alpha
  7. PPA_BETA=ppa:nextcloud-devs/client-beta
  8. OBS_PROJECT=home:ivaradi
  9. OBS_PROJECT_ALPHA=home:ivaradi:alpha
  10. OBS_PROJECT_BETA=home:ivaradi:beta
  11. OBS_PACKAGE=nextcloud-desktop
  12. if test "${DRONE_TARGET_BRANCH}" = "stable-2.6"; then
  13. UBUNTU_DISTRIBUTIONS="bionic focal jammy kinetic"
  14. DEBIAN_DISTRIBUTIONS="buster stretch testing"
  15. else
  16. UBUNTU_DISTRIBUTIONS="jammy kinetic lunar"
  17. DEBIAN_DISTRIBUTIONS="bullseye testing"
  18. fi
  19. pull_request=${DRONE_PULL_REQUEST:=master}
  20. if test -z "${DRONE_WORKSPACE}"; then
  21. DRONE_WORKSPACE=`pwd`
  22. fi
  23. if test -z "${DRONE_DIR}"; then
  24. DRONE_DIR=`dirname ${DRONE_WORKSPACE}`
  25. fi
  26. set +x
  27. if test "$DEBIAN_SECRET_KEY" -a "$DEBIAN_SECRET_IV"; then
  28. openssl aes-256-cbc -K $DEBIAN_SECRET_KEY -iv $DEBIAN_SECRET_IV -in admin/linux/debian/signing-key.txt.enc -d | gpg --import
  29. openssl aes-256-cbc -K $DEBIAN_SECRET_KEY -iv $DEBIAN_SECRET_IV -in admin/linux/debian/oscrc.enc -out ~/.oscrc -d
  30. touch ~/.has_ppa_keys
  31. fi
  32. set -x
  33. cd "${DRONE_WORKSPACE}"
  34. git fetch --tags
  35. read basever revdate kind <<<$(admin/linux/debian/scripts/git2changelog.py /tmp/tmpchangelog stable)
  36. cd "${DRONE_DIR}"
  37. echo "$kind" > kind
  38. if test "$kind" = "alpha"; then
  39. repo=nextcloud-devs/client-alpha
  40. elif test "$kind" = "beta"; then
  41. repo=nextcloud-devs/client-beta
  42. else
  43. repo=nextcloud-devs/client
  44. fi
  45. origsourceopt=""
  46. cp -a ${DRONE_WORKSPACE} nextcloud-desktop_${basever}-${revdate}
  47. tar cjf nextcloud-desktop_${basever}-${revdate}.orig.tar.bz2 --exclude .git --exclude binary nextcloud-desktop_${basever}-${revdate}
  48. cd "${DRONE_WORKSPACE}"
  49. git config --global user.email "drone@noemail.invalid"
  50. git config --global user.name "Drone User"
  51. for distribution in ${UBUNTU_DISTRIBUTIONS} ${DEBIAN_DISTRIBUTIONS}; do
  52. git checkout -- .
  53. git clean -xdf
  54. git fetch origin debian/dist/${distribution}/${DRONE_TARGET_BRANCH}
  55. git checkout origin/debian/dist/${distribution}/${DRONE_TARGET_BRANCH}
  56. git merge ${DRONE_COMMIT}
  57. admin/linux/debian/scripts/git2changelog.py /tmp/tmpchangelog ${distribution} ${revdate} ${basever}
  58. cat /tmp/tmpchangelog debian/changelog > debian/changelog.new
  59. mv debian/changelog.new debian/changelog
  60. fullver=`head -1 debian/changelog | sed "s:nextcloud-desktop (\([^)]*\)).*:\1:"`
  61. EDITOR=true dpkg-source --commit . local-changes
  62. dpkg-source --build .
  63. dpkg-genchanges -S -sa > "../nextcloud-desktop_${fullver}_source.changes"
  64. if test -f ~/.has_ppa_keys; then
  65. debsign -k2265D8767D14AA7B -S
  66. fi
  67. done
  68. cd ..
  69. ls -al
  70. if test "${pull_request}" = "master"; then
  71. if test "$kind" = "alpha"; then
  72. PPA=$PPA_ALPHA
  73. OBS_PROJECT=$OBS_PROJECT_ALPHA
  74. elif test "$kind" = "beta"; then
  75. PPA=$PPA_BETA
  76. OBS_PROJECT=$OBS_PROJECT_BETA
  77. fi
  78. if test -f ~/.has_ppa_keys; then
  79. for distribution in ${UBUNTU_DISTRIBUTIONS}; do
  80. changes=$(ls -1 nextcloud-desktop_*~${distribution}1_source.changes)
  81. if test -f "${changes}"; then
  82. dput $PPA "${changes}" > /dev/null
  83. fi
  84. done
  85. for distribution in ${DEBIAN_DISTRIBUTIONS}; do
  86. pkgsuffix=".${distribution}"
  87. pkgvertag="~${distribution}1"
  88. package="${OBS_PACKAGE}${pkgsuffix}"
  89. OBS_SUBDIR="${OBS_PROJECT}/${package}"
  90. mkdir -p osc
  91. pushd osc
  92. osc co ${OBS_PROJECT} ${package}
  93. if test "$(ls ${OBS_SUBDIR})"; then
  94. osc delete ${OBS_SUBDIR}/*
  95. fi
  96. cp ../nextcloud-desktop*.orig.tar.* ${OBS_SUBDIR}/
  97. cp ../nextcloud-desktop_*[0-9.][0-9]${pkgvertag}.dsc ${OBS_SUBDIR}/
  98. cp ../nextcloud-desktop_*[0-9.][0-9]${pkgvertag}.debian.tar* ${OBS_SUBDIR}/
  99. cp ../nextcloud-desktop_*[0-9.][0-9]${pkgvertag}_source.changes ${OBS_SUBDIR}/
  100. osc add ${OBS_SUBDIR}/*
  101. cd ${OBS_SUBDIR}
  102. osc commit -m "Travis update"
  103. popd
  104. done
  105. fi
  106. fi