.gitlab-ci.yml 10.4 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:
echel0n's avatar
echel0n committed
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:
echel0n's avatar
echel0n committed
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
121 122
    - git add --all
    - git commit -m "[TASK] Releasing v$(cat sickrage/version.txt)"
123 124 125
    - 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"
126 127
    - 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
128 129 130 131
    - 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)"
132 133
    - 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
134
  when: manual
135
  only:
136
    - /^[0-9.]+dev[0-9]+$/@SiCKRAGE/sickrage
137 138
  except:
    refs:
139
      - branches
140 141 142 143
      - triggers
    variables:
      - $CI_COMMIT_MESSAGE =~ /\[TASK\] Releasing/

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

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

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

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

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

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

262
deploy:synology:master:
263
  stage: release_deploy
echel0n's avatar
echel0n committed
264 265 266 267 268 269 270
  variables:
    UPSTREAM_BRANCH: master
    UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
  trigger:
    project: sickrage/sickrage-synology
    branch: master
  only:
271
    - /^[0-9.]+$/@SiCKRAGE/sickrage
272
  except:
273
    - branches
274 275
    - triggers

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

292
deploy:qnap:master:
293
  stage: release_deploy
294 295 296 297 298 299 300 301 302
  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:
303
    - /^[0-9.]+$/@SiCKRAGE/sickrage
echel0n's avatar
echel0n committed
304
  except:
305
    - branches
306
    - triggers