-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
130 lines (108 loc) · 3.18 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
image: python:3.9
variables:
TAGNAME: "continuous-${CI_COMMIT_BRANCH}"
DOCKER_REPOSITORY: "${CI_REGISTRY}/cipres/${CI_PROJECT_NAME}"
stages:
- prepare
- build
- release
- docker
prepare:
image: python:3.9
stage: prepare
script:
- export VERSION=$(python -c 'import levior; print(levior.__version__)')
- >
echo "WHEEL_FILENAME=${CI_PROJECT_NAME}-${VERSION}-py3-none-any.whl"
>> vars.env
- >
echo "WHEEL_ARTIFACT_URL=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/continuous-${CI_COMMIT_BRANCH}/${CI_PROJECT_NAME}-${VERSION}-py3-none-any.whl"
>> vars.env
- >
echo "APPIMAGE_FILENAME=${CI_PROJECT_NAME}-${VERSION}-x86_64.AppImage"
>> vars.env
- >
echo "APPIMAGE_LATEST_FILENAME=${CI_PROJECT_NAME}-latest-x86_64.AppImage"
>> vars.env
- >
echo "APPIMAGE_ARTIFACT_URL=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/continuous-${CI_COMMIT_BRANCH}/${CI_PROJECT_NAME}-${VERSION}-x86_64.AppImage"
>> vars.env
artifacts:
reports:
dotenv: vars.env
build:
stage: build
only:
- master
- devel
- rdf
script:
- apt-get -y update
- apt-get install -y fuse
- python3 -m venv venv
- source venv/bin/activate
- python3 -m pip install --upgrade pip
- pip install build wheel flake8
- pip install '.[zim,js,test]'
- flake8 levior
- python -m build
- pytest --cov --cov-report=term --cov-report=xml:coverage.xml -v -s tests
- .gitlab/appimage-build
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
artifacts:
paths:
- "*.AppImage"
- dist/*.whl
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
release:
image: registry.gitlab.com/gitlab-org/release-cli
stage: release
only:
- master
- devel
- rdf
script:
- apk add curl
- >
curl
--request DELETE
--header "JOB-TOKEN: $CI_JOB_TOKEN"
--header "PRIVATE-TOKEN: ${GITLAB_PRIVATE_TOKEN}"
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/releases/${TAGNAME}"
- >
curl --header "JOB-TOKEN: $CI_JOB_TOKEN"
--upload-file
dist/${WHEEL_FILENAME}
${WHEEL_ARTIFACT_URL}
- >
curl --header "JOB-TOKEN: $CI_JOB_TOKEN"
--upload-file
${APPIMAGE_FILENAME}
${APPIMAGE_ARTIFACT_URL}
- >
release-cli create
--name release-${CI_COMMIT_SHA}
--description README.md
--tag-name $TAGNAME
--ref $CI_COMMIT_SHA
--assets-link
"{\"name\": \"${WHEEL_FILENAME}\", \"filepath\": \"/${WHEEL_FILENAME}\", \"url\": \"${WHEEL_ARTIFACT_URL}\"}"
--assets-link
"{\"name\": \"${APPIMAGE_FILENAME}\", \"filepath\": \"/${APPIMAGE_LATEST_FILENAME}\", \"url\": \"${APPIMAGE_ARTIFACT_URL}\"}"
docker:
image: docker:latest
stage: docker
services:
- docker:dind
rules:
- if: $CI_COMMIT_MESSAGE =~ /\[docker\]/
when: always
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- DOCKER_TAG="latest"
- docker build -f Dockerfile -t $DOCKER_REPOSITORY:$DOCKER_TAG .
- docker push $DOCKER_REPOSITORY:$DOCKER_TAG