variables:
  PACKAGE_VERSION: "continuous"
  DEBUG_BINARY: "com.aurora.store.debug_${CI_COMMIT_SHORT_SHA}.apk"
  DEBUG_BINARY_PATH: "app/build/outputs/apk/debug/app-debug.apk"
  PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/debug/${PACKAGE_VERSION}"

stages:
- build
- upload
- release

assembleDebug:
  stage: build
  image: theimpulson/gitlab-ci-android:latest
  script:
    - './gradlew assembleDebug'
  artifacts:
    paths:
    - $DEBUG_BINARY_PATH

uploadDebug:
  stage: upload
  image: curlimages/curl:latest
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script:
    - 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file ${DEBUG_BINARY_PATH} ${PACKAGE_REGISTRY_URL}/${DEBUG_BINARY}'
