make_ci.sh 1.61 KB
Newer Older
torgiren's avatar
Devel  
torgiren committed
1
2
#!/bin/bash
cat <<EOF > .gitlab-ci.yml
torgiren's avatar
ci    
torgiren committed
3
---
torgiren's avatar
Devel  
torgiren committed
4
5
6
7
8
9
10
stages:
  - checks
  - pack
  - upload

upload_all:
  stage: upload
torgiren's avatar
ci    
torgiren committed
11
12
  image:
    name: alpine/helm:3.2.1
torgiren's avatar
Devel  
torgiren committed
13
  script:
torgiren's avatar
ci    
torgiren committed
14
15
16
17
    - apk add --no-cache ca-certificates git
    - helm plugin install https://github.com/chartmuseum/helm-push.git
    - helm repo add --username \${CI_REGISTRY_USER} --password \${CI_REGISTRY_PASSWORD} my-repo "\${CI_API_V4_URL}/projects/\${CI_PROJECT_ID}/packages/helm/stable"
    - sh -c 'for file in *tgz; do helm push \${file} my-repo; done'
torgiren's avatar
Devel  
torgiren committed
18
19
20
  only:
    - master

torgiren's avatar
ci    
torgiren committed
21
22
23
24
check_ci_script:
  stage: .pre
  image: bash
  script:
torgiren's avatar
ci    
torgiren committed
25
    - sh -ec 'for i in \$(ls */Chart.yaml); do chart=\$(dirname \$i); grep "^build_\${chart}:" .gitlab-ci.yml; done'
torgiren's avatar
ci    
torgiren committed
26

torgiren's avatar
Devel  
torgiren committed
27
28
29
30
31
32
EOF

for i in $(ls */Chart.yaml); do
    chart=$(dirname $i)
    echo "adding $chart"
    cat <<EOF >> .gitlab-ci.yml
torgiren's avatar
ci    
torgiren committed
33

torgiren's avatar
ci    
torgiren committed
34
.versions_check_$(echo ${chart}|tr '-' '_'):
torgiren's avatar
Devel  
torgiren committed
35
36
37
38
  stage: checks
  image: curlimages/curl:latest
  script:
    - 'VER=\$(grep "^version: " ${chart}/Chart.yaml|cut -f 2 -d":"|tr -d " ")'
torgiren's avatar
ci    
torgiren committed
39
    - echo "\${VER}"
torgiren's avatar
ci    
torgiren committed
40
    - export VER; sh -c 'curl -v https://gitlab.home.exphost.pl/api/v4/projects/6/packages/helm/stable/charts/${chart}-\${VER}.tgz --output /dev/null --fail; [ \$? -gt 0 ]'
torgiren's avatar
ci    
torgiren committed
41
  only:
torgiren's avatar
ci    
torgiren committed
42
    changes:
torgiren's avatar
ci    
torgiren committed
43
      - ${chart}/**/*
torgiren's avatar
ci    
torgiren committed
44
45
46
47
48
49
50

lint_$(echo ${chart}|tr '-' '_'):
  stage: checks
  image: alpine/helm:latest
  before_script:
  script:
    - helm lint ${chart}
torgiren's avatar
ci    
torgiren committed
51
52
53
#  only:
#    changes:
#      - ${chart}/**/*
torgiren's avatar
Devel  
torgiren committed
54
55
56
57
58
59
60
61
62
63

build_$(echo ${chart}|tr '-' '_'):
  stage: pack
  image: alpine/helm:latest
  before_script:
  script:
    - helm package ${chart}
  artifacts:
    paths:
      - "${chart}-*.tgz"
torgiren's avatar
ci    
torgiren committed
64
65
66
#  only:
#    changes:
#      - ${chart}/**/*
torgiren's avatar
Devel  
torgiren committed
67
68
EOF
done