.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.8-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
    - python checksum-generator.py
122 123
    - git add --all
    - git commit -m "[TASK] Releasing v$(cat sickrage/version.txt)"
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"
127
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:master --follow-tags
128 129
    - git checkout develop
    - bumpversion --allow-dirty patch package.json sickrage/version.txt
echel0n's avatar
echel0n committed
130
    - python checksum-generator.py
131 132
    - git add --all
    - git commit -m "[TASK] Bump develop branch to v$(cat sickrage/version.txt)"
133
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:develop --follow-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.8-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
echel0n's avatar
echel0n committed
158
    - python checksum-generator.py
159 160 161 162
    #    - python setup.py extract_messages
    #    - crowdin-cli-py upload sources
    #    - crowdin-cli-py download
    #    - python setup.py compile_catalog
163 164 165 166
    - 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)"
167
    - git tag -a $(cat sickrage/version.txt) -m "Pre-release v$(cat sickrage/version.txt)"
168
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:$CI_COMMIT_REF_NAME --follow-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
  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)
192
    - sentry-cli releases deploys $(cat sickrage/version.txt) new -e master
193
  only:
194
    - /^[0-9.]+$/@SiCKRAGE/sickrage
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
  except:
    - branches
    - triggers

release:sentry:develop:
  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
  image: python:3.8-alpine3.12
222
  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
deploy:docker:master:
235
  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
244 245 246 247 248 249 250 251 252 253 254 255 256
  except:
    - branches
    - triggers

deploy:docker:develop:
  stage: release_deploy
  variables:
    UPSTREAM_BRANCH: develop
    UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
  trigger:
    project: sickrage/sickrage-docker
    branch: master
  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
  trigger:
    project: sickrage/sickrage-synology
266
    branch: master
echel0n's avatar
echel0n committed
267
  only:
268
    - /^[0-9.]+$/@SiCKRAGE/sickrage
269 270 271 272 273 274 275 276 277 278
  except:
    - branches
    - triggers

deploy:synology:develop:
  stage: release_deploy
  trigger:
    project: sickrage/sickrage-synology
    branch: develop
  only:
279 280 281 282 283
    - /^[0-9.]+dev[0-9]+$/@SiCKRAGE/sickrage
  except:
    - branches
    - triggers

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

300
deploy:qnap:master:
301
  stage: release_deploy
302 303 304 305 306 307 308 309 310
  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:
311
    - /^[0-9.]+$/@SiCKRAGE/sickrage
echel0n's avatar
echel0n committed
312
  except:
313
    - branches
314
    - triggers