deploy.sh 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. set -e
  2. FullExecPath=$PWD
  3. pushd `dirname $0` > /dev/null
  4. FullScriptPath=`pwd`
  5. popd > /dev/null
  6. if [ ! -d "$FullScriptPath/../../../DesktopPrivate" ]; then
  7. echo ""
  8. echo "This script is for building the production version of Telegram Desktop."
  9. echo ""
  10. echo "For building custom versions please visit the build instructions page at:"
  11. echo "https://github.com/telegramdesktop/tdesktop/#build-instructions"
  12. exit
  13. fi
  14. Error () {
  15. cd $FullExecPath
  16. echo "$1"
  17. exit 1
  18. }
  19. DeployTarget="$1"
  20. if [ ! -f "$FullScriptPath/target" ]; then
  21. Error "Build target not found!"
  22. fi
  23. while IFS='' read -r line || [[ -n "$line" ]]; do
  24. BuildTarget="$line"
  25. done < "$FullScriptPath/target"
  26. while IFS='' read -r line || [[ -n "$line" ]]; do
  27. set $line
  28. eval $1="$2"
  29. done < "$FullScriptPath/version"
  30. if [ "$AlphaVersion" != "0" ]; then
  31. AppVersion="$AlphaVersion"
  32. AppVersionStrFull="${AppVersionStr}_${AlphaVersion}"
  33. AlphaKeyFile="talpha_${AppVersion}_key"
  34. elif [ "$BetaChannel" == "0" ]; then
  35. AppVersionStrFull="$AppVersionStr"
  36. else
  37. AppVersionStrFull="$AppVersionStr.beta"
  38. fi
  39. echo ""
  40. HomePath="$FullScriptPath/.."
  41. DeployMac="0"
  42. DeployWin="0"
  43. DeployWin64="0"
  44. DeployWinArm="0"
  45. DeployLinux="0"
  46. if [ "$DeployTarget" == "mac" ]; then
  47. DeployMac="1"
  48. echo "Deploying version $AppVersionStrFull for macOS.."
  49. elif [ "$DeployTarget" == "win" ]; then
  50. DeployWin="1"
  51. echo "Deploying version $AppVersionStrFull for Windows 32 bit.."
  52. elif [ "$DeployTarget" == "win64" ]; then
  53. DeployWin64="1"
  54. echo "Deploying version $AppVersionStrFull for Windows 64 bit.."
  55. elif [ "$DeployTarget" == "winarm" ]; then
  56. DeployWinArm="1"
  57. echo "Deploying version $AppVersionStrFull for Windows on ARM.."
  58. elif [ "$DeployTarget" == "linux" ]; then
  59. DeployLinux="1"
  60. echo "Deploying version $AppVersionStrFull for Linux 64 bit.."
  61. else
  62. DeployMac="1"
  63. DeployWin="1"
  64. DeployWin64="1"
  65. DeployWinArm="1"
  66. DeployLinux="1"
  67. echo "Deploying five versions of $AppVersionStrFull: for Windows 32 bit / 64 bit / on ARM, macOS and Linux 64 bit.."
  68. fi
  69. if [ "$BuildTarget" == "mac" ]; then
  70. BackupPath="$HOME/Projects/backup/tdesktop"
  71. elif [ "$BuildTarget" == "linux" ]; then
  72. BackupPath="/media/psf/Home/Projects/backup/tdesktop"
  73. if [ ! -d "$BackupPath" ]; then
  74. BackupPath="/mnt/c/Telegram/Projects/backup/tdesktop"
  75. fi
  76. else
  77. Error "Can't deploy here"
  78. fi
  79. MacDeployPath="$BackupPath/$AppVersionStrMajor/$AppVersionStrFull/tmac"
  80. MacUpdateFile="tmacupd$AppVersion"
  81. ARMacUpdateFile="tarmacupd$AppVersion"
  82. MacSetupFile="tsetup.$AppVersionStrFull.dmg"
  83. MacRemoteFolder="tmac"
  84. WinDeployPath="$BackupPath/$AppVersionStrMajor/$AppVersionStrFull/tsetup"
  85. WinUpdateFile="tupdate$AppVersion"
  86. WinSetupFile="tsetup.$AppVersionStrFull.exe"
  87. WinPortableFile="tportable.$AppVersionStrFull.zip"
  88. WinRemoteFolder="tsetup"
  89. Win64DeployPath="$BackupPath/$AppVersionStrMajor/$AppVersionStrFull/tx64"
  90. Win64UpdateFile="tx64upd$AppVersion"
  91. Win64SetupFile="tsetup-x64.$AppVersionStrFull.exe"
  92. Win64PortableFile="tportable-x64.$AppVersionStrFull.zip"
  93. Win64RemoteFolder="tx64"
  94. WinArmDeployPath="$BackupPath/$AppVersionStrMajor/$AppVersionStrFull/tarm64"
  95. WinArmUpdateFile="tarm64upd$AppVersion"
  96. WinArmSetupFile="tsetup-arm64.$AppVersionStrFull.exe"
  97. WinArmPortableFile="tportable-arm64.$AppVersionStrFull.zip"
  98. WinArmRemoteFolder="tarm64"
  99. LinuxDeployPath="$BackupPath/$AppVersionStrMajor/$AppVersionStrFull/tlinux"
  100. LinuxUpdateFile="tlinuxupd$AppVersion"
  101. LinuxSetupFile="tsetup.$AppVersionStrFull.tar.xz"
  102. LinuxRemoteFolder="tlinux"
  103. DeployPath="$BackupPath/$AppVersionStrMajor/$AppVersionStrFull"
  104. if [ "$AlphaVersion" != "0" ]; then
  105. if [ "$DeployTarget" == "win" ]; then
  106. AlphaFilePath="$WinDeployPath/$AlphaKeyFile"
  107. elif [ "$DeployTarget" == "win64" ]; then
  108. AlphaFilePath="$Win64DeployPath/$AlphaKeyFile"
  109. elif [ "$DeployTarget" == "winarm" ]; then
  110. AlphaFilePath="$WinArmDeployPath/$AlphaKeyFile"
  111. elif [ "$DeployTarget" == "linux" ]; then
  112. AlphaFilePath="$LinuxDeployPath/$AlphaKeyFile"
  113. else
  114. AlphaFilePath="$MacDeployPath/$AlphaKeyFile"
  115. fi
  116. if [ ! -f "$AlphaFilePath" ]; then
  117. Error "Alpha key file for $AppVersionStrFull not found."
  118. fi
  119. while IFS='' read -r line || [[ -n "$line" ]]; do
  120. AlphaSignature="$line"
  121. done < "$AlphaFilePath"
  122. MacUpdateFile="${MacUpdateFile}_${AlphaSignature}"
  123. ARMacUpdateFile="${ARMacUpdateFile}_${AlphaSignature}"
  124. MacSetupFile="talpha${AlphaVersion}_${AlphaSignature}.zip"
  125. WinUpdateFile="${WinUpdateFile}_${AlphaSignature}"
  126. WinPortableFile="talpha${AlphaVersion}_${AlphaSignature}.zip"
  127. Win64UpdateFile="${Win64UpdateFile}_${AlphaSignature}"
  128. Win64PortableFile="talpha${AlphaVersion}_${AlphaSignature}.zip"
  129. WinArmUpdateFile="${WinArmUpdateFile}_${AlphaSignature}"
  130. WinArmPortableFile="talpha${AlphaVersion}_${AlphaSignature}.zip"
  131. LinuxUpdateFile="${LinuxUpdateFile}_${AlphaSignature}"
  132. LinuxSetupFile="talpha${AlphaVersion}_${AlphaSignature}.tar.xz"
  133. fi
  134. if [ "$DeployMac" == "1" ]; then
  135. if [ ! -f "$MacDeployPath/$MacUpdateFile" ]; then
  136. Error "$MacDeployPath/$MacUpdateFile not found!";
  137. fi
  138. if [ ! -f "$MacDeployPath/$ARMacUpdateFile" ]; then
  139. Error "$MacDeployPath/$ARMacUpdateFile not found!";
  140. fi
  141. if [ ! -f "$MacDeployPath/$MacSetupFile" ]; then
  142. Error "$MacDeployPath/$MacSetupFile not found!"
  143. fi
  144. fi
  145. if [ "$DeployWin" == "1" ]; then
  146. if [ ! -f "$WinDeployPath/$WinUpdateFile" ]; then
  147. Error "$WinUpdateFile not found!"
  148. fi
  149. if [ "$AlphaVersion" == "0" ]; then
  150. if [ ! -f "$WinDeployPath/$WinSetupFile" ]; then
  151. Error "$WinSetupFile not found!"
  152. fi
  153. fi
  154. if [ ! -f "$WinDeployPath/$WinPortableFile" ]; then
  155. Error "$WinPortableFile not found!"
  156. fi
  157. fi
  158. if [ "$DeployWin64" == "1" ]; then
  159. if [ ! -f "$Win64DeployPath/$Win64UpdateFile" ]; then
  160. Error "$Win64UpdateFile not found!"
  161. fi
  162. if [ "$AlphaVersion" == "0" ]; then
  163. if [ ! -f "$Win64DeployPath/$Win64SetupFile" ]; then
  164. Error "$Win64SetupFile not found!"
  165. fi
  166. fi
  167. if [ ! -f "$Win64DeployPath/$Win64PortableFile" ]; then
  168. Error "$Win64PortableFile not found!"
  169. fi
  170. fi
  171. if [ "$DeployWinArm" == "1" ]; then
  172. if [ ! -f "$WinArmDeployPath/$WinArmUpdateFile" ]; then
  173. Error "$WinArmUpdateFile not found!"
  174. fi
  175. if [ "$AlphaVersion" == "0" ]; then
  176. if [ ! -f "$WinArmDeployPath/$WinArmSetupFile" ]; then
  177. Error "$WinArmSetupFile not found!"
  178. fi
  179. fi
  180. if [ ! -f "$WinArmDeployPath/$WinArmPortableFile" ]; then
  181. Error "$WinArmPortableFile not found!"
  182. fi
  183. fi
  184. if [ "$DeployLinux" == "1" ]; then
  185. if [ ! -f "$LinuxDeployPath/$LinuxUpdateFile" ]; then
  186. Error "$LinuxDeployPath/$LinuxUpdateFile not found!"
  187. fi
  188. if [ ! -f "$LinuxDeployPath/$LinuxSetupFile" ]; then
  189. Error "$LinuxDeployPath/$LinuxSetupFile not found!"
  190. fi
  191. fi
  192. $FullScriptPath/../../../DesktopPrivate/mount.sh
  193. declare -a Files
  194. if [ "$DeployMac" == "1" ]; then
  195. Files+=("tmac/$MacUpdateFile" "tmac/$ARMacUpdateFile" "tmac/$MacSetupFile")
  196. fi
  197. if [ "$DeployWin" == "1" ]; then
  198. Files+=("tsetup/$WinUpdateFile" "tsetup/$WinPortableFile")
  199. if [ "$AlphaVersion" == "0" ]; then
  200. Files+=("tsetup/$WinSetupFile")
  201. fi
  202. fi
  203. if [ "$DeployWin64" == "1" ]; then
  204. Files+=("tx64/$Win64UpdateFile" "tx64/$Win64PortableFile")
  205. if [ "$AlphaVersion" == "0" ]; then
  206. Files+=("tx64/$Win64SetupFile")
  207. fi
  208. fi
  209. if [ "$DeployWinArm" == "1" ]; then
  210. Files+=("tarm64/$WinArmUpdateFile" "tarm64/$WinArmPortableFile")
  211. if [ "$AlphaVersion" == "0" ]; then
  212. Files+=("tarm64/$WinArmSetupFile")
  213. fi
  214. fi
  215. if [ "$DeployLinux" == "1" ]; then
  216. Files+=("tlinux/$LinuxUpdateFile" "tlinux/$LinuxSetupFile")
  217. fi
  218. cd $DeployPath
  219. rsync -avR --no-g --progress ${Files[@]} "$FullScriptPath/../../../DesktopPrivate/remote/files"
  220. echo "Version $AppVersionStrFull was deployed!"
  221. cd $FullExecPath