util.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/bash
  2. # must be run from the root
  3. function set_version ()
  4. {
  5. SLIC3R_VERSION=$(grep "VERSION" xs/src/libslic3r/libslic3r.h | awk -F\" '{print $2}')
  6. }
  7. # Cache the SHA1 for this build commit.
  8. function get_commit () {
  9. if [ ! -z ${TRAVIS_COMMIT+x} ]; then
  10. # Travis sets the sha1 in TRAVIS_COMMIT
  11. COMMIT_SHA1=$(git rev-parse --short $TRAVIS_COMMIT)
  12. else
  13. # should be able to get it properly
  14. COMMIT_SHA1=$(git rev-parse --short HEAD)
  15. fi
  16. }
  17. function set_build_id ()
  18. {
  19. echo "Setting SLIC3R_BUILD_ID"
  20. if [ $(git describe &>/dev/null) ]; then
  21. SLIC3R_BUILD_ID=$(git describe)
  22. TAGGED=true
  23. else
  24. SLIC3R_BUILD_ID=${SLIC3R_VERSION}-${COMMIT_SHA1}
  25. fi
  26. }
  27. function set_branch ()
  28. {
  29. echo "Setting current_branch"
  30. if [ -z ${TRAVIS_BRANCH} ] && [ -z ${GIT_BRANCH+x} ] && [ -z ${APPVEYOR_REPO_BRANCH+x} ]; then
  31. current_branch=$(git symbolic-ref HEAD | sed 's!refs\/heads\/!!')
  32. else
  33. current_branch="unknown"
  34. if [ ! -z ${GIT_BRANCH+x} ]; then
  35. echo "Setting to GIT_BRANCH"
  36. current_branch=$(echo $GIT_BRANCH | cut -d / -f 2)
  37. fi
  38. if [ ! -z ${APPVEYOR_REPO_BRANCH+x} ]; then
  39. echo "Setting to APPVEYOR_REPO_BRANCH"
  40. current_branch=$APPVEYOR_REPO_BRANCH
  41. fi
  42. if [ ! -z ${TRAVIS_BRANCH} ]; then
  43. if [ "${TRAVIS_BRANCH}" != "false" ]; then
  44. echo "Setting to TRAVIS_BRANCH"
  45. current_branch=$TRAVIS_BRANCH
  46. fi
  47. fi
  48. fi
  49. if [ -z ${current_branch+x} ]; then
  50. current_branch="unknown"
  51. fi
  52. }
  53. function set_app_name ()
  54. {
  55. set_branch
  56. if [ "$current_branch" == "master" ]; then
  57. appname=Slic3r
  58. else
  59. appname=Slic3r-${current_branch}
  60. fi
  61. }
  62. function set_pr_id ()
  63. {
  64. echo "Setting PR_ID if available."
  65. if [ ! -z ${GITHUB_PR_NUMBER+x} ]; then
  66. PR_ID=$GITHUB_PR_NUMBER
  67. fi
  68. if [ ! -z ${APPVEYOR_PULL_REQUEST_NUMBER+x} ]; then
  69. PR_ID=$APPVEYOR_PULL_REQUEST_NUMBER
  70. fi
  71. if [ ! -z ${TRAVIS_PULL_REQUEST_BRANCH+x} ] && [ "${TRAVIS_PULL_REQUEST}" != "false" ] ; then
  72. PR_ID=$TRAVIS_PULL_REQUEST
  73. fi
  74. if [ ! -z ${PR_ID+x} ]; then
  75. echo "Setting PR_ID to $PR_ID."
  76. else
  77. echo "PR_ID remains unset."
  78. fi
  79. }
  80. function install_par ()
  81. {
  82. cpanm -q PAR::Packer
  83. cpanm -q Wx::Perl::Packager
  84. }