-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
222 lines (203 loc) · 5.61 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
image: cirrusci/flutter:stable
stages:
- lint
- test
- publish
dartdoc:
stage: lint
script:
- flutter pub get
- dartdoc --no-auto-include-dependencies --quiet
only:
refs:
- merge_requests
changes:
- lib/**/*
- README.md
- .gitlab-ci.yml
flutter_analyze:
stage: lint
script:
- flutter pub get
- flutter analyze --pub
- flutter format -n . --set-exit-if-changed
only:
refs:
- merge_requests
changes:
- lib/**/*.dart
- test/**/*.dart
- example/lib/**/*.dart
- example/test/**/*.dart
- .gitlab-ci.yml
kotlin_analyze:
image: kkopper/ktlint:0.36.0
stage: lint
script:
- cd android || exit 1
- ktlint
only:
refs:
- merge_requests
changes:
- android/**/*.kt
- .gitlab-ci.yml
pod_lint:
image: ruby:3.0.2-slim-buster
stage: lint
script:
- cd ios || exit 1
- apt-get update && apt-get install -y rbenv git curl unzip
- gem install cocoapods -v 1.11.2
- adduser --disabled-password --gecos "" cocoapods # Running as root is not allowed for CocoaPods
- export RUBYOPT='-W0' # Disable ruby deprecation warnings
- su cocoapods -c "pod lib lint --allow-warnings twilio_conversations.podspec"
only:
refs:
- merge_requests
changes:
- ios/twilio_conversations.podspec
- .gitlab-ci.yml
swift_analyze:
image: registry.gitlab.com/twilio-flutter/docker-swiftlint/docker-swiftlint:0.39.1
stage: lint
script:
- cd ios || exit 1
- swiftlint --strict
only:
refs:
- merge_requests
changes:
- ios/**/*.swift
- .gitlab-ci.yml
unit_test:
stage: test
script:
- flutter test --coverage --pub test
- lcov --list coverage/lcov.info
only:
refs:
- merge_requests
- master
changes:
- lib/**/*
- test/**/*
- lib/**/*
- .gitlab-ci.yml
dry-run:
stage: publish
script:
- flutter pub get
- flutter pub publish --dry-run
only:
refs:
- merge_requests
pub-dev:
# https://robertohuertas.com/2019/01/20/publish-flutter-package-with-travis/
stage: publish
script:
- |
if [ -z "${PUB_DEV_PUBLISH_ACCESS_TOKEN}" ]; then
echo "Missing PUB_DEV_PUBLISH_ACCESS_TOKEN environment variable"
exit 1
fi
if [ -z "${PUB_DEV_PUBLISH_REFRESH_TOKEN}" ]; then
echo "Missing PUB_DEV_PUBLISH_REFRESH_TOKEN environment variable"
exit 1
fi
if [ -z "${PUB_DEV_PUBLISH_TOKEN_ENDPOINT}" ]; then
echo "Missing PUB_DEV_PUBLISH_TOKEN_ENDPOINT environment variable"
exit 1
fi
if [ -z "${PUB_DEV_PUBLISH_EXPIRATION}" ]; then
echo "Missing PUB_DEV_PUBLISH_EXPIRATION environment variable"
exit 1
fi
cat <<EOF > ~/.pub-cache/credentials.json
{
"accessToken":"$(echo "${PUB_DEV_PUBLISH_ACCESS_TOKEN}" | base64 -d)",
"refreshToken":"$(echo "${PUB_DEV_PUBLISH_REFRESH_TOKEN}" | base64 -d)",
"tokenEndpoint":"${PUB_DEV_PUBLISH_TOKEN_ENDPOINT}",
"scopes":["https://www.googleapis.com/auth/userinfo.email","openid"],
"expiration":${PUB_DEV_PUBLISH_EXPIRATION}
}
EOF
- flutter pub get
- flutter pub publish -f
only:
refs:
- /^v.*$/
except:
refs:
- branches
changelog:
image: curlimages/curl
stage: publish
script:
- |
if [ -z "${DISCORD_WEBHOOK}" ]; then
echo "Missing DISCORD_WEBHOOK environment variable"
exit 1
fi
TAG_NAME="$(awk '/^version: /{print $NF}' pubspec.yaml)"
PUB_SPEC_NAME="$(awk '/^name: /{print $NF}' pubspec.yaml)"
CHANGELOG_MESSAGE=$(sed '1,/^##/!d;/##/d' CHANGELOG.md | awk '{printf "%s\\n", $0}')
DATA='{
"embeds": [ {
"author": {
"name": "'"$CI_PROJECT_NAME"'",
"url": "https://pub.dev/packages/'"$PUB_SPEC_NAME"'/versions/'"$TAG_NAME"'",
"icon_url": "https://assets.gitlab-static.net/uploads/-/system/project/avatar/'"$CI_PROJECT_ID"'/'"$CI_PROJECT_NAME"'.png?width=64"
},
"description": "Version `'"$TAG_NAME"'` has just been released on pub.dev",
"fields": [
{
"name": "Changelog",
"value": "```markdown'"${CHANGELOG_MESSAGE}"'```",
"inline": false
},
{
"name": "Pipeline",
"value": "['"$CI_PIPELINE_IID"']('"$CI_PROJECT_URL/pipelines/$CI_PIPELINE_IID"')",
"inline": true
},
{
"name": "Commit",
"value": "['"$CI_COMMIT_SHORT_SHA"']('"$CI_PROJECT_URL/-/commit/$CI_COMMIT_SHA"')",
"inline": true
}
]
} ]
}'
curl --fail -H Content-Type:application/json -d "$DATA" $DISCORD_WEBHOOK
only:
refs:
- /^v.*$/
except:
refs:
- branches
tag:
image: curlimages/curl
stage: publish
script:
- |
if [ -z "${GITLAB_API_TOKEN}" ]; then
echo "Missing GITLAB_API_TOKEN environment variable"
exit 1
fi
export TAG_NAME="$(awk '/^version: /{print $NF}' pubspec.yaml)"
curl --fail --request POST --header "PRIVATE-TOKEN: ${GITLAB_API_TOKEN}" \
--data-urlencode "tag_name=v${TAG_NAME}" \
--data-urlencode "ref=master" \
--data-urlencode "message=Check the [CHANGELOG.md](${CI_PROJECT_URL}/-/blob/master/CHANGELOG.md)" \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/repository/tags"
environment:
name: pub-dev-plugin
url: https://pub.dev/packages/twilio_conversations
when: manual
only:
refs:
- master
changes:
- /**/*
- .gitlab-ci.yml