diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3293d44a1e4b3c33610cf956aaf9acf8eb00f999..233c587ddfc665883a1deec39f654c14ec231f89 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,160 +1,6 @@ -image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:master +include: + - project: 'e/templates' + ref: gitlab-ci-apps + file: '/gitlab-ci/.ci-apps.yml' -variables: - SENTRY_DSN: $SENTRY_DSN - -stages: - - debug - - release - - publish - -before_script: - - export GRADLE_USER_HOME=$(pwd)/.gradle - - chmod +x ./gradlew - -# Debug build related jobs -buildDebug: - stage: debug - script: - - ./gradlew assembleDebug - artifacts: - paths: - - app/build/outputs/apk/debug/ - -test: - stage: release - rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: always - script: - - ./gradlew test -PtestAccountName="$testAccountName" -PtestAccountPwd="$testAccountPwd" -PtestServerUrl="$testServerUrl" - artifacts: - when: always - paths: - - app/build/test-results/*/TEST-*.xml - - app/build/reports/tests/* - reports: - junit: app/build/test-results/*/TEST-*.xml - -# Default lint configuration for debug builds -# Manual as we don't want to run them generally for debug builds -.lintDebugDefault: - stage: debug - when: manual - allow_failure: true - -lintDebug: - extends: .lintDebugDefault - script: - - ./gradlew lintDebug - artifacts: - paths: - - app/build/reports/ - -# Release build related jobs - -# Default configuration for release builds -# Only on "master", "merge_request_event" and protected branches -buildRelease: - stage: release - allow_failure: false - rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: always - - if: '$CI_COMMIT_REF_PROTECTED == "true"' - when: always - - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' - when: always - - if: '$CI_COMMIT_TAG !~ "/^$/"' - when: always - script: - - ./gradlew assembleRelease - artifacts: - paths: - - app/build/outputs/apk/release/ - -# Release jobs to generate signed artifacts -.releaseSigned: - stage: release - allow_failure: false - before_script: - - export GRADLE_USER_HOME=$(pwd)/.gradle - - chmod +x ./gradlew - - echo "${KEYSTORE}" | base64 -d > keystore/proprietary.keystore - rules: - - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' - when: always - - if: '$CI_COMMIT_REF_PROTECTED == "true"' - when: always - -buildReleaseDev: - extends: .releaseSigned - script: - - ./gradlew assembleReleaseDev - artifacts: - paths: - - app/build/outputs/apk/releaseDev/ - -buildReleaseStable: - extends: .releaseSigned - script: - - ./gradlew assembleReleaseStable - artifacts: - paths: - - app/build/outputs/apk/releaseStable/ - -# Default lint configuration for release jobs -.lintReleaseDefault: - stage: release - when: always - allow_failure: false - -lintRelease: - extends: .lintReleaseDefault - rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: always - script: - - ./gradlew lintRelease - - ./gradlew detekt - artifacts: - paths: - - app/build/reports/ - - build/reports/ - -pushToPrebuilt: - stage: publish - needs: ["buildRelease"] - rules: - - if: '$CI_COMMIT_TAG !~ "/^$/"' - when: manual - - when: never - variables: - NEW_APK_PATH: "app/build/outputs/apk/release/" - before_script: - - 'which ssh-agent || ( apt update -y && apt install openssh-client -y )' - - eval $(ssh-agent -s) - - echo "$SSH_E_ROBOT_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - - mkdir -p ~/.ssh - - chmod 700 ~/.ssh - - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts - - chmod 644 ~/.ssh/known_hosts - - git config --global user.email "gitlab@e.foundation" - - git config --global user.name "gitlab" - script: - - NEW_APK_NAME=$(basename ${NEW_APK_PATH}*-release.apk) - - NEW_APK_VERSION=$(awk -F '-' '{print $2}' <<< "$NEW_APK_NAME") - - echo $NEW_APK_NAME - - echo $NEW_APK_VERSION - - git lfs clone git@gitlab.e.foundation:e/os/android_prebuilts_prebuiltapks_lfs.git - - cd android_prebuilts_prebuiltapks_lfs - - rm Apps/*-release.apk - - mv ../${NEW_APK_PATH}/${NEW_APK_NAME} Apps/ - # todo: improve to replace sed command, by a new one based on REGEXP (instead of using line number) - - sed -i "6s/.*/LOCAL_SRC_FILES := ${NEW_APK_NAME}/" Apps/Android.mk - - git add Apps - - git status - - git commit -m "App Lounge - ${NEW_APK_VERSION}, ${CI_COMMIT_TAG}" -m "From ${CI_COMMIT_SHA}, pipeline ${CI_PIPELINE_ID}" - - git push - # Sometimes a single push doesn't do all the job, so we have to push twice - - git push +# finishing the script