Commit 2f59abe0 authored by echel0n's avatar echel0n

Added regex for semantic versioning along with matching of each section of the...

Added regex for semantic versioning along with matching of each section of the version string to see if remote is greater then local version.
parent 94f82ef6
......@@ -8,15 +8,15 @@ tests
runscripts
node_modules
dist
manifests
changelog.md
readme.md
README.txt
crowdin.yaml
Gruntfile.js
MANIFEST.in
package.json
package-lock.json
pre-commit-hook.sh
setup.cfg
setup.py
webpack.config.js
\ No newline at end of file
webpack.config.js
......@@ -80,4 +80,5 @@ Thumbs.db
/bower_components/
/node_modules/
/src/spritesmith-generated/
/dist/
\ No newline at end of file
/dist/
/sickrage/core/webserver/static/js/core.js.map
\ No newline at end of file
before_script:
- apk add --no-cache py-pip
stages:
- release
- deploy
- review_webpack
- review_docker
- review_deploy
- release_build
- release_sentry
- release_deploy
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:
- merge_requests
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- sickrage/core/webserver/static/
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://localhost:2375
DOCKER_TLS_CERTDIR: ""
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:
- merge_requests
cache:
key: ${CI_COMMIT_REF_SLUG}
services:
- docker:dind
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:
- merge_requests
sentry_release_master:
stage: release
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:
- merge_requests
release:build:master:
stage: release_build
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
- pip install bumpversion
- pip install -r requirements-dev.txt
- bumpversion --allow-dirty patch package.json sickrage/version.txt
- npm run build
# - python setup.py extract_messages
# - crowdin-cli-py upload sources
# - crowdin-cli-py download
# - python setup.py compile_catalog
- 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 tag -a $(cat sickrage/version.txt) -m "Release v$(cat sickrage/version.txt)"
- git commit -m "[TASK] Releasing v$(cat sickrage/version.txt)"
- git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:$CI_COMMIT_REF_NAME --follow-tags
only:
- master
except:
refs:
- tags
- triggers
variables:
- $CI_COMMIT_MESSAGE =~ /\[TASK\] Releasing/
release:build:develop:
stage: release_build
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
- pip install bumpversion
- pip install -r requirements-dev.txt
- bumpversion --allow-dirty preversion package.json sickrage/version.txt
- npm run build
# - python setup.py extract_messages
# - crowdin-cli-py upload sources
# - crowdin-cli-py download
# - python setup.py compile_catalog
- 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 tag -a $(cat sickrage/version.txt) -m "Pre-release v$(cat sickrage/version.txt)"
- git commit -m "[TASK] Pre-Releasing v$(cat sickrage/version.txt)"
- git push https://$GIT_ACCESS_USER:[email protected]$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:$CI_COMMIT_REF_NAME --follow-tags
only:
- develop
except:
refs:
- tags
- triggers
variables:
- $CI_COMMIT_MESSAGE =~ /\[TASK\] Pre-Releasing/
release:sentry:master:
stage: release_sentry
image:
name: getsentry/sentry-cli
entrypoint: [""]
......@@ -33,8 +182,8 @@ sentry_release_master:
- branches
- triggers
sentry_release_develop:
stage: release
release:sentry:develop:
stage: release_sentry
image:
name: getsentry/sentry-cli
entrypoint: [""]
......@@ -53,10 +202,11 @@ sentry_release_develop:
- branches
- triggers
deploy_pypi:
stage: deploy
deploy:pypi:
stage: release_deploy
image: python:3.7-alpine3.9
script:
- apk add --no-cache py-pip gcc libffi-dev python3-dev musl-dev openssl-dev
- pip install -U twine
- python setup.py sdist bdist_wheel
- twine upload dist/*
......@@ -67,8 +217,8 @@ deploy_pypi:
- branches
- triggers
deploy_docker_master:
stage: deploy
deploy:docker:master:
stage: release_deploy
variables:
UPSTREAM_BRANCH: master
UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
......@@ -81,8 +231,8 @@ deploy_docker_master:
- branches
- triggers
deploy_docker_develop:
stage: deploy
deploy:docker:develop:
stage: release_deploy
variables:
UPSTREAM_BRANCH: develop
UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
......@@ -95,8 +245,8 @@ deploy_docker_develop:
- branches
- triggers
deploy_synology:
stage: deploy
deploy:synology:master:
stage: release_deploy
variables:
UPSTREAM_BRANCH: master
UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
......@@ -109,8 +259,8 @@ deploy_synology:
- branches
- triggers
deploy_readynas:
stage: deploy
deploy:readynas:master:
stage: release_deploy
variables:
UPSTREAM_COMMIT_TAG: $CI_COMMIT_TAG
UPSTREAM_PROJECT_NAME: $CI_PROJECT_NAME
......@@ -125,8 +275,8 @@ deploy_readynas:
- branches
- triggers
deploy_qnap:
stage: deploy
deploy:qnap:master:
stage: release_deploy
variables:
UPSTREAM_COMMIT_TAG: $CI_COMMIT_TAG
UPSTREAM_PROJECT_NAME: $CI_PROJECT_NAME
......@@ -139,4 +289,4 @@ deploy_qnap:
- /^[0-9.]+$/
except:
- branches
- triggers
\ No newline at end of file
- triggers
......@@ -5,6 +5,7 @@ ARG SOURCE_COMMIT
ENV SOURCE_COMMIT $SOURCE_COMMIT
ENV TZ 'Canada/Pacific'
ENV WEB_ROOT ''
#RUN locale-gen en_US.UTF-8
#ENV LANG en_US.UTF-8
......@@ -20,4 +21,4 @@ RUN pip install -r /opt/sickrage/requirements.txt
EXPOSE 8081
VOLUME /config /downloads /tv /anime
ENTRYPOINT python /opt/sickrage/SiCKRAGE.py --nolaunch --datadir /config
\ No newline at end of file
ENTRYPOINT python /opt/sickrage/SiCKRAGE.py --nolaunch --web_root $WEB_ROOT --datadir /config
\ No newline at end of file
module.exports = function (grunt) {
const shell = require('shelljs');
const webpackConfig = require('./webpack.config');
require('load-grunt-tasks')(grunt);
grunt.initConfig({
webpack: {
options: {
stats: !process.env.NODE_ENV || process.env.NODE_ENV === 'development'
},
prod: webpackConfig,
dev: webpackConfig
},
changelog: {
release: {
options: {
after: '256',
logArguments: [
'--pretty=* %h - %ad: %s',
'--no-merges',
'--date=short'
],
fileHeader: '# Changelog',
featureRegex: /^(.*)$/gim,
partials: {
features: '{{#each features}}{{> feature}}{{/each}}\n',
feature: '- {{this}} {{this.date}}\n',
fixes: '{{#each fixes}}{{> fix}}{{/each}}\n',
fix: '- {{this}} {{this.date}}\n'
},
dest: "changelog.md"
}
}
},
exec: {
// Translations
'crowdin_upload_sources': {cmd: 'crowdin-cli-py upload sources'},
'crowdin_upload_translations': {cmd: 'crowdin-cli-py upload translations'},
'crowdin_download_translations': {cmd: 'crowdin-cli-py download'},
'babel_extract': {cmd: 'python setup.py extract_messages'},
'babel_update': {cmd: 'python setup.py update_catalog'},
'babel_compile': {cmd: 'python setup.py compile_catalog'},
// Git Commands
'git': {
cmd: function (cmd, branch) {
branch = branch ? ' ' + branch : '';
return 'git ' + cmd + branch;
}
},
'git_push': {
cmd: function (remote, branch, tags) {
let pushCmd = 'git push ' + remote + ' ' + branch;
if (tags) {
pushCmd += ' --tags';
}
return pushCmd;
},
stderr: false,
callback: function (err, stdout, stderr) {
grunt.log.write(stderr);
}
},
'git_commit': {
cmd: function (message) {
return 'git commit -am "' + message + '"';
},
stderr: false,
callback: function (err, stdout, stderr) {
grunt.log.write(stderr);
}
},
'git_last_tag': {
cmd: 'git for-each-ref refs/tags --sort=-taggerdate --count=1 --format=%(refname:short)',
stdout: false,
callback: function (err, stdout) {
stdout = stdout.trim();
if (/^\d{1,2}.\d{1,2}.\d+(?:.dev\d+)?$/.test(stdout)) {
grunt.config('last_tag', stdout);
} else {
grunt.fatal('Could not get the last tag name. We got: ' + stdout);
}
}
},
'git_list_changes': {
cmd: function () {
return 'git log --oneline --pretty=format:%s ' + grunt.config('last_tag') + '..HEAD';
},
stdout: false,
maxBuffer: 500 * 1024,
callback: function (err, stdout) {
const commits = stdout.trim()
.replace(/`/gm, '').replace(/^\([\w\d\s,.\-+_/>]+\)\s/gm, ''); // removes ` and tag information
if (commits) {
grunt.config('commits', commits);
} else {
grunt.fatal('Getting new commit list failed!');
}
}
},
'git_tag': {
cmd: function (version) {
return 'git tag ' + version + ' -m "' + grunt.config('commits') + '"';
},
stdout: false
}
}
});
grunt.registerTask('upload_trans', 'Upload translations', function () {
grunt.log.writeln('Extracting and uploading translations to Crowdin...'.magenta);
const tasks = [
'exec:babel_extract',
'exec:crowdin_upload_sources'
];
if (process.env.CROWDIN_API_KEY) {
grunt.task.run(tasks);
} else {
grunt.log.warn('Environment variable `CROWDIN_API_KEY` is not set, aborting task'.bold);
}
});
grunt.registerTask('download_trans', 'Download translations', function () {
grunt.log.writeln('Downloading and compiling translations from Crowdin...'.magenta);
const tasks = [
'exec:crowdin_download_translations',
'exec:babel_compile'
];
if (process.env.CROWDIN_API_KEY) {
grunt.task.run(tasks);
} else {
grunt.log.warn('Environment variable `CROWDIN_API_KEY` is not set, aborting task.'.bold);
}
});
grunt.registerTask('sync_trans', 'Sync translations with Crowdin', function () {
grunt.log.writeln('Syncing translations with Crowdin...'.magenta);
const tasks = [
'upload_trans',
'download_trans'
];
if (process.env.CROWDIN_API_KEY) {
grunt.task.run(tasks);
} else {
grunt.log.warn('Environment variable `CROWDIN_API_KEY` is not set, aborting task.'.bold);
}
});
grunt.registerTask('bump_version', function (new_version) {
const vFile = 'sickrage/version.txt';
grunt.file.write(vFile, new_version)
});
grunt.registerTask('pre-release', function () {
grunt.task.run(['exec:git:checkout:develop']);
const vFile = 'sickrage/version.txt';
const version = grunt.file.read(vFile);
const versionParts = version.split('.');
const vArray = {
vMajor: versionParts[0],
vMinor: versionParts[1],
vPatch: versionParts[2],
vPre: versionParts[3] || 0
};
if (vArray.vPre === 0) {
vArray.vPatch = parseFloat(vArray.vPatch) + 1;
}
if (vArray.vPre !== 0) {
vArray.vPre = vArray.vPre.split('dev')[1];
vArray.vPre = parseFloat(vArray.vPre) + 1;
} else {
vArray.vPre = parseFloat(vArray.vPre) + 1;
}
const newVersion = vArray.vMajor + '.' + vArray.vMinor + '.' + vArray.vPatch + '.dev' + vArray.vPre;
const tasks = [
'changelog',
'webpack:dev',
//'sync_trans',
'bump_version:' + newVersion,
'exec:git_commit:Pre-Release v' + newVersion,
'exec:git_last_tag', 'exec:git_list_changes', 'exec:git_tag:' + newVersion,
'exec:git_push:origin:develop:tags',
];
grunt.task.run(tasks);
});
grunt.registerTask('release', function () {
grunt.task.run(['exec:git:checkout:develop']);
const vFile = 'sickrage/version.txt';
const version = grunt.file.read(vFile);
const versionParts = version.split('.');
const vArray = {
vMajor: versionParts[0],
vMinor: versionParts[1],
vPatch: versionParts[2],
vPre: versionParts[3] || 0
};
if (vArray.vPre === 0) {
vArray.vPatch = parseFloat(vArray.vPatch) + 1;
}
if (vArray.vPre !== 0) {
vArray.vPre = vArray.vPre.split('dev')[1];
vArray.vPre = parseFloat(vArray.vPre) + 1;
} else {
vArray.vPre = parseFloat(vArray.vPre) + 1;
}
const newVersion = vArray.vMajor + '.' + vArray.vMinor + '.' + vArray.vPatch;
const tasks = [
'exec:git:checkout:-b release-v' + newVersion + ':develop',
'changelog',
'webpack:prod',
//'sync_trans',
'bump_version:' + newVersion,
'exec:git_commit:Release v' + newVersion,
'exec:git:checkout:master',
'exec:git:merge:release-v' + newVersion,
'exec:git_last_tag', 'exec:git_list_changes', 'exec:git_tag:' + newVersion,
'exec:git_push:origin:master:tags',
'exec:git:checkout:develop',
'exec:git:merge:release-v' + newVersion,
'exec:git_push:origin:develop',
'exec:git:branch:-d release-v' + newVersion,
];
grunt.task.run(tasks);
});
};
\ No newline at end of file
# Changelog
- * 94f82ef67 - 2019-11-05: Release v9.4.183
- * d94d4b9bc - 2019-11-05: Revert "Added lazy loading to main shows page, reduces page load times."
- * 932c107ab - 2019-11-05: Revert "Refactored main shows page to load shows via web sockets."
- * 940d091a7 - 2019-11-05: Revert "Refactored TVShow and TVEpisode database models to use select instead of joined for lazy loading relationships."
......
apiVersion: apps/v1
kind: Deployment
metadata:
name: __CI_COMMIT_REF_SLUG__
namespace: __KUBE_NAMESPACE__
labels:
app: __CI_COMMIT_REF_SLUG__
ref: __CI_ENVIRONMENT_SLUG__
spec:
replicas: 1
selector:
matchLabels:
app: __CI_COMMIT_REF_SLUG__
ref: __CI_ENVIRONMENT_SLUG__
template:
metadata:
labels:
app: __CI_COMMIT_REF_SLUG__
ref: __CI_ENVIRONMENT_SLUG__
spec:
containers:
- name: app
image: __CI_REGISTRY_IMAGE__:__VERSION__
imagePullPolicy: Always
env:
- name: TZ
value: "Canada/Pacific"
- name: WEB_ROOT
value: __CI_COMMIT_REF_SLUG__
ports:
- containerPort: 8081
imagePullSecrets:
- name: gitlab-registry
\ No newline at end of file
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: __CI_COMMIT_REF_SLUG__
namespace: __KUBE_NAMESPACE__
labels:
app: __CI_COMMIT_REF_SLUG__
ref: __CI_ENVIRONMENT_SLUG__
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
tls:
- hosts:
- review.sickrage.ca
secretName: sickrage-ca-tls
rules:
- host: review.sickrage.ca
http:
paths:
- path: /__CI_COMMIT_REF_SLUG__
backend:
serviceName: __CI_COMMIT_REF_SLUG__
servicePort: 80
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
name: __CI_COMMIT_REF_SLUG__
namespace: __KUBE_NAMESPACE__
labels:
app: __CI_COMMIT_REF_SLUG__
ref: __CI_ENVIRONMENT_SLUG__
spec:
type: ClusterIP
ports:
- port: 80
protocol: TCP
targetPort: 8081
selector:
app: __CI_COMMIT_REF_SLUG__
\ No newline at end of file
This diff is collapsed.
{
"name": "sickrage",
"version": "9.4.184.dev9",
"private": true,
"repository": {
"type": "git",
......@@ -10,11 +11,12 @@
},
"homepage": "https://www.sickrage.ca",
"scripts": {
"dev": "webpack --mode development",
"prod": "webpack --mode production"
"build": "webpack --config webpack.config.js -p"
},
"devDependencies": {
"@fortawesome/fontawesome-free": "^5.1.0",
"@sentry/browser": "^5.9.0",
"@sentry/webpack-plugin": "^1.9.3",
"animate.css": "^3.6.1",
"autoprefixer": "^8.6.5",
"babel": "^6.23.0",
......
......@@ -3,5 +3,5 @@ crowdin-cli-py
babel
wheel
tox
wheel
vcrpy-unittest
\ No newline at end of file
vcrpy-unittest
Mako
\ No newline at end of file
[bumpversion]
current_version = 9.4.184.dev9
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<releaselevel>[a-z]+)(?P<preversion>\d+))?
serialize =
{major}.{minor}.{patch}.{releaselevel}{preversion}
{major}.{minor}.{patch}
commit = False
tag = False
[metadata]
description-file = README.txt
......@@ -24,4 +33,5 @@ input_file = sickrage/locale/messages.pot
output_dir = sickrage/locale
input_file = sickrage/locale/messages.pot
ignore_obsolete = true
previous = true
\ No newline at end of file
previous = true
......@@ -263,6 +263,9 @@ def main():
parser.add_argument('--disable_updates',
action='store_true',
help='Disable application updates')
parser.add_argument('--web_root',
default='',
help='Overrides URL web root')
parser.add_argument('--db_type',
default='sqlite',
help='Database type: sqlite or mysql')
......@@ -287,6 +290,7 @@ def main():
app.quiet = args.quiet
app.web_port = int(args.port)
app.web_host = args.host
app.web_root = args.web_root.lstrip('/').rstrip('/')
app.no_launch = args.nolaunch
app.disable_updates = args.disable_updates
app.developer = args.dev
......
......@@ -40,7 +40,6 @@ from dateutil import tz
from fake_useragent import UserAgent
from keycloak.realm import KeycloakRealm
from tornado.ioloop import IOLoop
from tzlocal import get_localzone
import sickrage
from sickrage.core.api import API
......@@ -103,6 +102,8 @@ class Core(object):
self.no_launch = None
self.disable_updates = None
self.web_port = None
self.web_host = None
self.web_root = None
self.developer = None
self.db_type = None
self.db_prefix = None
......
......@@ -55,8 +55,12 @@ class API(object):
@token.setter
def token(self, value):
token = value.decode() if isinstance(value, bytes) else value
if not isinstance(token, dict):
token = {}
if token.get('expires_in'):
token['expires_at'] = int(time.time() + token['expires_in'])