.gitlab-ci.yml 10 KB
Newer Older
1
stages:
echel0n's avatar
echel0n committed
2
3
4
#  - review_webpack
#  - review_docker
#  - review_deploy
5
6
7
  - release_build
  - release_sentry
  - release_deploy
8

echel0n's avatar
echel0n committed
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
#review:webpack:
#  stage: review_webpack
#  image:
#    name: nikolaik/python-nodejs:python3.7-nodejs10-alpine
#  variables:
#    NODE_ENV: "development"
#  script:
#    - apk add --no-cache git gcc libffi-dev python3-dev musl-dev openssl-dev
#    - npm install -qs
#    - npm run build
#  only:
#    - [email protected]/sickrage
#  cache:
#    key: ${CI_COMMIT_REF_SLUG}
#    paths:
#      - sickrage/core/webserver/static/
#
#review:docker:
#  stage: review_docker
#  dependencies:
#    - review:webpack
#  image:
#    name: docker:latest
#    entrypoint: ["/bin/sh", "-c"]
#  variables:
#    DOCKER_DRIVER: overlay2
#    DOCKER_HOST: tcp://localhost:2375
#    DOCKER_TLS_CERTDIR: ""
#  services:
#    - docker:dind
#  script:
#    - docker login -u "${CI_REGISTRY_USER}" -p "${CI_JOB_TOKEN}" "${CI_REGISTRY}"
#    - docker build --network host -t "${CI_REGISTRY_IMAGE}:latest" .
#    - docker tag "${CI_REGISTRY_IMAGE}:latest" "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}"
#    - test ! -z "${CI_COMMIT_TAG}" && docker push "${CI_REGISTRY_IMAGE}:latest"
#    - docker push "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}"
#  only:
#    - [email protected]/sickrage
#  cache:
#    key: ${CI_COMMIT_REF_SLUG}
#
#review:deploy:
#  stage: review_deploy
#  dependencies:
#    - review:docker
#  image:
#    name: lachlanevenson/k8s-kubectl:latest
#    entrypoint: ["/bin/sh", "-c"]
#  script:
#    - kubectl create secret docker-registry gitlab-registry --namespace ${KUBE_NAMESPACE} --docker-server=${CI_REGISTRY} --docker-username=${CI_REGISTRY_USER} --docker-password=${CI_JOB_TOKEN} --docker-email=$GITLAB_USER_EMAIL --dry-run -o json | kubectl apply --namespace ${KUBE_NAMESPACE} -f -
#    - sed -i "s~__CI_REGISTRY_IMAGE__~${CI_REGISTRY_IMAGE}~" manifests/deployment.yaml
#    - sed -i "s/__VERSION__/${CI_COMMIT_REF_NAME}/" manifests/deployment.yaml manifests/ingress.yaml manifests/service.yaml
#    - sed -i "s/__CI_COMMIT_REF_SLUG__/${CI_COMMIT_REF_SLUG}/" manifests/deployment.yaml manifests/ingress.yaml manifests/service.yaml
#    - sed -i "s/__CI_ENVIRONMENT_SLUG__/${CI_ENVIRONMENT_SLUG}/" manifests/deployment.yaml manifests/ingress.yaml manifests/service.yaml
#    - sed -i "s/__KUBE_NAMESPACE__/${KUBE_NAMESPACE}/" manifests/deployment.yaml manifests/ingress.yaml manifests/service.yaml
#    - |
#      if kubectl apply -f manifests/deployment.yaml | grep -q unchanged; then
#          echo "=> Patching deployment to force image update."
#          kubectl patch -f manifests/deployment.yaml -p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"ci-last-updated\":\"$(date +'%s')\"}}}}}"
#      else
#          echo "=> Deployment apply has changed the object, no need to force image update."
#      fi
#    - kubectl apply -f manifests/service.yaml || true
#    - kubectl apply -f manifests/ingress.yaml
#    - kubectl rollout status -f manifests/deployment.yaml
#  environment:
#    name: review/$CI_COMMIT_REF_NAME
#    url: https://review.sickrage.ca/$CI_COMMIT_REF_SLUG
#    on_stop: review:stop
#  only:
#    - [email protected]/sickrage
#
#review:stop:
#  stage: review_deploy
#  image:
#    name: lachlanevenson/k8s-kubectl:latest
#    entrypoint: ["/bin/sh", "-c"]
#  script:
##    - wget -O /usr/bin/reg https://github.com/genuinetools/reg/releases/download/v0.13.0/reg-linux-amd64
##    - chmod +x /usr/bin/reg
##    - reg -r ${CI_REGISTRY} -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} rm ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}
#    - kubectl delete ing -l ref=${CI_ENVIRONMENT_SLUG}
#    - kubectl delete all -l ref=${CI_ENVIRONMENT_SLUG}
#  variables:
#    GIT_STRATEGY: none
#  when: manual
#  environment:
#    name: review/$CI_COMMIT_REF_NAME
#    action: stop
#  only:
#    - [email protected]/sickrage
100

