.gitlab-ci.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. stages:
  2. - environment
  3. - build
  4. - test
  5. - internal
  6. - alpha
  7. - beta
  8. - production
  9. .updateContainerJob:
  10. image: docker:stable
  11. stage: environment
  12. services:
  13. - docker:dind
  14. script:
  15. - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
  16. - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG || true
  17. - docker build --cache-from $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG .
  18. - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
  19. updateContainer:
  20. extends: .updateContainerJob
  21. only:
  22. changes:
  23. - Dockerfile
  24. ensureContainer:
  25. extends: .updateContainerJob
  26. allow_failure: true
  27. before_script:
  28. - "mkdir -p ~/.docker && echo '{\"experimental\": \"enabled\"}' > ~/.docker/config.json"
  29. - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
  30. # Skip update container `script` if the container already exists
  31. # via https://gitlab.com/gitlab-org/gitlab-ce/issues/26866#note_97609397 -> https://stackoverflow.com/a/52077071/796832
  32. - docker manifest inspect $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG > /dev/null && exit || true
  33. except:
  34. changes:
  35. - Dockerfile
  36. .build_job:
  37. image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
  38. stage: build
  39. before_script:
  40. - chmod +x gradlew
  41. - "export VERSION_CODE=$(($CI_PIPELINE_IID)) && echo $VERSION_CODE"
  42. - "export VERSION_SHA=`echo ${CI_COMMIT_SHA:0:8}` && echo $VERSION_SHA"
  43. artifacts:
  44. paths:
  45. - app/build/outputs
  46. buildDebug:
  47. extends: .build_job
  48. script:
  49. - bundle exec fastlane buildDebug
  50. buildRelease:
  51. extends: .build_job
  52. script:
  53. - bundle exec fastlane buildRelease
  54. environment:
  55. name: production
  56. testDebug:
  57. image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
  58. stage: test
  59. dependencies:
  60. - buildDebug
  61. script:
  62. - chmod +x gradlew
  63. - bundle exec fastlane test
  64. .promote_job:
  65. image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
  66. when: manual
  67. dependencies: []
  68. before_script:
  69. - echo You need to add your google_play_api_key.json file for this to work. Please see project's README.md. && false
  70. - chmod +x gradlew
  71. after_script:
  72. - rm -f ~/google_play_api_key.json
  73. publishInternal:
  74. extends: .promote_job
  75. image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
  76. stage: internal
  77. dependencies:
  78. - buildRelease
  79. when: manual
  80. script:
  81. - bundle exec fastlane internal
  82. promoteAlpha:
  83. extends: .promote_job
  84. stage: alpha
  85. script:
  86. - bundle exec fastlane promote_internal_to_alpha
  87. promoteBeta:
  88. extends: .promote_job
  89. stage: beta
  90. script:
  91. - bundle exec fastlane promote_alpha_to_beta
  92. promoteProduction:
  93. extends: .promote_job
  94. stage: production
  95. # We only allow production promotion on master because
  96. # in this way you can protect production scoped secret variables
  97. only:
  98. - master
  99. script:
  100. - bundle exec fastlane promote_beta_to_production