-
Notifications
You must be signed in to change notification settings - Fork 157
/
.gitlab-ci.yml
149 lines (139 loc) · 3.47 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
stages:
- test
- build and push
- manifests
- release
.common_build: &common_build
image: docker:stable
stage: build and push
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
services:
- docker:dind
except:
- tags
only:
changes:
- "Dockerfile*"
- ouroboros
- pyouroboros/*
- .gitlab-ci.yml
before_script:
- mkdir $HOME/.docker
- echo '{"experimental":"enabled"}' > $HOME/.docker/config.json
- if [[ $CI_COMMIT_REF_NAME == "master" ]]; then
export TAG=$(grep -i version pyouroboros/__init__.py | cut -d \ -f3 | tr -d \");
else
export TAG="develop";
fi
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USER" --password-stdin
- export CI_PROJECT_PATH=$(echo $CI_PROJECT_PATH | tr "[:upper:]" "[:lower:]")
.common_release: &common_release
<<: *common_build
tags:
- docker
- shared
only:
refs:
- master
flake8:
image: python:3.7.3-alpine
stage: test
cache:
key: "ouroboros-cache"
paths:
- .cache/pip
- venv/
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
tags:
- shared
before_script:
- python -m venv venv
- source venv/bin/activate
- pip install -U flake8
script:
- flake8 --max-line-length 120 ouroboros *.py pyouroboros/*.py
amd64:
<<: *common_build
tags:
- docker
- shared
script:
- docker build --pull
--cache-from "$CI_PROJECT_PATH":"$TAG-amd64"
-t "$CI_PROJECT_PATH":"$TAG-amd64" .
- docker push "$CI_PROJECT_PATH":"$TAG-amd64"
armv6:
<<: *common_build
tags:
- docker
- arm
script:
- docker build --pull
--cache-from "$CI_PROJECT_PATH":"$TAG-arm"
-t "$CI_PROJECT_PATH":"$TAG-arm"
-f Dockerfile.arm .
- docker push "$CI_PROJECT_PATH":"$TAG-arm"
arm64v8:
<<: *common_build
tags:
- docker
- arm64
script:
- docker build --pull
--cache-from "$CI_PROJECT_PATH":"$TAG-arm64"
-t "$CI_PROJECT_PATH":"$TAG-arm64"
-f Dockerfile.arm64 .
- docker push "$CI_PROJECT_PATH":"$TAG-arm64"
versioned:
<<: *common_build
stage: manifests
tags:
- docker
- shared
script:
- docker manifest create "$CI_PROJECT_PATH":"$TAG"
"$CI_PROJECT_PATH":"$TAG-amd64"
"$CI_PROJECT_PATH":"$TAG-arm64"
"$CI_PROJECT_PATH":"$TAG-arm"
- docker manifest push -p "$CI_PROJECT_PATH":"$TAG"
latest:
<<: *common_release
stage: manifests
tags:
- docker
script:
- docker manifest create "$CI_PROJECT_PATH":latest
"$CI_PROJECT_PATH":"$TAG-amd64"
"$CI_PROJECT_PATH":"$TAG-arm64"
"$CI_PROJECT_PATH":"$TAG-arm"
- docker manifest push -p "$CI_PROJECT_PATH":latest
github:
<<: *common_release
stage: release
script:
- apk add git
- git remote set-url origin "https://$GITHUB_USER:[email protected]/$CI_PROJECT_PATH.git"
- git tag $TAG
- git push --tags
pypi:
<<: *common_release
image: python:3.7.3-alpine
stage: release
cache:
key: "ouroboros-cache"
paths:
- .cache/pip
- venv/
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
tags:
- shared
before_script:
- python -m venv venv
- source venv/bin/activate
- pip install -U twine
script:
- venv/bin/python setup.py sdist && venv/bin/python -m twine upload --skip-existing -u ${PYPI_CREDS_USR} -p ${PYPI_CREDS_PSW} dist/*