-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
134 lines (121 loc) · 4.53 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
include:
- file: /Scan/trivy.yml
project: jitesoft/gitlab-ci-lib
stages:
- build
- containerize
- scan
.build:src:alpine:
stage: build
image: registry.gitlab.com/jitesoft/dockerfiles/go:latest
script:
- mkdir binaries
- mkdir -p ${GOPATH}/github.com/keybase/bot-sshca
- apk add --no-cache wget grep tar curl
- VERSION=$(wget -qO- https://github.com/keybase/bot-sshca/releases | grep -oP '(?<=releases\/tag\/)(.*?)(?=\">)' | awk 'NR==1{print $1}')
- printf ${VERSION} > binaries/version.txt
- curl -L https://github.com/keybase/bot-sshca/archive/${VERSION}.tar.gz -o /tmp/kssh-bot.tar.gz
- tar -xzf /tmp/kssh-bot.tar.gz -C ${GOPATH}/github.com/keybase/bot-sshca --strip-components=1
- cd ${GOPATH}/github.com/keybase/bot-sshca
- go mod download
- go build -ldflags "-w -s -X main.VersionNumber=${VERSION}" ${GOPATH}/github.com/keybase/bot-sshca/src/cmd/keybaseca/keybaseca.go
- cd ${CI_PROJECT_DIR}
- mv Alpine/entrypoint binaries/entrypoint
- mv Alpine/Dockerfile ${CI_PROJECT_DIR}/Dockerfile
- cp ${GOPATH}/github.com/keybase/bot-sshca/keybaseca ${CI_PROJECT_DIR}/binaries/keybaseca-${ARCH}
artifacts:
paths:
- binaries
- Dockerfile
expire_in: 1 hour
build:src:alpine:amd64:
extends: .build:src:alpine
tags:
- native-amd64
variables:
ARCH: "amd64"
GO111MODULE: "on"
build:src:alpine:arm64:
extends: .build:src:alpine
tags:
- native-aarch64
variables:
ARCH: "arm64"
GO111MODULE: "on"
.build:src:ubuntu:
stage: build
image: registry.gitlab.com/jitesoft/dockerfiles/go/ubuntu:latest
script:
- mkdir binaries
- mkdir -p ${GOPATH}/github.com/keybase/bot-sshca
- apt-get update
- apt-get install -y wget grep tar curl
- VERSION=$(wget -qO- https://github.com/keybase/bot-sshca/releases | grep -oP '(?<=releases\/tag\/)(.*?)(?=\">)' | awk 'NR==1{print $1}')
- printf ${VERSION} > binaries/version.txt
- printf ${VERSION} > binaries/version.txt
- curl -L https://github.com/keybase/bot-sshca/archive/${VERSION}.tar.gz -o /tmp/kssh-bot.tar.gz
- tar -xzf /tmp/kssh-bot.tar.gz -C ${GOPATH}/github.com/keybase/bot-sshca --strip-components=1
- cd ${GOPATH}/github.com/keybase/bot-sshca
- go mod download
- go build -ldflags "-w -s -X main.VersionNumber=${VERSION}" ${GOPATH}/github.com/keybase/bot-sshca/src/cmd/keybaseca/keybaseca.go
- cd ${CI_PROJECT_DIR}
- mv Ubuntu/entrypoint binaries/entrypoint
- mv Ubuntu/Dockerfile ${CI_PROJECT_DIR}/Dockerfile
- cp ${GOPATH}/github.com/keybase/bot-sshca/keybaseca ${CI_PROJECT_DIR}/binaries/keybaseca-${ARCH}
artifacts:
paths:
- binaries
- Dockerfile
expire_in: 1 hour
build:src:ubuntu:amd64:
extends: .build:src:ubuntu
tags:
- native-amd64
variables:
ARCH: "amd64"
GO111MODULE: "on"
build:src:ubuntu:arm64:
extends: .build:src:ubuntu
tags:
- native-aarch64
variables:
ARCH: "arm64"
GO111MODULE: "on"
containerize:alpine:
needs:
- build:src:alpine:amd64
- build:src:alpine:arm64
stage: containerize
variables:
GIT_STRATEGY: none
image: registry.gitlab.com/jitesoft/dockerfiles/misc:latest
script:
- VERSION=$(cat binaries/version.txt)
- VERSION_SHORT=$(echo ${VERSION} | cut -d'-' -f 1)
- TAG_LIST=$(helper "${CI_REGISTRY_IMAGE}/alpine" "latest,${VERSION}")
- TAG_LIST="$(helper "jitesoft/keybase-sshca,ghcr.io/jitesoft/keybase-sshca" "latest-alpine,${VERSION}-alpine,${VERSION_SHORT}-alpine") ${TAG_LIST}"
- docker buildx build --platform linux/amd64,linux/arm64 --push ${TAG_LIST} --build-arg VERSION="${VERSION}" --progress plain .
tags: [ jitesoft, protected, buildx ]
containerize:ubuntu:
needs:
- build:src:ubuntu:amd64
- build:src:ubuntu:arm64
stage: containerize
variables:
GIT_STRATEGY: none
image: registry.gitlab.com/jitesoft/dockerfiles/misc:latest
script:
- VERSION=$(cat binaries/version.txt)
- VERSION_SHORT=$(echo ${VERSION} | cut -d'-' -f 1)
- TAG_LIST=$(helper "${CI_REGISTRY_IMAGE}" "latest,${VERSION}")
- TAG_LIST="$(helper "jitesoft/keybase-sshca,ghcr.io/jitesoft/keybase-sshca" "latest,${VERSION},${VERSION_SHORT}") ${TAG_LIST}"
- docker buildx build --platform linux/amd64,linux/arm64 --push ${TAG_LIST} --build-arg VERSION="${VERSION}" --progress plain .
tags: [ jitesoft, protected, buildx ]
scan:ubuntu:
extends: .container_scanning
variables:
SCANNING_IMAGE_NAME: "${CI_REGISTRY_IMAGE}:latest"
scan:alpine:
extends: .container_scanning
variables:
SCANNING_IMAGE_NAME: "${CI_REGISTRY_IMAGE}/alpine:latest"