diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd895d6..beb864f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,7 @@ stages: - build - test - lint + - release - deploy variables: @@ -25,4 +26,5 @@ include: - local: '/gitlab-ci/build.yml' - local: '/gitlab-ci/test.yml' - local: '/gitlab-ci/lint.yml' + - local: '/gitlab-ci/release.yml' - local: '/gitlab-ci/deploy.yml' diff --git a/gitlab-ci/build.yml b/gitlab-ci/build.yml index 4d9854d..c8df615 100644 --- a/gitlab-ci/build.yml +++ b/gitlab-ci/build.yml @@ -5,7 +5,3 @@ static: - npm install script: - npm run build - only: - refs: - - development - - merge_requests diff --git a/gitlab-ci/deploy.yml b/gitlab-ci/deploy.yml index 05365df..0fe3ce4 100644 --- a/gitlab-ci/deploy.yml +++ b/gitlab-ci/deploy.yml @@ -4,11 +4,13 @@ deploy: environment: name: production url: rss.fudiggity.nl + rules: + - if: $CI_COMMIT_TAG before_script: - pip install ansible --quiet - - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@git.fudiggity.nl/sonny/ansible-playbooks.git deployment + - git clone https://git.fudiggity.nl/sonny/newsreader.git deployment - mkdir /root/.ssh - - echo "192.168.178.63 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILbtcdgJBhVCKsO88cV19EYefDTopdYejEQCp1pYr1Ga" > /root/.ssh/known_hosts + - echo "$DEPLOY_HOST_KEY" > /root/.ssh/known_hosts - echo "$DEPLOY_KEY" > deployment/deploy_key && chmod 0600 deployment/deploy_key - mkdir /root/.vaults - echo "$VAULT_PASSWORD" > /root/.vaults/newsreader && chmod 0600 /root/.vaults/newsreader @@ -20,5 +22,3 @@ deploy: --user ansible --private-key deployment/deploy_key --vault-password-file /root/.vaults/newsreader - only: - - master diff --git a/gitlab-ci/release.yml b/gitlab-ci/release.yml new file mode 100644 index 0000000..d6abaf6 --- /dev/null +++ b/gitlab-ci/release.yml @@ -0,0 +1,12 @@ +release: + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + rules: + - if: $CI_COMMIT_TAG + script: + - echo 'running release job' + release: + name: 'Release $CI_COMMIT_TAG' + description: 'Auto created release' + tag_name: '$CI_COMMIT_TAG' + ref: '$CI_COMMIT_TAG' diff --git a/src/newsreader/conf/base.py b/src/newsreader/conf/base.py index b117b4f..43b89fd 100644 --- a/src/newsreader/conf/base.py +++ b/src/newsreader/conf/base.py @@ -2,6 +2,8 @@ import os from pathlib import Path +from .version import get_current_version + BASE_DIR = Path(__file__).resolve().parent.parent.parent.parent DJANGO_PROJECT_DIR = os.path.join(BASE_DIR, "src", "newsreader") @@ -212,6 +214,8 @@ STATICFILES_FINDERS = [ DEFAULT_FROM_EMAIL = "newsreader@rss.fudiggity.nl" # Project settings +VERSION = get_current_version() + # Reddit integration REDDIT_CLIENT_ID = "CLIENT_ID" REDDIT_CLIENT_SECRET = "CLIENT_SECRET" diff --git a/src/newsreader/conf/production.py b/src/newsreader/conf/production.py index 5bc11a9..bfe9818 100644 --- a/src/newsreader/conf/production.py +++ b/src/newsreader/conf/production.py @@ -65,6 +65,7 @@ try: dsn=os.environ.get("SENTRY_DSN"), integrations=[DjangoIntegration(), CeleryIntegration()], send_default_pii=False, + release=VERSION, ) except ImportError: pass diff --git a/src/newsreader/conf/version.py b/src/newsreader/conf/version.py new file mode 100644 index 0000000..d91d770 --- /dev/null +++ b/src/newsreader/conf/version.py @@ -0,0 +1,13 @@ +import os +import subprocess + + +def get_current_version(): + if "VERSION" in os.environ: + return os.environ["VERSION"] + + try: + output = subprocess.check_output(["git", "describe"], universal_newlines=True) + return output.strip() + except (subprocess.CalledProcessError, OSError): + return "" diff --git a/src/newsreader/scss/components/errorlist/_errorlist.scss b/src/newsreader/scss/components/errorlist/_errorlist.scss index d9c592c..382558d 100644 --- a/src/newsreader/scss/components/errorlist/_errorlist.scss +++ b/src/newsreader/scss/components/errorlist/_errorlist.scss @@ -4,8 +4,6 @@ margin: 5px 0; padding: 0; - color: $white; - list-style: disc; list-style-position: inside;