101
release:build:master:
102
103
104
105
106
107
  stage: release_build
  image:
    name: nikolaik/python-nodejs:python3.7-nodejs10-alpine
  variables:
    NODE_ENV: "development"
  script:
108
    - apk add --no-cache git gcc libffi-dev python3-dev musl-dev openssl-dev
109
110
    - git config --global user.email $(git --no-pager show -s --format='%ae' HEAD)
    - git config --global user.name $(git --no-pager show -s --format='%an' HEAD)
111
112
113
    - npm install -qs
    - pip install bumpversion
    - pip install -r requirements-dev.txt
114
    - bumpversion --allow-dirty release package.json sickrage/version.txt
115
    - git checkout -b release-$(cat sickrage/version.txt)
116
    - npm run build
echel0n's avatar
echel0n committed
117
118
119
120
#    - python setup.py extract_messages
#    - crowdin-cli-py upload sources
#    - crowdin-cli-py download
#    - python setup.py compile_catalog
121
122
    - git add --all
    - git commit -m "[TASK] Releasing v$(cat sickrage/version.txt)"
123
124
125
126
    - git fetch . release-$(cat sickrage/version.txt):master
    - git fetch . release-$(cat sickrage/version.txt):develop
    - git tag -a $(cat sickrage/version.txt) -m "Release v$(cat sickrage/version.txt) master"
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:master --follow-tags
127
128
129
130
    - git checkout develop
    - bumpversion --allow-dirty patch package.json sickrage/version.txt
    - git add --all
    - git commit -m "[TASK] Bump develop branch to v$(cat sickrage/version.txt)"
131
132
133
#    - git tag -a $(cat sickrage/version.txt) -m "Pre-Release v$(cat sickrage/version.txt) develop"
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:develop --follow-tags
  when: manual
134
  only:
135
    - [email protected]/sickrage
136
137
138
139
140
141
142
  except:
    refs:
      - tags
      - triggers
    variables:
      - $CI_COMMIT_MESSAGE =~ /\[TASK\] Releasing/

143
release:build:develop:
144
145
146
147
148
149
  stage: release_build
  image:
    name: nikolaik/python-nodejs:python3.7-nodejs10-alpine
  variables:
    NODE_ENV: "development"
  script:
150
    - apk add --no-cache git gcc libffi-dev python3-dev musl-dev openssl-dev
151
152
153
    - npm install -qs
    - pip install bumpversion
    - pip install -r requirements-dev.txt
154
    - bumpversion --allow-dirty dev package.json sickrage/version.txt
155
    - npm run build
156
157
158
159
    #    - python setup.py extract_messages
    #    - crowdin-cli-py upload sources
    #    - crowdin-cli-py download
    #    - python setup.py compile_catalog
160
161
162
163
    - git config --global user.email $(git --no-pager show -s --format='%ae' HEAD)
    - git config --global user.name $(git --no-pager show -s --format='%an' HEAD)
    - git add --all
    - git commit -m "[TASK] Pre-Releasing v$(cat sickrage/version.txt)"
164
    - git tag -a $(cat sickrage/version.txt) -m "Pre-release v$(cat sickrage/version.txt)"
165
166
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:$CI_COMMIT_REF_NAME --follow-tags
  only:
167
    - [email protected]/sickrage
168
169
170
171
172
173
  except:
    refs:
      - tags
      - triggers
    variables:
      - $CI_COMMIT_MESSAGE =~ /\[TASK\] Pre-Releasing/
174
      - $CI_COMMIT_MESSAGE =~ /\[TASK\] Bump/
175

176
release:sentry:master:
177
178
179
180
181
182
183
184
185
186
187
188
189
190
  stage: release_sentry
  image:
    name: getsentry/sentry-cli
    entrypoint: [""]
  script:
    - export SENTRY_URL=$SENTRY_URL
    - export SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
    - export SENTRY_ORG=$SENTRY_ORG
    - export SENTRY_PROJECT=$SENTRY_PROJECT
    - sentry-cli releases new --project $SENTRY_PROJECT $(cat sickrage/version.txt)
    - sentry-cli releases set-commits --auto $(cat sickrage/version.txt)
    - sentry-cli releases finalize $(cat sickrage/version.txt)
    - sentry-cli releases deploys $(cat sickrage/version.txt) new -e master
  only:
