-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
81 lines (73 loc) · 2.51 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
image: docker:stable
stages:
- build
- containerize
- publish
services:
- docker:dind
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
DOCKER_HUB_NAME: mediciland/oip
before_script:
- apk update && apk add curl zip unzip tar
- docker login -u $dockerhub_user -p $dockerhub_pass
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
Build:
stage: build
script:
- ./ci/buildBinaries.sh
- tar -czvf $CI_PROJECT_DIR/oipd.linux.amd64.tar.gz -C $CI_PROJECT_DIR/build/linux .
- tar -czvf $CI_PROJECT_DIR/oipd.darwin.amd64.tar.gz -C $CI_PROJECT_DIR/build/darwin .
- zip $CI_PROJECT_DIR/oipd.windows.amd64.zip $CI_PROJECT_DIR/build/windows/oipd.exe
artifacts:
paths:
- oipd.linux.amd64.tar.gz
- oipd.darwin.amd64.tar.gz
- oipd.windows.amd64.zip
Containerize (master):
stage: containerize
script:
- curl --header "Private-Token:$gitlab_readonly_pass" -L "https://gitlab.com/api/v4/projects/mediciland%2Fblockchain%2Fflod-go/jobs/artifacts/master/download?job=Build" > artifacts.zip
- unzip artifacts.zip
- ls -al $CI_PROJECT_DIR
- tar xzvf $CI_PROJECT_DIR/oipd.linux.amd64.tar.gz
- mv oipd bin/oipd
- ls bin
- ./ci/buildImage.sh
- docker tag oip:dev "$CI_REGISTRY_IMAGE":next
- docker push "$CI_REGISTRY_IMAGE":next
- docker tag "$CI_REGISTRY_IMAGE":next "$DOCKER_HUB_NAME":next
- docker push "$DOCKER_HUB_NAME":next
only:
- master
Containerize (branch):
stage: containerize
script:
- curl --header "Private-Token:$gitlab_readonly_pass" -L "https://gitlab.com/api/v4/projects/mediciland%2Fblockchain%2Fflod-go/jobs/artifacts/master/download?job=Build" > artifacts.zip
- unzip artifacts.zip
- ls -al $CI_PROJECT_DIR
- tar xzvf $CI_PROJECT_DIR/oipd.linux.amd64.tar.gz
- mv oipd bin/oipd
- ls bin
- ./ci/buildImage.sh
- docker tag oip:dev "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
only:
- branches
except:
- master
Push to Docker Hub:
stage: publish
script:
- docker pull "$CI_REGISTRY_IMAGE":next
- docker tag "$CI_REGISTRY_IMAGE":next "$CI_REGISTRY_IMAGE":latest
- docker push "$CI_REGISTRY_IMAGE":latest
- docker tag "$CI_REGISTRY_IMAGE":latest "$DOCKER_HUB_NAME:$CI_COMMIT_TAG"
- docker push "$DOCKER_HUB_NAME:$CI_COMMIT_TAG"
- docker tag "$DOCKER_HUB_NAME:$CI_COMMIT_TAG" "$DOCKER_HUB_NAME":latest
- docker push "$DOCKER_HUB_NAME":latest
only:
- tags
except:
- branches