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

echel0n's avatar
echel0n committed
101
release_build_master:
102 103
  stage: release_build
  image:
echel0n's avatar
echel0n committed
104
    name: nikolaik/python-nodejs:python3.9-nodejs10-alpine
105 106
  variables:
    NODE_ENV: "development"
107
    CARGO_HOME: "$CI_PROJECT_DIR/cargo"
108
  script:
109
    - export PATH="$CARGO_HOME/bin:$PATH"
110
    - apk add --no-cache git gcc libffi-dev python3-dev musl-dev openssl-dev curl
111
    - curl https://sh.rustup.rs -sSf | sh -s -- -y
112 113
    - 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)
114
    - pip install -U pip
115 116
    - pip install bumpversion
    - pip install -r requirements-dev.txt
117
    - RELEASE_VERSION=$(bumpversion --dry-run --list release | awk -F= '/new_version=/ { print $2 }')
118
    - bumpversion --allow-dirty release package.json sickrage/version.txt
119 120
    - npx auto-changelog -v $RELEASE_VERSION --hide-credit --package --commit-limit false --ignore-commit-pattern \[TASK\].*
    - yarn install --pure-lockfile --cache-folder .yarn-cache
121
    - yarn run build
echel0n's avatar
echel0n committed
122
    - python checksum-generator.py
123 124
    - git checkout -b release/$RELEASE_VERSION
    - git fetch --all
125
    - git add --all
126 127 128
    - git commit -m "[TASK] Releasing v$RELEASE_VERSION"
    - git checkout master
    - git fetch --all
echel0n's avatar
echel0n committed
129
    - git merge release/$RELEASE_VERSION
130
    - git tag -a $RELEASE_VERSION -m "Release v$RELEASE_VERSION master"
131
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:master --follow-tags
132
    - git checkout develop
133
    - git merge --ff-only release/$RELEASE_VERSION
134
    - bumpversion --allow-dirty patch package.json sickrage/version.txt
echel0n's avatar
echel0n committed
135
    - python checksum-generator.py
136
    - git add --all
echel0n's avatar
echel0n committed
137
    - git commit -m "[TASK] Bump develop branch to v$(cat sickrage/version.txt)"
138
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:develop --follow-tags
139
  when: manual
140
  only:
141
    - /^[0-9.]+dev[0-9]+$/@SiCKRAGE/sickrage
142 143
  except:
    refs:
144
      - branches
145
      - triggers
echel0n's avatar
echel0n committed
146 147
    variables:
      - $CI_COMMIT_MESSAGE =~ /\[TASK\] Releasing/
148

echel0n's avatar
echel0n committed
149
release_build_develop:
150
  stage: release_build
echel0n's avatar
echel0n committed
151
  retry: 2
152
  image:
echel0n's avatar
echel0n committed
153
    name: nikolaik/python-nodejs:python3.9-nodejs10-alpine
154 155
  variables:
    NODE_ENV: "development"
156
    CARGO_HOME: "$CI_PROJECT_DIR/cargo"
157
  script:
158
    - export PATH="$CARGO_HOME/bin:$PATH"
159
    - apk add --no-cache git gcc libffi-dev python3-dev musl-dev openssl-dev curl
160
    - curl https://sh.rustup.rs -sSf | sh -s -- -y
echel0n's avatar
echel0n committed
161
    - yarn install --pure-lockfile --cache-folder .yarn-cache
162
    - pip install -U pip
163 164
    - pip install bumpversion
    - pip install -r requirements-dev.txt
165
    - bumpversion --allow-dirty dev package.json sickrage/version.txt
166
    - npx auto-changelog -v $(cat sickrage/version.txt) --hide-credit --unreleased --package --commit-limit false --ignore-commit-pattern \[TASK\].*
167
    - yarn run build
echel0n's avatar
echel0n committed
168
    - python checksum-generator.py
169 170 171 172
    #    - python setup.py extract_messages
    #    - crowdin-cli-py upload sources
    #    - crowdin-cli-py download
    #    - python setup.py compile_catalog
173 174 175
    - 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
echel0n's avatar
echel0n committed
176
    - git commit -m "[TASK] Pre-Releasing v$(cat sickrage/version.txt)"
177
    - git tag -a $(cat sickrage/version.txt) -m "Pre-release v$(cat sickrage/version.txt)"
178
    - git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:$CI_COMMIT_REF_NAME --follow-tags
179
  only:
