-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
154 lines (142 loc) · 4.13 KB
/
.gitlab-ci.yml
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
variables:
FLUTTER_DOCKER_IMAGE: cirrusci/flutter:2.10.0
stages:
- precheck
- analyze
- test
- build
- transform
- upload
- deploy
- promote
commitlint:
image:
name: gtramontina/commitlint:8.3.5
entrypoint: [ "" ]
stage: precheck
needs: [ ]
script:
- commitlint --from origin/master --verbose
except:
- master
stylelint:
image: $FLUTTER_DOCKER_IMAGE
stage: precheck
needs: [ ]
script:
- flutter format --line-length 120 --dry-run --set-exit-if-changed .
analyze:
image: $FLUTTER_DOCKER_IMAGE
stage: analyze
needs: [ ]
script:
- flutter analyze
test:
image: $FLUTTER_DOCKER_IMAGE
stage: test
needs: [ ]
before_script:
- apt-get update
- apt-get install -y libsqlite3-dev
script:
- flutter test --coverage
after_script:
- lcov --remove coverage/lcov.info lib/database.drift.dart --output-file coverage/lcov.info
- genhtml --output ./coverage coverage/lcov.info
coverage: '/^\s+lines\.+:\s+([\d.]+\%)\s+/'
build:appbundle:debug:
image: $FLUTTER_DOCKER_IMAGE
stage: build
needs: [ ]
except:
- master
- tags
script:
- flutter build appbundle --debug
build:appbundle:release:
image: $FLUTTER_DOCKER_IMAGE
stage: build
needs: [ ]
only:
- master
- tags
before_script:
- echo "$GOOGLE_SERVICES_JSON" > android/app/google-services.json
- echo -n "$SIGNING_JKS_FILE_BASE64" | base64 -d > android/app/upload-keystore.jks
- if [ -n "$CI_COMMIT_TAG" ]; then BUILD_NAME=$CI_COMMIT_TAG; else BUILD_NAME=$CI_COMMIT_SHORT_SHA; fi
script:
- flutter build appbundle --release --build-number=$CI_PIPELINE_IID --build-name=$BUILD_NAME
artifacts:
paths:
- build/app/outputs/bundle/release/app-release.aab
build:apk:
image: openjdk:16-buster
stage: transform
needs: [ "build:appbundle:release" ]
only:
- tags
before_script:
- echo -n "$SIGNING_JKS_FILE_BASE64" | base64 -d > android/app/upload-keystore.jks
- wget https://github.com/google/bundletool/releases/download/1.6.1/bundletool-all-1.6.1.jar -O bundletool.jar
script:
- java -jar bundletool.jar build-apks --mode=universal --bundle=build/app/outputs/bundle/release/app-release.aab --output=app-release.apks --ks=android/app/upload-keystore.jks --ks-pass=pass:$SIGNING_KEYSTORE_PASSWORD --ks-key-alias=$SIGNING_KEY_ALIAS --key-pass=pass:$SIGNING_KEY_PASSWORD
- unzip app-release.apks
- mv universal.apk app-release.apk
artifacts:
paths:
- app-release.apk
deploy:gitlab-release:
image: curlimages/curl:latest
stage: deploy
needs: [ "commitlint", "stylelint", "analyze", "test", "build:apk" ]
only:
- tags
script:
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file app-release.apk "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/flauncher/$CI_COMMIT_TAG/flauncher-$CI_COMMIT_TAG.apk"'
deploy:play-store:
stage: deploy
needs: [ "commitlint", "stylelint", "analyze", "test", "build:appbundle:release" ]
image: ruby:2.6.3
only:
- tags
before_script:
- echo "$GOOGLE_PLAY_API_KEY" > android/fastlane/google_play_api_key.json
- export LC_ALL=en_US.UTF-8
- export LANG=en_US.UTF-8
- gem install fastlane -NV
- cd android
script:
- fastlane deploy
promote:play-store:
stage: promote
needs: [ "deploy:play-store" ]
image: ruby:2.6.3
when: manual
only:
- tags
before_script:
- echo "$GOOGLE_PLAY_API_KEY" > android/fastlane/google_play_api_key.json
- export LC_ALL=en_US.UTF-8
- export LANG=en_US.UTF-8
- gem install fastlane -NV
- cd android
script:
- fastlane promote
promote:gitlab-release:
stage: promote
needs: [ "deploy:gitlab-release" ]
image: registry.gitlab.com/gitlab-org/release-cli:latest
when: manual
only:
- tags
script:
- echo 'running promote:gitlab-release'
release:
name: $CI_COMMIT_TAG
description: FLauncher v$CI_COMMIT_TAG
tag_name: $CI_COMMIT_TAG
assets:
links:
- name: flauncher-$CI_COMMIT_TAG.apk
url: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/flauncher/$CI_COMMIT_TAG/flauncher-$CI_COMMIT_TAG.apk
filepath: /flauncher-$CI_COMMIT_TAG.apk