.gitlab-ci.yml 10.5 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

9 10 11 12
services:
  - name: docker:dind
    command: ["--mtu=1450"]

echel0n's avatar
echel0n committed
13 14 15
#review:webpack:
#  stage: review_webpack
#  image:
16
#    name: nikolaik/python-nodejs:python3.7-nodejs10-alpine
echel0n's avatar
echel0n committed
17 18 19 20
#  variables:
#    NODE_ENV: "development"
#  script:
#    - apk add --no-cache git gcc libffi-dev python3-dev musl-dev openssl-dev
echel0n's avatar
echel0n committed
21
#    - yarn install --pure-lockfile --cache-folder .yarn-cache
22
#    - yarn run build
echel0n's avatar
echel0n committed
23
#  only:
24
#    - [email protected]/sickrage
echel0n's avatar
echel0n committed
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
#  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:
50
#    - [email protected]/sickrage
echel0n's avatar
echel0n committed
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
#  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:
83
#    - [email protected]/sickrage
echel0n's avatar
echel0n committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
#
#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:
103
#    - [email protected]/sickrage
104

105
release:build:master:
106 107
  stage: release_build
  image:
108
    name: nikolaik/python-nodejs:python3.7-nodejs10-alpine
109 110 111
  variables:
    NODE_ENV: "development"
  script:
112
    - apk add --no-cache git gcc libffi-dev python3-dev musl-dev openssl-dev
113 114
    - 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)
echel0n's avatar
echel0n committed
115
    - yarn install --pure-lockfile --cache-folder .yarn-cache
116 117
    - pip install bumpversion
    - pip install -r requirements-dev.txt
118
    - bumpversion --allow-dirty release package.json sickrage/version.txt
119
    - git checkout -b release-$(cat sickrage/version.txt)
120
    - yarn run build
echel0n's avatar
echel0n committed
121 122 123 124
#    - python setup.py extract_messages
#    - crowdin-cli-py upload sources
#    - crowdin-cli-py download
#    - python setup.py compile_catalog
125 126
    - git add --all
    - git commit -m "[TASK] Releasing v$(cat sickrage/version.txt)"
127 128 129
    - 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"
130 131
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:master
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:master --tags
132 133 134 135
    - 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)"
136 137
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:develop
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:develop --tags
138
  when: manual
139
  only:
140
    - /^[0-9.]+dev[0-9]+$/@SiCKRAGE/sickrage
141 142
  except:
    refs:
143
      - branches
144 145 146 147
      - triggers
    variables:
      - $CI_COMMIT_MESSAGE =~ /\[TASK\] Releasing/

148
release:build:develop:
149 150
  stage: release_build
  image:
151
    name: nikolaik/python-nodejs:python3.7-nodejs10-alpine
152 153 154
  variables:
    NODE_ENV: "development"
  script:
155
    - apk add --no-cache git gcc libffi-dev python3-dev musl-dev openssl-dev
echel0n's avatar
echel0n committed
156
    - yarn install --pure-lockfile --cache-folder .yarn-cache
157 158
    - pip install bumpversion
    - pip install -r requirements-dev.txt
159
    - bumpversion --allow-dirty dev package.json sickrage/version.txt
160
    - yarn run build
161 162 163 164
    #    - python setup.py extract_messages
    #    - crowdin-cli-py upload sources
    #    - crowdin-cli-py download
    #    - python setup.py compile_catalog
165 166 167 168
    - 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)"
169
    - git tag -a $(cat sickrage/version.txt) -m "Pre-release v$(cat sickrage/version.txt)"
170 171
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:$CI_COMMIT_REF_NAME
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:$CI_COMMIT_REF_NAME --tags
172
  only:
173
    - [email protected]/sickrage
174 175 176 177 178 179
  except:
    refs:
      - tags
      - triggers
    variables:
      - $CI_COMMIT_MESSAGE =~ /\[TASK\] Pre-Releasing/
180
      - $CI_COMMIT_MESSAGE =~ /\[TASK\] Bump/
181

182
release:sentry:master:
183 184 185 186 187 188 189 190 191 192 193 194 195 196
  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:
197
    - /^[0-9.]+$/@SiCKRAGE/sickrage
198
  except:
199
    - branches
200 201
    - triggers

202
release:sentry:develop:
203 204 205 206 207 208 209 210 211 212 213 214 215 216
  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:
217
    - /^[0-9.]+dev[0-9]+$/@SiCKRAGE/sickrage
218
  except:
219
    - branches
220 221 222 223
    - triggers

deploy:pypi:
  stage: release_deploy
224 225
  image: python:3.7-alpine3.9
  script:
226
    - apk add --no-cache py-pip gcc libffi-dev python3-dev musl-dev openssl-dev
227 228 229 230
    - pip install -U twine
    - python setup.py sdist bdist_wheel
    - twine upload dist/*
  only:
231 232
    - /^[0-9.]+$/@SiCKRAGE/sickrage
    - /^[0-9.]+dev[0-9]+$/@SiCKRAGE/sickrage
echel0n's avatar
echel0n committed
233
  except:
234
    - branches
echel0n's avatar
echel0n committed
235
    - triggers
236

237 238
deploy:docker:master:
  stage: release_deploy
echel0n's avatar
echel0n committed
239
  variables:
240
    UPSTREAM_BRANCH: master
echel0n's avatar
echel0n committed
241 242 243 244 245
    UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
  trigger:
    project: sickrage/sickrage-docker
    branch: master
  only:
246
    - /^[0-9.]+$/@SiCKRAGE/sickrage
echel0n's avatar
echel0n committed
247
  except:
248
    - branches
echel0n's avatar
echel0n committed
249 250
    - triggers

251 252
deploy:docker:develop:
  stage: release_deploy
253
  variables:
254
    UPSTREAM_BRANCH: develop
echel0n's avatar
echel0n committed
255
    UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
256 257 258
  trigger:
    project: sickrage/sickrage-docker
    branch: master
echel0n's avatar
echel0n committed
259
  only:
260
    - /^[0-9.]+dev[0-9]+$/@SiCKRAGE/sickrage
261
  except:
262
    - branches
echel0n's avatar
echel0n committed
263
    - triggers
264

265
deploy:synology:master:
266
  stage: release_deploy
267 268 269 270 271 272 273
  variables:
    UPSTREAM_BRANCH: master
    UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
  trigger:
    project: sickrage/sickrage-synology
    branch: master
  only:
274
    - /^[0-9.]+$/@SiCKRAGE/sickrage
275
  except:
276
    - branches
277 278
    - triggers

279
deploy:readynas:master:
280
  stage: release_deploy
281 282 283 284 285 286 287 288 289
  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:
290
    - /^[0-9.]+$/@SiCKRAGE/sickrage
291
  except:
292
    - branches
293 294
    - triggers

295
deploy:qnap:master:
296
  stage: release_deploy
297 298 299 300 301 302 303 304 305
  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:
306
    - /^[0-9.]+$/@SiCKRAGE/sickrage
307
  except:
308
    - branches
309
    - triggers