-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.yml
184 lines (176 loc) · 10.2 KB
/
build.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
default: "help"
expose: ["help", "info", "promote", "build", "release", "publish"]
configuration: ~/.dockerhub.yml
# ~/.dockerhub.yml should contains:
# DOCKERHUB_USER: <your dockerhub user>
# DOCKERHUB_PASS: <your dockerhub password or a dockerhub token>
properties:
latest: false
targets:
help:
doc: "print this message"
steps:
# - $: 'neon -info' => incorrect order, issue to open
- color: "cyan"
print: "Available targets"
- print: ""
- print: "help print this message"
- print: "info print build informations"
- print: "promote promote the project with a new tag based on git log history"
- print: "build build docker images locally [will trigger: info]"
- print: "release build docker images locally with tagged versions [will trigger: info->build]"
- print: "publish publish docker images to Dockerhub [will trigger: info->build->release]"
- print: ""
- print: 'Example : neon -props "{latest: true}" promote publish'
info:
doc: "print build informations"
steps:
- if: tag == ""
then:
- $: "git describe --tags --exact-match 2>/dev/null || git symbolic-ref -q --short HEAD"
1=: "tag"
3x: true
else:
- $: "echo -n ={tag}"
1=: "tag"
3x: true
- $: 'echo -n "={tag}" | sed -e s/^v//'
1=: "version"
3x: true
- $: "git rev-parse HEAD 2>/dev/null"
1=: "commit"
3x: true
- "date = now()[0:10]"
- if: BY == ""
then:
- $: "git config user.email"
1=: "by"
3x: true
else:
- $: "echo -n ={BY}"
1=: "by"
3x: true
- $: 'if expr match "={version}" "v\?[0-9]\+\.[0-9]\+\.[0-9]\+" 1>/dev/null 2>&1; then echo -n "yes"; else echo -n "no"; fi'
1=: "is_release"
3x: true
- $: "cut -f1 -d."
<: "=version"
1=: "version_major"
3x: true
- $: "cut -f2 -d."
<: "=version"
1=: "version_minor"
3x: true
- $: "cut -f3 -d."
<: "=version"
1=: "version_patch"
3x: true
- print: |-
TAG = ={tag}
COMMIT = ={commit}
DATE = ={date}
BY = ={by}
RELEASE = ={is_release}
- if: 'is_release == "yes"'
then:
- print: |-
VERSION = ={version_major}.={version_minor}.={version_patch}
promote:
doc: "promote the project with a new tag based on git log history"
steps:
- $: "git tag $(svu next || echo -n v0.1.0)"
2x: true
- $: "echo Promoted to $(svu current)"
# run "neon -props '{latest: true}' build" to include latest tag
build:
doc: "build docker images locally"
unless: 'newer(find(".", "build/last-*"), find(".", "Dockerfile*", "**/*.sh", ".zshrc", ".p10k.zsh"))'
depends: "info"
steps:
- print: "Executing build target"
color: cyan
- mkdir: "build"
- $: "sudo docker build -f Dockerfile.alpine -q --iidfile build/last-alpine-ci -t adrienaury/go-devcontainer-ci:alpine --target go-devcontainer-ci-alpine ."
- $: "sudo docker build -f Dockerfile.alpine -q --iidfile build/last-alpine-slim -t adrienaury/go-devcontainer-slim:alpine --target go-devcontainer-slim-alpine ."
- $: "sudo docker build -f Dockerfile.alpine -q --iidfile build/last-alpine-full -t adrienaury/go-devcontainer:alpine --target go-devcontainer-full-alpine ."
- $: "sudo docker build -f Dockerfile.debian -q --iidfile build/last-debian-ci -t adrienaury/go-devcontainer-ci:debian --target go-devcontainer-ci-debian ."
- $: "sudo docker build -f Dockerfile.debian -q --iidfile build/last-debian-slim -t adrienaury/go-devcontainer-slim:debian --target go-devcontainer-slim-debian ."
- $: "sudo docker build -f Dockerfile.debian -q --iidfile build/last-debian-full -t adrienaury/go-devcontainer:debian --target go-devcontainer-full-debian ."
- if: "latest"
then:
- $: "sudo docker tag adrienaury/go-devcontainer-ci:alpine adrienaury/go-devcontainer-ci:latest"
- $: "sudo docker tag adrienaury/go-devcontainer-slim:alpine adrienaury/go-devcontainer-slim:latest"
- $: "sudo docker tag adrienaury/go-devcontainer:alpine adrienaury/go-devcontainer:latest"
# run "neon -props '{latest: true}' release" to include latest tag
release:
doc: "build docker images locally with tagged versions"
# unless: 'is_release != "yes"' => is_release unknown variable, issue to open
depends: ["info", "build"]
steps:
- if: 'is_release == "yes"'
then:
- $: "sudo docker tag adrienaury/go-devcontainer:alpine adrienaury/go-devcontainer:v={version_major}"
- $: "sudo docker tag adrienaury/go-devcontainer:alpine adrienaury/go-devcontainer:v={version_major}.={version_minor}"
- $: "sudo docker tag adrienaury/go-devcontainer:alpine adrienaury/go-devcontainer:v={version_major}.={version_minor}.={version_patch}"
- $: "sudo docker images --no-trunc | grep $(cat build/last-alpine-full)"
- $: "sudo docker tag adrienaury/go-devcontainer:debian adrienaury/go-devcontainer:v={version_major}-debian"
- $: "sudo docker tag adrienaury/go-devcontainer:debian adrienaury/go-devcontainer:v={version_major}.={version_minor}-debian"
- $: "sudo docker tag adrienaury/go-devcontainer:debian adrienaury/go-devcontainer:v={version_major}.={version_minor}.={version_patch}-debian"
- $: "sudo docker images --no-trunc | grep $(cat build/last-debian-full)"
- $: "sudo docker tag adrienaury/go-devcontainer-slim:alpine adrienaury/go-devcontainer-slim:v={version_major}"
- $: "sudo docker tag adrienaury/go-devcontainer-slim:alpine adrienaury/go-devcontainer-slim:v={version_major}.={version_minor}"
- $: "sudo docker tag adrienaury/go-devcontainer-slim:alpine adrienaury/go-devcontainer-slim:v={version_major}.={version_minor}.={version_patch}"
- $: "sudo docker images --no-trunc | grep $(cat build/last-alpine-slim)"
- $: "sudo docker tag adrienaury/go-devcontainer-slim:debian adrienaury/go-devcontainer-slim:v={version_major}-debian"
- $: "sudo docker tag adrienaury/go-devcontainer-slim:debian adrienaury/go-devcontainer-slim:v={version_major}.={version_minor}-debian"
- $: "sudo docker tag adrienaury/go-devcontainer-slim:debian adrienaury/go-devcontainer-slim:v={version_major}.={version_minor}.={version_patch}-debian"
- $: "sudo docker images --no-trunc | grep $(cat build/last-debian-slim)"
- $: "sudo docker tag adrienaury/go-devcontainer-ci:alpine adrienaury/go-devcontainer-ci:v={version_major}"
- $: "sudo docker tag adrienaury/go-devcontainer-ci:alpine adrienaury/go-devcontainer-ci:v={version_major}.={version_minor}"
- $: "sudo docker tag adrienaury/go-devcontainer-ci:alpine adrienaury/go-devcontainer-ci:v={version_major}.={version_minor}.={version_patch}"
- $: "sudo docker images --no-trunc | grep $(cat build/last-alpine-ci)"
- $: "sudo docker tag adrienaury/go-devcontainer-ci:debian adrienaury/go-devcontainer-ci:v={version_major}-debian"
- $: "sudo docker tag adrienaury/go-devcontainer-ci:debian adrienaury/go-devcontainer-ci:v={version_major}.={version_minor}-debian"
- $: "sudo docker tag adrienaury/go-devcontainer-ci:debian adrienaury/go-devcontainer-ci:v={version_major}.={version_minor}.={version_patch}-debian"
- $: "sudo docker images --no-trunc | grep $(cat build/last-debian-ci)"
else:
- print: "Skipping release target (not a release)"
color: red
docker-login:
steps:
- $: "sudo docker login -u ={DOCKERHUB_USER} -p ={DOCKERHUB_PASS}"
2x: true
# run "neon -props '{latest: true}' publish" to include latest tag
publish:
doc: "push docker images to Dockerhub"
# unless: 'is_release != "yes"' => is_release unknown variable, issue to open
depends: ["info", "release", "docker-login"]
steps:
- if: 'is_release == "yes"'
then:
- $: "sudo docker push adrienaury/go-devcontainer:v={version_major}"
- $: "sudo docker push adrienaury/go-devcontainer:v={version_major}.={version_minor}"
- $: "sudo docker push adrienaury/go-devcontainer:v={version_major}.={version_minor}.={version_patch}"
- $: "sudo docker push adrienaury/go-devcontainer:v={version_major}-debian"
- $: "sudo docker push adrienaury/go-devcontainer:v={version_major}.={version_minor}-debian"
- $: "sudo docker push adrienaury/go-devcontainer:v={version_major}.={version_minor}.={version_patch}-debian"
- $: "sudo docker push adrienaury/go-devcontainer-slim:v={version_major}"
- $: "sudo docker push adrienaury/go-devcontainer-slim:v={version_major}.={version_minor}"
- $: "sudo docker push adrienaury/go-devcontainer-slim:v={version_major}.={version_minor}.={version_patch}"
- $: "sudo docker push adrienaury/go-devcontainer-slim:v={version_major}-debian"
- $: "sudo docker push adrienaury/go-devcontainer-slim:v={version_major}.={version_minor}-debian"
- $: "sudo docker push adrienaury/go-devcontainer-slim:v={version_major}.={version_minor}.={version_patch}-debian"
- $: "sudo docker push adrienaury/go-devcontainer-ci:v={version_major}"
- $: "sudo docker push adrienaury/go-devcontainer-ci:v={version_major}.={version_minor}"
- $: "sudo docker push adrienaury/go-devcontainer-ci:v={version_major}.={version_minor}.={version_patch}"
- $: "sudo docker push adrienaury/go-devcontainer-ci:v={version_major}-debian"
- $: "sudo docker push adrienaury/go-devcontainer-ci:v={version_major}.={version_minor}-debian"
- $: "sudo docker push adrienaury/go-devcontainer-ci:v={version_major}.={version_minor}.={version_patch}-debian"
- if: "latest"
then:
- $: "sudo docker push adrienaury/go-devcontainer-ci:latest"
- $: "sudo docker push adrienaury/go-devcontainer-slim:latest"
- $: "sudo docker push adrienaury/go-devcontainer:latest"
else:
- print: "Skipping release target (not a release)"
color: red