-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
180 lines (165 loc) · 4.25 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
stages:
- test
- build
- publish
before_script:
- bundle install || true
- git fetch --prune --prune-tags
- echo "Latest tag to be used as build and version number"
- export LATEST_TAG=$(git describe --tags --abbrev=0 --match "connectedfueling-app-*")
- export TAG_NUMBER=${LATEST_TAG##connectedfueling-app-v} # Get content after connectedfueling-app-v
- export VERSION_NAME=${TAG_NUMBER%.*} # Get content before last .
- export BUILD_NUMBER=${TAG_NUMBER##*.} # Get content after last .
- echo "Building version $VERSION_NAME with build number $BUILD_NUMBER"
.dependent_changes: &dependent_changes
changes:
- .gitlab-ci.yml
- "ConnectedFueling.xcodeproj/project.pbxproj"
- "App/**/*"
- "Gemfile.lock"
.only_merge_requests: &only_merge_requests
only:
refs:
- merge_requests
<<: *dependent_changes
.only_master: &only_master
only:
refs:
- master
<<: *dependent_changes
.runner_tags:
tags:
- ios
.base_template:
extends: .runner_tags
interruptible: true
## Merge requests
### Plist
plist:
extends: .base_template
stage: test
before_script:
- echo "Ignore global before_script"
after_script:
- echo "Ignore global after_script"
script:
- find . -name "*.strings" -size +0 -print0 | xargs -0 plutil -lint
<<: *only_merge_requests
### Code style
code_style:
extends: .base_template
stage: test
before_script:
- echo "Ignore global before_script"
after_script:
- echo "Ignore global after_script"
script:
- swiftlint
<<: *only_merge_requests
### Unit tests
unit_test:
extends: .base_template
stage: test
script:
- bundle exec fastlane test
allow_failure: false
<<: *only_merge_requests
except:
variables:
- $CI_COMMIT_MESSAGE =~ /WIP/
### Review
build_review:
extends: .base_template
stage: build
script:
- bundle exec fastlane build_development
<<: *only_merge_requests
except:
refs:
- tags
variables:
- $CI_COMMIT_MESSAGE =~ /WIP/
environment:
name: review/$CI_COMMIT_REF_NAME
artifacts:
name: "review-app"
paths:
- ./App.ipa
expire_in: 2 days
## Release to TestFlight
release_schedule:
image: node:latest
stage: publish
before_script: []
after_script: []
script:
- if $(eval $CONDITION); then echo "Releasing..."; else echo "Nothing to do"; exit 0; fi
- echo "Current time to be used as new build and version number"
- export BUILD_NUMBER=$(TZ=Etc/Utc date "+%Y%m%d%H")
- export VERSION_NAME=$(TZ=Etc/Utc date "+%y.%V.%u")
- export CUSTOM_TAG_NAME="${TAG_PREFIX}v${VERSION_NAME}.${BUILD_NUMBER}"
- export CUSTOM_BRANCH_NAME="main"
- echo "Creating tag with tag name:" $CUSTOM_TAG_NAME
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@git.pace.cloud/pace/mobile/common.git tmp/common
- cd tmp/common/scripts/release
- yarn install
- node --unhandled-rejections=strict create-empty-release.js
only:
refs:
- schedules
variables:
- $SCHEDULED_JOB == "connectedfueling-app-testflight"
dependencies: []
needs: []
variables:
TAG_PREFIX: "connectedfueling-app-"
tags:
- docker
build_testflight_app:
extends: .base_template
stage: build
only:
- tags
script:
- bundle exec fastlane build_beta
artifacts:
name: "$(git show -s --format=%ct $CI_COMMIT_SHA)-beta"
paths:
- App.ipa
expire_in: 1 weeks
except:
variables:
- $CI_COMMIT_TAG !~ /^connectedfueling-app-/
publish_testflight_app:
extends: .base_template
stage: publish
only:
- tags
script:
- bundle exec fastlane publish
except:
variables:
- $CI_COMMIT_TAG !~ /^connectedfueling-app-/
submit:
extends: .base_template
stage: publish
needs: ["publish_testflight_app"]
only:
- tags
script:
- bundle exec fastlane submit_review --verbose
except:
variables:
- $CI_COMMIT_TAG !~ /^connectedfueling-app-/
when: manual
### Merge main into release (triggers GitHub mirroring)
trigger_github_mirroring:
extends: .base_template
stage: publish
before_script: []
after_script: []
script:
- ./scripts/trigger_github_mirroring.sh
rules:
- if: $SCHEDULED_JOB == "connectedfueling-app-github-mirroring"
- if: $SCHEDULED_JOB == "connectedfueling-app-testflight"