Loading gitlab-ci/.ci-apps.yml +100 −42 Original line number Diff line number Diff line image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:55-workshop-auto-release image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:master variables: SENTRY_DSN: $SENTRY_DSN stages: - build - test - mycustomstage - debug - release - publish Loading @@ -14,46 +12,75 @@ before_script: - export GRADLE_USER_HOME=$(pwd)/.gradle - chmod +x ./gradlew # 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 cache: key: ${CI_PROJECT_ID} lintDebug: extends: .lintDebugDefault script: - ./gradlew lintDebug artifacts: paths: - .gradle/ - app/build/reports/ # Debug build related jobs dummy: stage: test only: - /^.*playground.*$/ ktlintDebug: extends: .lintDebugDefault script: - echo "dummy job running $CI_COMMIT_REF_NAME! $CI_COMMIT_BRANCH" - ./gradlew app:ktlintCheck --info artifacts: paths: - app/build/reports/ktlint/ lint: stage: build # Release build related jobs # Default configuration for release builds # Only on "master", "merge_request_event" and protected branches # Debug build related jobs buildDebug: stage: debug script: - ./gradlew lintRelease - echo "lint fininshed" - ./gradlew assembleDebug artifacts: paths: - app/build/outputs/apk/debug/ dummy_job: stage: mycustomstage # Default lint configuration for release jobs .lintReleaseDefault: stage: release when: always allow_failure: false lintRelease: extends: .lintReleaseDefault rules: - if: '$CI_COMMIT_MESSAGE =~ "/^.*dummy_job.*$/"' when: manual - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' when: always script: - echo "second dummy job running $CI_COMMIT_MESSAGE $CI_COMMIT_BRANCH $CI_PIPELINE_SOURCE" - ./gradlew lintRelease artifacts: paths: - app/build/reports/ ktlintRelease: extends: .lintReleaseDefault script: - ./gradlew app:ktlintCheck --info artifacts: paths: - app/build/reports/ktlint/ test: stage: test allow_failure: false stage: release rules: - if: '$CI_PIPELINE_SOURCE == "push"' - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' when: always script: - echo "Test run Started!" - ./gradlew test - echo "Test running ended!" artifacts: when: always paths: Loading @@ -62,15 +89,17 @@ test: reports: junit: app/build/test-results/*/TEST-*.xml # 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_COMMIT_MESSAGE =~ "/^.*dummy_job.*$/"' - 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 Loading @@ -78,11 +107,42 @@ buildRelease: 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/ pushToPrebuilt: stage: publish needs: ["buildRelease"] rules: - if: '$CI_COMMIT_MESSAGE =~ "/^.*dummy_job.*$/"' - if: '$CI_COMMIT_TAG !~ "/^$/"' when: manual - when: never variables: Loading @@ -90,6 +150,7 @@ pushToPrebuilt: 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 Loading @@ -101,10 +162,10 @@ pushToPrebuilt: - 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:hasibprince/applounge_git_lfs.git - cd applounge_git_lfs - rm *-release.apk - mv ../${NEW_APK_PATH}/${NEW_APK_NAME} / - 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 Loading @@ -113,6 +174,3 @@ pushToPrebuilt: - git push # Sometimes a single push doesn't do all the job, so we have to push twice - git push after_script: - echo "after script is executed" Loading
gitlab-ci/.ci-apps.yml +100 −42 Original line number Diff line number Diff line image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:55-workshop-auto-release image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:master variables: SENTRY_DSN: $SENTRY_DSN stages: - build - test - mycustomstage - debug - release - publish Loading @@ -14,46 +12,75 @@ before_script: - export GRADLE_USER_HOME=$(pwd)/.gradle - chmod +x ./gradlew # 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 cache: key: ${CI_PROJECT_ID} lintDebug: extends: .lintDebugDefault script: - ./gradlew lintDebug artifacts: paths: - .gradle/ - app/build/reports/ # Debug build related jobs dummy: stage: test only: - /^.*playground.*$/ ktlintDebug: extends: .lintDebugDefault script: - echo "dummy job running $CI_COMMIT_REF_NAME! $CI_COMMIT_BRANCH" - ./gradlew app:ktlintCheck --info artifacts: paths: - app/build/reports/ktlint/ lint: stage: build # Release build related jobs # Default configuration for release builds # Only on "master", "merge_request_event" and protected branches # Debug build related jobs buildDebug: stage: debug script: - ./gradlew lintRelease - echo "lint fininshed" - ./gradlew assembleDebug artifacts: paths: - app/build/outputs/apk/debug/ dummy_job: stage: mycustomstage # Default lint configuration for release jobs .lintReleaseDefault: stage: release when: always allow_failure: false lintRelease: extends: .lintReleaseDefault rules: - if: '$CI_COMMIT_MESSAGE =~ "/^.*dummy_job.*$/"' when: manual - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' when: always script: - echo "second dummy job running $CI_COMMIT_MESSAGE $CI_COMMIT_BRANCH $CI_PIPELINE_SOURCE" - ./gradlew lintRelease artifacts: paths: - app/build/reports/ ktlintRelease: extends: .lintReleaseDefault script: - ./gradlew app:ktlintCheck --info artifacts: paths: - app/build/reports/ktlint/ test: stage: test allow_failure: false stage: release rules: - if: '$CI_PIPELINE_SOURCE == "push"' - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' when: always script: - echo "Test run Started!" - ./gradlew test - echo "Test running ended!" artifacts: when: always paths: Loading @@ -62,15 +89,17 @@ test: reports: junit: app/build/test-results/*/TEST-*.xml # 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_COMMIT_MESSAGE =~ "/^.*dummy_job.*$/"' - 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 Loading @@ -78,11 +107,42 @@ buildRelease: 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/ pushToPrebuilt: stage: publish needs: ["buildRelease"] rules: - if: '$CI_COMMIT_MESSAGE =~ "/^.*dummy_job.*$/"' - if: '$CI_COMMIT_TAG !~ "/^$/"' when: manual - when: never variables: Loading @@ -90,6 +150,7 @@ pushToPrebuilt: 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 Loading @@ -101,10 +162,10 @@ pushToPrebuilt: - 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:hasibprince/applounge_git_lfs.git - cd applounge_git_lfs - rm *-release.apk - mv ../${NEW_APK_PATH}/${NEW_APK_NAME} / - 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 Loading @@ -113,6 +174,3 @@ pushToPrebuilt: - git push # Sometimes a single push doesn't do all the job, so we have to push twice - git push after_script: - echo "after script is executed"