From 363e7020e2463ef0f04cc2da8c0d899bbee44e75 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 17 Oct 2022 18:10:04 +0200 Subject: [PATCH 01/10] Add base for auto-publish job in CI --- .gitlab-ci.yml | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 61c5e2e3a..ae8975fd6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,9 @@ -image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:latest +image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:55-workshop-auto-release stages: - debug - release + - publish before_script: - export GRADLE_USER_HOME=$(pwd)/.gradle @@ -61,13 +62,13 @@ ktlintDebug: 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 + #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 script: - ./gradlew assembleRelease artifacts: @@ -125,3 +126,29 @@ ktlintRelease: artifacts: paths: - app/build/reports/ktlint/ + + +pushToPrebuilt: + stage: publish + needs: ["buildRelease"] + when: manual + variables: + GIT_PUSH_TOKEN: $GIT_PUSH_TOKEN + NEW_APK_PATH: "app/build/outputs/apk/release/" + 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 + - git lfs clone -b 55-test-auto-publish 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/ + - sed -i "6s/.*/LOCAL_SRC_FILES := ${NEW_APK_NAME}/" Apps/Android.mk # todo: improve to replace + - git add Apps + - git commit -m "Update Apps Lounge apk to ${APKVERSION}" + - git push + - git push + + -- GitLab From a9f6c8ba5b2bf8c11fa8ab75ec32939f7e609a66 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 19 Oct 2022 16:41:58 +0200 Subject: [PATCH 02/10] update before_script to get ssh access --- .gitlab-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae8975fd6..d730d9487 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,13 @@ stages: before_script: - export GRADLE_USER_HOME=$(pwd)/.gradle - chmod +x ./gradlew + - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - echo "$SSH_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 # Debug build related jobs -- GitLab From 7158e70526f7c8a8c524977568e07ba9203c977c Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Wed, 19 Oct 2022 14:55:17 +0000 Subject: [PATCH 03/10] add gitlab name and email --- .gitlab-ci.yml | 323 +++++++++++++++++++++++++------------------------ 1 file changed, 162 insertions(+), 161 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d730d9487..7f8ea681b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,161 +1,162 @@ -image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:55-workshop-auto-release - -stages: - - debug - - release - - publish - -before_script: - - export GRADLE_USER_HOME=$(pwd)/.gradle - - chmod +x ./gradlew - - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' - - eval $(ssh-agent -s) - - echo "$SSH_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 - - -# Debug build related jobs -buildDebug: - stage: debug - script: - - ./gradlew assembleDebug - artifacts: - paths: - - app/build/outputs/apk/debug/ - -test: - allow_failure: true - stage: debug - 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/ - -ktlintDebug: - extends: .lintDebugDefault - script: - - ./gradlew app:ktlintCheck --info - artifacts: - paths: - - app/build/reports/ktlint/ - -# 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 - 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 - script: - - ./gradlew lintRelease - artifacts: - paths: - - app/build/reports/ - -ktlintRelease: - extends: .lintReleaseDefault - script: - - ./gradlew app:ktlintCheck --info - artifacts: - paths: - - app/build/reports/ktlint/ - - -pushToPrebuilt: - stage: publish - needs: ["buildRelease"] - when: manual - variables: - GIT_PUSH_TOKEN: $GIT_PUSH_TOKEN - NEW_APK_PATH: "app/build/outputs/apk/release/" - 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 - - git lfs clone -b 55-test-auto-publish 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/ - - sed -i "6s/.*/LOCAL_SRC_FILES := ${NEW_APK_NAME}/" Apps/Android.mk # todo: improve to replace - - git add Apps - - git commit -m "Update Apps Lounge apk to ${APKVERSION}" - - git push - - git push - - +image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:55-workshop-auto-release + +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: + allow_failure: true + stage: debug + 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/ + +ktlintDebug: + extends: .lintDebugDefault + script: + - ./gradlew app:ktlintCheck --info + artifacts: + paths: + - app/build/reports/ktlint/ + +# 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 + 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 + script: + - ./gradlew lintRelease + artifacts: + paths: + - app/build/reports/ + +ktlintRelease: + extends: .lintReleaseDefault + script: + - ./gradlew app:ktlintCheck --info + artifacts: + paths: + - app/build/reports/ktlint/ + + +pushToPrebuilt: + stage: publish + needs: ["buildRelease"] + when: manual + variables: + NEW_APK_PATH: "app/build/outputs/apk/release/" + before_script: + - 'which ssh-agent || ( apt-get update -y && apt-get 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 + 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 + - git lfs clone -b 55-test-auto-publish 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/ + - sed -i "6s/.*/LOCAL_SRC_FILES := ${NEW_APK_NAME}/" Apps/Android.mk # todo: improve to replace + - git config user.email "gitlab@e.foundation" + - git config user.name "gitlab" + - git add Apps + - git commit -m "Update Apps Lounge apk to ${NEW_APK_VERSION}" + - git push + - git push + + -- GitLab From 6b4a98e93edb202c5245864919e5a9f748ab17b9 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Fri, 21 Oct 2022 11:09:29 +0200 Subject: [PATCH 04/10] Add some debug instruction --- .gitlab-ci.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7f8ea681b..832b1996d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -146,17 +146,16 @@ 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:e/os/android_prebuilts_prebuiltapks_lfs.git - git lfs clone -b 55-test-auto-publish 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/ - - sed -i "6s/.*/LOCAL_SRC_FILES := ${NEW_APK_NAME}/" Apps/Android.mk # todo: improve to replace + - ls -l Apps # Debug only + - sed -i "6s/.*/LOCAL_SRC_FILES := ${NEW_APK_NAME}/" Apps/Android.mk # todo: improve to replace based on REGEX¨P and not line number - git config user.email "gitlab@e.foundation" - git config user.name "gitlab" - git add Apps + - git status - git commit -m "Update Apps Lounge apk to ${NEW_APK_VERSION}" - git push - - git push - - + - git push \ No newline at end of file -- GitLab From 74677c227344015b718ea071e344282d27705208 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Mon, 24 Oct 2022 19:37:22 +0530 Subject: [PATCH 05/10] convert to CRLF --- .gitlab-ci.yml | 320 ++++++++++++++++++++++++------------------------- 1 file changed, 160 insertions(+), 160 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 832b1996d..c4c923665 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,161 +1,161 @@ -image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:55-workshop-auto-release - -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: - allow_failure: true - stage: debug - 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/ - -ktlintDebug: - extends: .lintDebugDefault - script: - - ./gradlew app:ktlintCheck --info - artifacts: - paths: - - app/build/reports/ktlint/ - -# 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 - 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 - script: - - ./gradlew lintRelease - artifacts: - paths: - - app/build/reports/ - -ktlintRelease: - extends: .lintReleaseDefault - script: - - ./gradlew app:ktlintCheck --info - artifacts: - paths: - - app/build/reports/ktlint/ - - -pushToPrebuilt: - stage: publish - needs: ["buildRelease"] - when: manual - variables: - NEW_APK_PATH: "app/build/outputs/apk/release/" - before_script: - - 'which ssh-agent || ( apt-get update -y && apt-get 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 - 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 -b 55-test-auto-publish 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/ - - ls -l Apps # Debug only - - sed -i "6s/.*/LOCAL_SRC_FILES := ${NEW_APK_NAME}/" Apps/Android.mk # todo: improve to replace based on REGEX¨P and not line number - - git config user.email "gitlab@e.foundation" - - git config user.name "gitlab" - - git add Apps - - git status - - git commit -m "Update Apps Lounge apk to ${NEW_APK_VERSION}" - - git push +image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:55-workshop-auto-release + +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: + allow_failure: true + stage: debug + 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/ + +ktlintDebug: + extends: .lintDebugDefault + script: + - ./gradlew app:ktlintCheck --info + artifacts: + paths: + - app/build/reports/ktlint/ + +# 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 + 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 + script: + - ./gradlew lintRelease + artifacts: + paths: + - app/build/reports/ + +ktlintRelease: + extends: .lintReleaseDefault + script: + - ./gradlew app:ktlintCheck --info + artifacts: + paths: + - app/build/reports/ktlint/ + + +pushToPrebuilt: + stage: publish + needs: ["buildRelease"] + when: manual + variables: + NEW_APK_PATH: "app/build/outputs/apk/release/" + before_script: + - 'which ssh-agent || ( apt-get update -y && apt-get 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 + 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 -b 55-test-auto-publish 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/ + - ls -l Apps # Debug only + - sed -i "6s/.*/LOCAL_SRC_FILES := ${NEW_APK_NAME}/" Apps/Android.mk # todo: improve to replace based on REGEX¨P and not line number + - git config user.email "gitlab@e.foundation" + - git config user.name "gitlab" + - git add Apps + - git status + - git commit -m "Update Apps Lounge apk to ${NEW_APK_VERSION}" + - git push - git push \ No newline at end of file -- GitLab From 7fc9b65a5af5f5ed0d3bfada33c64b4ee0119685 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Mon, 24 Oct 2022 16:18:09 +0200 Subject: [PATCH 06/10] Remove test & debug code --- .gitlab-ci.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c4c923665..45500320b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -61,13 +61,13 @@ ktlintDebug: 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 + 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 script: - ./gradlew assembleRelease artifacts: @@ -146,11 +146,10 @@ pushToPrebuilt: - NEW_APK_VERSION=$(awk -F '-' '{print $2}' <<< "$NEW_APK_NAME") - echo $NEW_APK_NAME - echo $NEW_APK_VERSION - - git lfs clone -b 55-test-auto-publish git@gitlab.e.foundation:e/os/android_prebuilts_prebuiltapks_lfs.git + - 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/ - - ls -l Apps # Debug only - sed -i "6s/.*/LOCAL_SRC_FILES := ${NEW_APK_NAME}/" Apps/Android.mk # todo: improve to replace based on REGEX¨P and not line number - git config user.email "gitlab@e.foundation" - git config user.name "gitlab" -- GitLab From a35c3f46e73955ef536589168dde4551544317f9 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Tue, 25 Oct 2022 09:59:00 +0200 Subject: [PATCH 07/10] Move command from script to before_script --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 45500320b..afa9ef6f1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -141,6 +141,8 @@ pushToPrebuilt: - chmod 700 ~/.ssh - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts - chmod 644 ~/.ssh/known_hosts + - git config user.email "gitlab@e.foundation" + - git config user.name "gitlab" script: - NEW_APK_NAME=$(basename ${NEW_APK_PATH}*-release.apk) - NEW_APK_VERSION=$(awk -F '-' '{print $2}' <<< "$NEW_APK_NAME") @@ -151,10 +153,8 @@ pushToPrebuilt: - rm Apps/*-release.apk - mv ../${NEW_APK_PATH}/${NEW_APK_NAME} Apps/ - sed -i "6s/.*/LOCAL_SRC_FILES := ${NEW_APK_NAME}/" Apps/Android.mk # todo: improve to replace based on REGEX¨P and not line number - - git config user.email "gitlab@e.foundation" - - git config user.name "gitlab" - git add Apps - git status - - git commit -m "Update Apps Lounge apk to ${NEW_APK_VERSION}" + - git commit -m "Update Apps Lounge apk to ${NEW_APK_VERSION}\nFrom ${CI_COMMIT_SHA}" - git push - - git push \ No newline at end of file + - git push # Sometimes a single push doesn't do all the job, so we have to push twice \ No newline at end of file -- GitLab From 5f01ca39c3b3b1bf10208b6801c68d64d290eab3 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Thu, 27 Oct 2022 09:48:41 +0000 Subject: [PATCH 08/10] Apply 1 suggestion(s) to 1 file(s) --- .gitlab-ci.yml | 318 ++++++++++++++++++++++++------------------------- 1 file changed, 159 insertions(+), 159 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index afa9ef6f1..dbe8f03be 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,160 +1,160 @@ -image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:55-workshop-auto-release - -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: - allow_failure: true - stage: debug - 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/ - -ktlintDebug: - extends: .lintDebugDefault - script: - - ./gradlew app:ktlintCheck --info - artifacts: - paths: - - app/build/reports/ktlint/ - -# 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 - 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 - script: - - ./gradlew lintRelease - artifacts: - paths: - - app/build/reports/ - -ktlintRelease: - extends: .lintReleaseDefault - script: - - ./gradlew app:ktlintCheck --info - artifacts: - paths: - - app/build/reports/ktlint/ - - -pushToPrebuilt: - stage: publish - needs: ["buildRelease"] - when: manual - variables: - NEW_APK_PATH: "app/build/outputs/apk/release/" - before_script: - - 'which ssh-agent || ( apt-get update -y && apt-get 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 user.email "gitlab@e.foundation" - - git config 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/ - - sed -i "6s/.*/LOCAL_SRC_FILES := ${NEW_APK_NAME}/" Apps/Android.mk # todo: improve to replace based on REGEX¨P and not line number - - git add Apps - - git status - - git commit -m "Update Apps Lounge apk to ${NEW_APK_VERSION}\nFrom ${CI_COMMIT_SHA}" - - git push +image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:55-workshop-auto-release + +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: + allow_failure: true + stage: debug + 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/ + +ktlintDebug: + extends: .lintDebugDefault + script: + - ./gradlew app:ktlintCheck --info + artifacts: + paths: + - app/build/reports/ktlint/ + +# 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 + 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 + script: + - ./gradlew lintRelease + artifacts: + paths: + - app/build/reports/ + +ktlintRelease: + extends: .lintReleaseDefault + script: + - ./gradlew app:ktlintCheck --info + artifacts: + paths: + - app/build/reports/ktlint/ + + +pushToPrebuilt: + stage: publish + needs: ["buildRelease"] + when: manual + 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 user.email "gitlab@e.foundation" + - git config 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/ + - sed -i "6s/.*/LOCAL_SRC_FILES := ${NEW_APK_NAME}/" Apps/Android.mk # todo: improve to replace based on REGEX¨P and not line number + - git add Apps + - git status + - git commit -m "Update Apps Lounge apk to ${NEW_APK_VERSION}\nFrom ${CI_COMMIT_SHA}" + - git push - git push # Sometimes a single push doesn't do all the job, so we have to push twice \ No newline at end of file -- GitLab From bce9da65fbc2f5f1db569fb153249b84cae8acba Mon Sep 17 00:00:00 2001 From: Vincent Bourgmayer Date: Thu, 17 Nov 2022 09:10:21 +0000 Subject: [PATCH 09/10] Apply 1 suggestion(s) to 1 file(s) --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dbe8f03be..25ffbe8ce 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -152,7 +152,8 @@ pushToPrebuilt: - cd android_prebuilts_prebuiltapks_lfs - rm Apps/*-release.apk - mv ../${NEW_APK_PATH}/${NEW_APK_NAME} Apps/ - - sed -i "6s/.*/LOCAL_SRC_FILES := ${NEW_APK_NAME}/" Apps/Android.mk # todo: improve to replace based on REGEX¨P and not line number + # 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 "Update Apps Lounge apk to ${NEW_APK_VERSION}\nFrom ${CI_COMMIT_SHA}" -- GitLab From 97cd5ecb1aa4e726c0f0e51b6c3ce5bf0e126dde Mon Sep 17 00:00:00 2001 From: Vincent Bourgmayer Date: Thu, 17 Nov 2022 09:11:51 +0000 Subject: [PATCH 10/10] Apply 1 suggestion(s) to 1 file(s) --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 25ffbe8ce..62a911281 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -158,4 +158,5 @@ pushToPrebuilt: - git status - git commit -m "Update Apps Lounge apk to ${NEW_APK_VERSION}\nFrom ${CI_COMMIT_SHA}" - git push - - git push # Sometimes a single push doesn't do all the job, so we have to push twice \ No newline at end of file + # Sometimes a single push doesn't do all the job, so we have to push twice + - git push \ No newline at end of file -- GitLab