Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e73788f5 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

mail: add release related jobs

parent 462a1ae5
Loading
Loading
Loading
Loading
+154 −3
Original line number Diff line number Diff line
image: "registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:master"

variables:
  APK_PATH: "app-thunderbird/build/outputs/apk/foss/release"
  UNSIGNED_APK: "Mail-unsigned.apk"
  COMMUNITY_APK: "Mail-community.apk"
  OFFICIAL_APK: "Mail-official.apk"
  TEST_APK: "Mail-test.apk"

stages:
- update-from-upstream
- build
- gitlab_release

before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
@@ -18,12 +27,154 @@ debug:
  - ./gradlew :app-thunderbird:assembleFossDebug
  artifacts:
    paths:
    - app-thunderbird/build/outputs/apk/foss
    - app-thunderbird/build/outputs/apk/foss/debug

release:
  stage: build
  script:
    - ./gradlew :app-thunderbird:assembleFossRelease
    - cd app-thunderbird/build/outputs/apk/foss/release
    - cp app-thunderbird-foss-release.apk "$UNSIGNED_APK"
  artifacts:
    paths:
      - app-thunderbird/build/outputs/apk/foss/release

init_submodules:
  stage: gitlab_release
  rules:
    - if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"'
      when: on_success
  script:
    - |
      git clone https://gitlab.e.foundation/e/os/system-apps-update-info.git systemAppsUpdateInfo
  artifacts:
    paths:
    - app-thunderbird/build/outputs/apk/foss
      - systemAppsUpdateInfo/scripts/

generate-apks:
  stage: gitlab_release
  rules:
    - if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"'
      when: on_success
  needs:
    - init_submodules
    - release
  dependencies:
    - init_submodules
    - release
  script:
    - |
      ./systemAppsUpdateInfo/scripts/generate-apks.sh \
      "$APK_PATH" "$UNSIGNED_APK" "$COMMUNITY_APK" "$OFFICIAL_APK" "$TEST_APK"
  artifacts:
    paths:
      - $APK_PATH/$UNSIGNED_APK
      - $APK_PATH/$COMMUNITY_APK
      - $APK_PATH/$OFFICIAL_APK
      - $APK_PATH/$TEST_APK

create-json-files:
  stage: gitlab_release
  dependencies:
    - init_submodules
    - generate-apks
  needs:
    - init_submodules
    - generate-apks
  rules:
    - if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"'
      when: on_success
  script:
    - |
      ./systemAppsUpdateInfo/scripts/create-json-files.sh \
      "$APK_PATH" "$UNSIGNED_APK" "$COMMUNITY_APK" "$OFFICIAL_APK" "$TEST_APK"
  artifacts:
    paths:
      - community.json
      - official.json
      - test.json

create-test-release:
  stage: gitlab_release
  dependencies:
    - init_submodules
  needs:
    - init_submodules
    - create-json-files
    - generate-apks
  rules:
    - if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"'
      when: manual
  script:
    - |
      ./systemAppsUpdateInfo/scripts/create-test-release.sh \
      "$APK_PATH" "$TEST_APK"
  allow_failure: true

create-release:
  stage: gitlab_release
  dependencies:
    - init_submodules
  needs:
    - init_submodules
    - create-json-files
    - generate-apks
  rules:
    - if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"'
      when: manual
  script:
    - |
      ./systemAppsUpdateInfo/scripts/create-release.sh \
      "$APK_PATH" "$UNSIGNED_APK" "$COMMUNITY_APK" "$OFFICIAL_APK"
  allow_failure: true

.update-from-upstream:
  image: registry.gitlab.e.foundation/e/tools/docker-tools:latest
  stage: update-from-upstream
  rules:
    - if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_REF_NAME == $LOCAL_BRANCH'
  variables:
    CI_PROJECT_SSH_URL: git@gitlab.e.foundation:$CI_PROJECT_PATH
    GIT_STRATEGY: none
  before_script:
    - eval $(ssh-agent -s)
    - echo "${SSH_E_ROBOT_PRIVATE_KEY}" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "${SSH_KNOWN_HOSTS}" > ~/.ssh/known_hosts
    - echo "${SSH_KNOWN_HOSTS}"
    - chmod 644 ~/.ssh/known_hosts
    - git config --global user.email $GITLAB_USER_EMAIL
    - git config --global user.name "$GITLAB_USER_NAME"
    - cd $CI_BUILD_DIR
    - rm -rf $CI_PROJECT_DIR
    - git clone $CI_PROJECT_SSH_URL $CI_PROJECT_DIR
    - cd $CI_PROJECT_DIR
  script:
    # update $UPSTREAM_BRANCH & tags
    - git fetch origin
    - git checkout $UPSTREAM_BRANCH
    - git remote add upstream $UPSTREAM_URL
    - git fetch upstream
    - git pull upstream $UPSTREAM_DEFAULT_BRANCH
    - git push origin $UPSTREAM_BRANCH
    - git push origin --tags
    # checkout to latest tag commit to $TEMP_LATEST_TAG_BRANCH
    - git checkout $(git describe --tags --abbrev=0)
    - git checkout -b $TEMP_LATEST_TAG_BRANCH
    # merge $LOCAL_BRANCH with $TEMP_LATEST_TAG_BRANCH & push
    - git checkout $LOCAL_BRANCH
    - git merge $TEMP_LATEST_TAG_BRANCH
    - git push origin $LOCAL_BRANCH
    # remove unwanted local branch & remote
    - git branch -D $TEMP_LATEST_TAG_BRANCH
    - git remote remove upstream

update-default-branch:
  extends: .update-from-upstream
  variables:
    LOCAL_BRANCH: develop
    UPSTREAM_BRANCH: upstream/release
    UPSTREAM_DEFAULT_BRANCH: release
    UPSTREAM_URL: https://github.com/thunderbird/thunderbird-android
    TEMP_LATEST_TAG_BRANCH: latest_upstream_tag_branch