deploy_archives.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. set -e
  3. TEMPDIR=$(mktemp -d)
  4. trap 'rm -rf $TEMPDIR' EXIT
  5. # Publish only for commits in 'stable' and for release tags (e.g. 5.4.1).
  6. if [ "$CI_COMMIT_TAG" ]
  7. then
  8. if [[ "$CI_COMMIT_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
  9. then
  10. echo "Tag $CI_COMMIT_TAG found, proceeding with the build."
  11. else
  12. echo "Commit for an unsupported tag name found, aborting."
  13. exit 0 # Can happen, don't throw an error.
  14. fi
  15. else
  16. if [ "$CI_COMMIT_BRANCH" == 'stable' ]
  17. then
  18. echo "Commit for the stable branch found, proceeding with the build."
  19. else
  20. echo "Push for a branch other than stable found, aborting."
  21. exit 1 # Should not happen with correct CI config, raise an error.
  22. fi
  23. fi
  24. script/build/cleanup.sh
  25. ( find . -type d -name ".git" \
  26. && find . -name ".gitignore" \
  27. && find . -name ".gitkeep" \
  28. && find . -name ".gitmodules" ) | xargs rm -rf
  29. echo "Building archives..."
  30. tar -czf "${TEMPDIR}/zammad-latest.tar.gz" . > /dev/null
  31. tar -cjf "${TEMPDIR}/zammad-latest.tar.bz2" . > /dev/null
  32. zip -r "${TEMPDIR}/zammad-latest.zip" ./* > /dev/null
  33. if [ "$CI_COMMIT_TAG" ]
  34. then
  35. cp "${TEMPDIR}/zammad-latest.tar.gz" "${TEMPDIR}/zammad-${CI_COMMIT_TAG}.tar.gz"
  36. cp "${TEMPDIR}/zammad-latest.tar.bz2" "${TEMPDIR}/zammad-${CI_COMMIT_TAG}.tar.bz2"
  37. cp "${TEMPDIR}/zammad-latest.zip" "${TEMPDIR}/zammad-${CI_COMMIT_TAG}.zip"
  38. fi
  39. echo '#'
  40. echo "# MD5 sums for the release notes"
  41. echo "#"
  42. (cd "$TEMPDIR"; md5sum -- *; echo '#'; ls -lah -- *; echo '#')
  43. #
  44. # Upload to FTP Server
  45. #
  46. if [ -z "$FTP_ZAMMAD_COM_SCP_TARGET" ]
  47. then
  48. echo "Error: the required environment variable FTP_ZAMMAD_COM_SCP_TARGET is missing."
  49. exit 1
  50. fi
  51. echo "Upload files to ${FTP_ZAMMAD_COM_SCP_TARGET}…"
  52. scp "$TEMPDIR"/* "$FTP_ZAMMAD_COM_SCP_TARGET"