180
    - [email protected]/sickrage
181 182 183 184
  except:
    refs:
      - tags
      - triggers
echel0n's avatar
echel0n committed
185 186 187
    variables:
      - $CI_COMMIT_MESSAGE =~ /\[TASK\] Pre-Releasing/
      - $CI_COMMIT_MESSAGE =~ /\[TASK\] Bump/
188

echel0n's avatar
echel0n committed
189
release_sentry_master:
190
  stage: release_sentry
echel0n's avatar
echel0n committed
191
  retry: 2
192 193 194 195 196 197 198 199 200 201 202
  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)
203
    - sentry-cli releases deploys $(cat sickrage/version.txt) new -e master
204
  only:
205
    - /^[0-9.]+$/@SiCKRAGE/sickrage
206 207 208 209
  except:
    - branches
    - triggers

echel0n's avatar
echel0n committed
210
release_sentry_develop:
211
  stage: release_sentry
echel0n's avatar
echel0n committed
212
  retry: 2
213 214 215 216 217 218 219 220 221 222 223 224 225
  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:
226
    - /^[0-9.]+dev[0-9]+$/@SiCKRAGE/sickrage
227
  except:
228
    - branches
229 230
    - triggers

echel0n's avatar
echel0n committed
231
deploy_pypi:
232
  stage: release_deploy
echel0n's avatar
echel0n committed
233
  retry: 2
234
  image: python:3.8-alpine3.12
235 236
  variables:
    CARGO_HOME: "$CI_PROJECT_DIR/cargo"
237
  script:
238 239 240
    - export PATH="$CARGO_HOME/bin:$PATH"
    - apk add --no-cache py-pip gcc libffi-dev python3-dev musl-dev openssl-dev curl
    - curl https://sh.rustup.rs -sSf | sh -s -- -y
241
    - pip install -U pip
242 243 244 245
    - pip install -U twine
    - python setup.py sdist bdist_wheel
    - twine upload dist/*
  only:
246 247
    - /^[0-9.]+$/@SiCKRAGE/sickrage
    - /^[0-9.]+dev[0-9]+$/@SiCKRAGE/sickrage
echel0n's avatar
echel0n committed
248
  except:
249
    - branches
echel0n's avatar
echel0n committed
250
    - triggers
251

echel0n's avatar
echel0n committed
252
deploy_docker_master:
253
  stage: release_deploy
echel0n's avatar
echel0n committed
254 255 256 257
  trigger:
    project: sickrage/sickrage-docker
    branch: master
  only:
258
    - /^[0-9.]+$/@SiCKRAGE/sickrage
259 260 261 262
  except:
    - branches
    - triggers

echel0n's avatar
echel0n committed
263
deploy_docker_develop:
264 265 266
  stage: release_deploy
  trigger:
    project: sickrage/sickrage-docker
267
    branch: develop
268
  only:
269
    - /^[0-9.]+dev[0-9]+$/@SiCKRAGE/sickrage
270
  except:
271
    - branches
echel0n's avatar
echel0n committed
272
    - triggers
273

echel0n's avatar
echel0n committed
274
deploy_synology_master:
275
  stage: release_deploy
echel0n's avatar
echel0n committed
276 277
  trigger:
    project: sickrage/sickrage-synology
278
    branch: master
echel0n's avatar
echel0n committed
279
  only:
280
    - /^[0-9.]+$/@SiCKRAGE/sickrage
281 282 283 284
  except:
    - branches
    - triggers

echel0n's avatar
echel0n committed
285
deploy_synology_develop:
286 287 288 289 290
  stage: release_deploy
  trigger:
    project: sickrage/sickrage-synology
    branch: develop
  only:
291 292 293 294 295
    - /^[0-9.]+dev[0-9]+$/@SiCKRAGE/sickrage
  except:
    - branches
    - triggers

echel0n's avatar
echel0n committed
296
deploy_readynas_master:
297
  stage: release_deploy
298 299 300 301 302 303 304 305 306
  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:
307
    - /^[0-9.]+$/@SiCKRAGE/sickrage
308
  except:
309
    - branches
310 311
    - triggers

echel0n's avatar
echel0n committed
312
deploy_qnap_master:
313
  stage: release_deploy
314 315 316 317 318 319 320 321 322
  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:
323
    - /^[0-9.]+$/@SiCKRAGE/sickrage
echel0n's avatar
echel0n committed
324
  except:
325
    - branches
326
    - triggers