-
Notifications
You must be signed in to change notification settings - Fork 75
/
.gitlab-ci.yml
102 lines (94 loc) · 2.44 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
46
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
stages:
- build
- deploy
variables:
PYTHON_VER: "3.8"
ROS_DISTRO: "noetic"
ROBO_GYM_IMAGE: $CI_REGISTRY_IMAGE:$PYTHON_VER-$CI_COMMIT_SHA
ROBOT_SERVERS_IMAGE: "$CI_REGISTRY/robo-gym/robot-servers:$ROS_DISTRO-develop-latest"
before_script:
# docker login asks for the password to be passed through stdin for security
# we use $CI_JOB_TOKEN here which is a special token provided by GitLab
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
# The pipeline needs at minimum one job to run
dummy:
stage: build
variables:
GIT_STRATEGY: none
script:
- ":"
only:
- /^docs.*$/
.build_robo-gym_image: &build_robo-gym_image_def
image: docker:18.09
services:
- docker:18.09-dind
tags:
- docker-executor
stage: build
retry:
max: 2
script:
# fetch the latest image (not failing if image is not found)
- docker pull $CI_REGISTRY_IMAGE:$PYTHON_VER-latest || true
- >
docker build
--pull
--cache-from $CI_REGISTRY_IMAGE:$PYTHON_VER-latest
--tag $ROBO_GYM_IMAGE
--build-arg PYTHON_VER=$PYTHON_VER
--build-arg CACHEBUST=$CI_COMMIT_SHA
.
- docker push $ROBO_GYM_IMAGE
- docker tag $ROBO_GYM_IMAGE $CI_REGISTRY_IMAGE:$PYTHON_VER-latest
- docker push $CI_REGISTRY_IMAGE:$PYTHON_VER-latest
except:
- /^docs.*$/
build_robo-gym_image_py38:
<<: *build_robo-gym_image_def
variables:
PYTHON_VER: "3.8"
only:
- schedules
build_robo-gym_image_py39:
<<: *build_robo-gym_image_def
variables:
PYTHON_VER: "3.9"
only:
- schedules
deploy_docker_image:
image: docker:18.09
services:
- docker:18.09-dind
tags:
- docker-executor
stage: deploy
variables:
GIT_STRATEGY: none
script:
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
- docker pull $ROBO_GYM_IMAGE
- docker tag $ROBO_GYM_IMAGE $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH:latest
- docker push $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH:latest
only:
- master
- develop
except:
- /^docs.*$/
deploy_production:
image: python:3.8-slim-buster
before_script:
- pip3 install twine
- python3 setup.py sdist
stage: deploy
variables:
TWINE_USERNAME: $PYPI_USERNAME
TWINE_PASSWORD: $PYPI_PASSWORD
script:
- twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
only:
- /^v.*$/
except:
refs:
- branches
- triggers