diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cc312da5f80f993443c3c96154d1e4389d433b92..edaad216319b25bf2ee85bacd161927e2f67b015 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,13 +13,19 @@ variables: PY36_IMAGE: thalia/python-thalia:3.6 PIP_CACHE_DIR: "${CI_PROJECT_DIR}/pip-cache" +stages: + - test + - deploy + pep8: + stage: test image: $PY35_IMAGE before_script: script: - tox -e flake8 .djangotest: &djangotest + stage: test services: - postgres:latest before_script: @@ -44,6 +50,7 @@ python36-django20: DJANGO_VERSION: django20 docs: + stage: test image: $PY35_IMAGE before_script: # install django deps @@ -60,6 +67,45 @@ docs: - ./generate-apidocs.sh - git diff --exit-code +build docker image: + stage: test + services: + - docker:dind + image: thalia/docker-compose + tags: + - docker + before_script: + - echo $GITLAB_REGISTRY_PASSWORD | docker login --username thaliawww --password-stdin registry.gitlab.com + script: + - docker-compose build --build-arg install_dev_requirements=0 web + - docker-compose run --rm web test + - docker tag $DOCKER_LATEST $DOCKER_TAG + - docker push $DOCKER_TAG + variables: + DOCKER_LATEST: registry.gitlab.com/thaliawww/concrexit:latest + DOCKER_TAG: registry.gitlab.com/thaliawww/concrexit:$CI_COMMIT_SHA + +tag docker image: + stage: deploy + services: + - docker:dind + image: docker:git + tags: + - docker + only: + - tags + dependencies: + - build docker image + before_script: + - echo $GITLAB_REGISTRY_PASSWORD | docker login --username thaliawww --password-stdin registry.gitlab.com + script: + - docker pull $DOCKER_TAG + - docker push $DOCKER_TAG_PRODUCTION + variables: + DOCKER_TAG: registry.gitlab.com/thaliawww/concrexit:$CI_COMMIT_SHA + DOCKER_TAG_PRODUCTION: registry.gitlab.com/thaliawww/concrexit:$CI_COMMIT_TAG + + cache: key: "$CI_JOB_NAME" paths: diff --git a/Dockerfile b/Dockerfile index 24c502c64d0f38dfed2cb34b79fee63aed3bd789..0143d146c1cba8d5f9280acf26c1c5fc04a901fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -67,4 +67,4 @@ COPY docs /usr/src/app/docs # Cache docs between builds if not mounting to FS VOLUME /concrexit/docs -RUN echo "Don't build releases without release.sh!" +RUN echo "Don't build releases yourself, let CI do it!" diff --git a/release.sh b/release.sh index bb51bd75b595b1eae4a1b99065b2046dff5ae745..cb398d98076be0943ae92f6d4c8cb34ad8e98117 100755 --- a/release.sh +++ b/release.sh @@ -42,6 +42,9 @@ version_major=${version%.*} echo "Changing directory to root of repository" cd "${0%/*}" +echo "Making sure we're up-to-date" +git fetch --tags + echo "Changing to branch 'release/$version_major'" git checkout "release/$version_major" @@ -57,23 +60,6 @@ fi if yesno "Do you want to push the tag to the repository?"; then echo "Pushing tags:" git push --tags - echo "Don't forget to fill in the release description" -fi - -if ! yesno "Do you want to build a docker container?"; then - exit 1 -fi - -if [ -n "$(git status --porcelain)" ]; then - echo "Unclean working directory!" - git status - exit 1 -fi - -docker_tag="registry.gitlab.com/thaliawww/concrexit:$version" - -docker build --build-arg install_dev_requirements=0 --pull -t "$docker_tag" . - -if yesno "Do you want to push the container?"; then - docker push "$docker_tag" + echo "Don't forget to fill in the release description on the website:" + echo "https://gitlab.science.ru.nl/thalia/concrexit/tags/v$version/release/edit" fi