From e31bca70166e8cdb87e73943726bf776dfca94b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Fri, 2 Jun 2017 19:21:12 +0200 Subject: [PATCH] Push to dockerhub instead of private registry --- .gitlab-ci.yml | 42 +++++++++++++++++++++++++++++++----------- Makefile | 24 +++++++++++++----------- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c92672d..8f88e95 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,7 +15,7 @@ stages: - clean before_script: - - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY + - docker login -u $HUB_USER -p $HUB_PASSWORD .test: &test_definition stage: test @@ -58,14 +58,6 @@ push-latest: - master - triggers -deploy: - stage: deploy - environment: test - script: - - make -e deploy - only: - - master - push-github: stage: deploy script: @@ -74,8 +66,36 @@ push-github: - master - triggers -clean : +deploy_pypi: + stage: deploy + script: # Configure the PyPI credentials, then push the package, and cleanup the creds. + - echo "[server-login]" >> ~/.pypirc + - echo "username=" ${PYPI_USER} >> ~/.pypirc + - echo "password=" ${PYPI_PASSWORD} >> ~/.pypirc + - make pip_upload + - echo "" > ~/.pypirc && rm ~/.pypirc # If the above fails, this won't run. + only: + - /^v\d+\.\d+\.\d+([abc]\d*)?$/ # PEP-440 compliant version (tags) + except: + - branches + +deploy: + stage: deploy + environment: test + script: + - make -e deploy + only: + - master + +clean_docker : stage: clean script: - make -e clean - when: manual \ No newline at end of file + when: manual + +cleanup_pypirc: + stage: clean + when: always # this is important; run even if preceding stages failed. + script: + - rm -vf ~/.pypirc # we don't want to leave these around, but GitLab may clean up anyway. + - docker logout \ No newline at end of file diff --git a/Makefile b/Makefile index ed42011..00756d1 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,17 @@ +NAME=senpy +VERSION=$(shell git describe --tags --dirty 2>/dev/null) +GITHUB_REPO=git@github.com:gsi-upm/senpy.git + +IMAGENAME=gsiupm/senpy +IMAGEWTAG=$(IMAGENAME):$(VERSION) + PYVERSIONS=3.5 2.7 PYMAIN=$(firstword $(PYVERSIONS)) -NAME=senpy -REPO=gsiupm -VERSION=$(shell git describe --tags --dirty 2>/dev/null) -TARNAME=$(NAME)-$(VERSION).tar.gz -IMAGENAME=$(REPO)/$(NAME) -IMAGEWTAG=$(IMAGENAME):$(VERSION) + DEVPORT=5000 + +TARNAME=$(NAME)-$(VERSION).tar.gz action="test-${PYMAIN}" -GITHUB_REPO=git@github.com:gsi-upm/senpy.git KUBE_CA_PEM_FILE="" KUBE_URL="" @@ -83,6 +86,9 @@ pip_test-%: sdist pip_test: $(addprefix pip_test-,$(PYVERSIONS)) +pip_upload: pip_test + python setup.py sdist upload ; + clean: @docker ps -a | grep $(IMAGENAME) | awk '{ split($$2, vers, "-"); if(vers[0] != "${VERSION}"){ print $$1;}}' | xargs docker rm -v 2>/dev/null|| true @docker images | grep $(IMAGENAME) | awk '{ split($$2, vers, "-"); if(vers[0] != "${VERSION}"){ print $$1":"$$2;}}' | xargs docker rmi 2>/dev/null|| true @@ -98,9 +104,6 @@ git_tag: git_push: git push --tags origin master -pip_upload: pip_test - python setup.py sdist upload ; - run-%: build-% docker run --rm -p $(DEVPORT):5000 -ti '$(IMAGEWTAG)-python$(PYMAIN)' --default-plugins @@ -141,5 +144,4 @@ deploy: @$(KUBECTL) apply -f /tmp/cwd/k8s/ - .PHONY: test test-% test-all build-% build test pip_test run yapf push-main push-% dev ci version .FORCE deploy