aboutsummaryrefslogtreecommitdiffstats
path: root/.circleci/config.yml
blob: 8f64437379cf75648098471e68b9b4db6d66bd51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
version: 2
jobs:
  test:
    docker:
      - image: registry.gitlab.com/fdroid/ci-images-client:latest
    steps:
      - checkout
      - restore_cache:
          key: gradle-{{ checksum "build.gradle" }}-{{ checksum ".circleci/config.yml" }}
      - run: export GRADLE_USER_HOME=$PWD/.gradle
      - run: echo y | sdkmanager "platforms;android-$(sed -n 's,.*compileSdkVersion\s*\([0-9][0-9]*\).*,\1,p' build.gradle)" > /dev/null
      - run: ./gradlew lintStandardDebug
      - save_cache:
          paths:
            - .gradle/caches
            - .gradle/wrapper
          key: gradle-{{ checksum "build.gradle" }}-{{ checksum ".circleci/config.yml" }}
      - store_artifacts:
          path: build/outputs/apk/standard
          destination: apk
  build:
    branches:
      ignore:
        - master
    docker:
      - image: registry.gitlab.com/fdroid/ci-images-client:latest
    steps:
      - checkout
      - restore_cache:
          key: android
      - run: export GRADLE_USER_HOME=$PWD/.gradle
      - run: echo y | sdkmanager "platforms;android-$(sed -n 's,.*compileSdkVersion\s*\([0-9][0-9]*\).*,\1,p' build.gradle)" > /dev/null
      # build
      - run: ./gradlew assembleStandard
      - save_cache:
          paths:
            - ~/.android
          key: android
      - store_artifacts:
          path: build/outputs/apk/standard

  publish:
    branches:
      only:
        - master
    docker:
      - image: registry.gitlab.com/fdroid/ci-images-client:latest
    steps:
      - checkout
      - restore_cache:
          key: android
      - run: export GRADLE_USER_HOME=$PWD/.gradle
      - run: echo y | sdkmanager "platforms;android-$(sed -n 's,.*compileSdkVersion\s*\([0-9][0-9]*\).*,\1,p' build.gradle)" > /dev/null
      # workaround for fdroid nightly circleci bug
      - run: sed -i "s/os.getenv('CIRCLE_REPOSITORY_URL')/\"https:\/\/github.com\/kriztan\/Pix-Art-Messenger\"/" /usr/lib/python3/dist-packages/fdroidserver/nightly.py
      # generate version number
      - run: sed -i "s/^\(\s*versionCode\s*\).*$/\1$(git rev-list --first-parent --count HEAD)/" build.gradle
      - run: sed -i "0,/versionName/s/^\(\s*versionName\).*/\1 \"$(printf '%s-%05d' $(git describe --tag --abbrev=0) $(git rev-list --first-parent --count HEAD))\"/" build.gradle
      - run: cat -n build.gradle
      # build
      - run: ./gradlew assembleStandard
      # publish on nightly fdroid repo
      - run: fdroid nightly
      - save_cache:
          paths:
            - ~/.android
          key: android

workflows:
  version: 2
  build_test:
    jobs:
    - build
    - publish