191
    - [email protected]/sickrage
192
  except:
193
    - tags
194
195
    - triggers

196
release:sentry:develop:
197
198
199
200
201
202
203
204
205
206
207
208
209
210
  stage: release_sentry
  image:
    name: getsentry/sentry-cli
    entrypoint: [""]
  script:
    - export SENTRY_URL=$SENTRY_URL
    - export SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
    - export SENTRY_ORG=$SENTRY_ORG
    - export SENTRY_PROJECT=$SENTRY_PROJECT
    - sentry-cli releases new --project $SENTRY_PROJECT $(cat sickrage/version.txt)
    - sentry-cli releases set-commits --auto $(cat sickrage/version.txt)
    - sentry-cli releases finalize $(cat sickrage/version.txt)
    - sentry-cli releases deploys $(cat sickrage/version.txt) new -e develop
  only:
211
    - [email protected]/sickrage
212
  except:
213
    - tags
214
215
216
217
    - triggers

deploy:pypi:
  stage: release_deploy
218
219
  image: python:3.7-alpine3.9
  script:
220
    - apk add --no-cache py-pip gcc libffi-dev python3-dev musl-dev openssl-dev
221
222
223
224
    - pip install -U twine
    - python setup.py sdist bdist_wheel
    - twine upload dist/*
  only:
225
226
    - [email protected]/sickrage
    - [email protected]/sickrage
echel0n's avatar
echel0n committed
227
  except:
228
    - tags
echel0n's avatar
echel0n committed
229
    - triggers
230

231
232
deploy:docker:master:
  stage: release_deploy
echel0n's avatar
echel0n committed
233
  variables:
234
    UPSTREAM_BRANCH: master
echel0n's avatar
echel0n committed
235
236
237
238
239
    UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
  trigger:
    project: sickrage/sickrage-docker
    branch: master
  only:
240
    - [email protected]/sickrage
echel0n's avatar
echel0n committed
241
  except:
242
    - tags
echel0n's avatar
echel0n committed
243
244
    - triggers

245
246
deploy:docker:develop:
  stage: release_deploy
247
  variables:
248
    UPSTREAM_BRANCH: develop
echel0n's avatar
echel0n committed
249
    UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
250
251
252
  trigger:
    project: sickrage/sickrage-docker
    branch: master
echel0n's avatar
echel0n committed
253
  only:
254
    - [email protected]/sickrage
255
  except:
256
    - tags
echel0n's avatar
echel0n committed
257
    - triggers
258

259
deploy:synology:master:
260
  stage: release_deploy
echel0n's avatar
echel0n committed
261
262
263
264
265
266
267
  variables:
    UPSTREAM_BRANCH: master
    UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
  trigger:
    project: sickrage/sickrage-synology
    branch: master
  only:
268
    - [email protected]/sickrage
269
  except:
270
    - tags
271
272
    - triggers

273
deploy:readynas:master:
274
  stage: release_deploy
275
276
277
278
279
280
281
282
283
  variables:
    UPSTREAM_COMMIT_TAG: $CI_COMMIT_TAG
    UPSTREAM_PROJECT_NAME: $CI_PROJECT_NAME
    UPSTREAM_COMMIT_TAG_MESSAGE: $CI_COMMIT_TAG_MESSAGE
    UPSTREAM_PROJECT_ID: $CI_PROJECT_ID
  trigger:
    project: sickrage/sickrage-readynas
    branch: master
  only:
284
    - [email protected]/sickrage
285
  except:
286
    - tags
287
288
    - triggers

289
deploy:qnap:master:
290
  stage: release_deploy
291
292
293
294
295
296
297
298
299
  variables:
    UPSTREAM_COMMIT_TAG: $CI_COMMIT_TAG
    UPSTREAM_PROJECT_NAME: $CI_PROJECT_NAME
    UPSTREAM_COMMIT_TAG_MESSAGE: $CI_COMMIT_TAG_MESSAGE
    UPSTREAM_PROJECT_ID: $CI_PROJECT_ID
  trigger:
    project: sickrage/sickrage-qnap
    branch: master
  only:
300
    - [email protected]/sickrage
echel0n's avatar
echel0n committed
301
  except:
302
    - tags
303
    - triggers