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

Commit a24a7bc3 authored by Hasib Prince's avatar Hasib Prince
Browse files

playground reverted, dummy_job to old script

parent ead64a9a
Loading
Loading
Loading
Loading
Loading
+4 −118
Original line number Diff line number Diff line
image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:55-workshop-auto-release

variables:
  SENTRY_DSN: $SENTRY_DSN

stages:
  - build
  - test
  - mycustomstage
  - release
  - publish

before_script:
  - export GRADLE_USER_HOME=$(pwd)/.gradle
  - chmod +x ./gradlew


cache:
  key: ${CI_PROJECT_ID}
  paths:
    - .gradle/

# Debug build related jobs

dummy:
  stage: test
  only:
    - /^.*playground.*$/
  script:
    - echo "dummy job running $CI_COMMIT_REF_NAME! $CI_COMMIT_BRANCH"

lint:
  stage: build
  script:
    - ./gradlew lintRelease
    - echo "lint fininshed"

dummy_job:
  stage: mycustomstage
  rules:
    - if: '$CI_COMMIT_MESSAGE =~ "/^.*dummy_job.*$/"'
      when: manual
  script:
    - echo "second dummy job running $CI_COMMIT_MESSAGE $CI_COMMIT_BRANCH $CI_PIPELINE_SOURCE"


test:
  stage: test
  allow_failure: false
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push"'
      when: always
  script:
    - echo "Test run Started!"
    - ./gradlew test
    - echo "Test running ended!"
  artifacts:
    when: always
    paths:
      - app/build/test-results/*/TEST-*.xml
      - app/build/reports/tests/*
    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.*$/"'
      when: always
  script:
    - ./gradlew assembleRelease
  artifacts:
    paths:
      - app/build/outputs/apk/release/

pushToPrebuilt:
  stage: publish
  needs: ["buildRelease"]
  rules:
    - if: '$CI_COMMIT_MESSAGE =~ "/^.*dummy_job.*$/"'
      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)
    - 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:hasibprince/applounge_git_lfs.git
    - cd applounge_git_lfs
    - rm *-release.apk
    - mv ../${NEW_APK_PATH}/${NEW_APK_NAME} /
    # 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

after_script:
  - echo "after script is executed"
include:
  - project: 'e/templates'
    ref: gitlab-ci-apps
    file: '/gitlab-ci/.ci-apps.yml'