Skip to content

Commit 0bb0925

Browse files
committed
docs(build): complete doc
1 parent 6f2f485 commit 0bb0925

3 files changed

Lines changed: 75 additions & 30 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ SHELL := /bin/zsh # Use zsh syntax
88
init:
99
@touch ~/.dockerhub.yml
1010
@chmod 0600 ~/.dockerhub.yml
11+
@touch ~/.github.yml
12+
@chmod 0600 ~/.github.yml
1113
@git config --local core.hooksPath githooks
1214

1315
.PHONY: warning

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ OK
396396

397397
Publish tagged binary to Github (as a Release). Under the hood, the [`goreleaser`](https://github.com/goreleaser/goreleaser) tool is used.
398398

399+
Edit the file `./goreleaser.template.yml` to configure the [`goreleaser`](https://github.com/goreleaser/goreleaser) build.
400+
399401
A prerequisite to this target is that a file named `.github.yml` at the home directory (`~/.github.yml`) contains a `GITHUB_TOKEN` property.
400402

401403
```console
@@ -600,13 +602,45 @@ adrienaury/go-template-webserver v0.2.0 sha
600602
OK
601603
```
602604

605+
Use `-props '{latest: true}'` to include the latest tag.
606+
607+
```console
608+
$ neon -props '{latest: true}' docker-tag
609+
----------------------------------------------- info --
610+
MODULE = github.com/adrienaury/go-template
611+
PROJECT = go-template
612+
TAG = v0.2.0
613+
COMMIT = 00a4bdbf147a4394aa1e7f0483802f94658e9ce3
614+
DATE = 2021-05-02
615+
BY = adrienaury@gmail.com
616+
RELEASE = yes
617+
VERSION = 0.2.0
618+
--------------------------------------------- docker --
619+
adrienaury/go-template refactor sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
620+
adrienaury/go-template v0.2.0 sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
621+
adrienaury/go-template-webserver refactor sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
622+
adrienaury/go-template-webserver v0.2.0 sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
623+
----------------------------------------- docker-tag --
624+
adrienaury/go-template latest sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
625+
adrienaury/go-template refactor sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
626+
adrienaury/go-template v0 sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
627+
adrienaury/go-template v0.2 sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
628+
adrienaury/go-template v0.2.0 sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
629+
adrienaury/go-template-webserver latest sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
630+
adrienaury/go-template-webserver refactor sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
631+
adrienaury/go-template-webserver v0 sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
632+
adrienaury/go-template-webserver v0.2 sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
633+
adrienaury/go-template-webserver v0.2.0 sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
634+
OK
635+
```
636+
603637
#### Docker-publish
604638

605639
Publish tagged docker images to Dockerhub.
606640

607641
A prerequisite to this target is that a file named `.dockerhub.yml` at the home directory (`~/.dockerhub.yml`) contains a `DOCKERHUB_USER` property and a `DOCKERHUB_PASS` property.
608642

609-
The build properties are the same as the [`docker`](#docker) target (a `dockerfiles` map).
643+
The build properties are the same as the [`docker`](#docker) target and the [`docker-tag`](#docker-tag) target combined (a `dockerfiles` map and the `latest` boolean).
610644

611645
## Contributing
612646

build.yml

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,23 @@ expose:
44
"help",
55
"info",
66
"promote",
7-
"docker",
87
"refresh",
98
"compile",
109
"lint",
1110
"test",
1211
"release",
12+
"test-int",
1313
"publish",
14+
"docker",
15+
"docker-tag",
16+
"docker-publish",
1417
]
15-
configuration: ~/.dockerhub.yml
18+
configuration: ["~/.dockerhub.yml", "~/.github.yml"] # DO NOT COMMIT THESE FILES
1619
# ~/.dockerhub.yml should contains:
1720
# DOCKERHUB_USER: <your dockerhub user>
1821
# DOCKERHUB_PASS: <your dockerhub password or a dockerhub token>
22+
# ~/.github.yml should contains:
23+
# GITHUB_TOKEN: <your github token>
1924

2025
properties:
2126
# Build Configuration (edit this section to override default values)
@@ -41,32 +46,29 @@ targets:
4146
- color: "cyan"
4247
print: "Available targets"
4348
- print: ""
44-
- print: "help Print this message"
45-
- print: "info Print build informations"
46-
## Stand-alone targets
47-
- print: "promote Promote the project with a new tag based on git log history"
48-
- print: "refresh Refresh go modules (add missing and remove unused modules) [will trigger: info]"
49-
- print: "compile Compile binary files locally [will trigger: info->refresh]"
50-
## Continuous Integration
51-
- print: "lint Examine source code and report suspicious constructs [will trigger: info->refresh]"
52-
- print: "test Run all tests with coverage [will trigger: info->refresh->lint]"
53-
- print: "release Compile binary files for production [will trigger: info->refresh->lint->test]"
54-
- print: "test-int Run all integration tests [will trigger: info->refresh->lint->test->release]"
55-
- print: "docker Build docker images [will trigger: info]"
56-
- print: "docker-tag Tag docker images [will trigger: info->docker]"
57-
## Continuous Deployment
58-
- print: "publish Publish tagged binary to Github [will trigger: info->refresh->lint->test]"
49+
- print: "help Print this message"
50+
- print: "info Print build informations"
51+
- print: "promote Promote the project with a new tag based on git log history"
52+
- print: "refresh Refresh go modules (add missing and remove unused modules) [will trigger: info]"
53+
- print: "compile Compile binary files locally [will trigger: info->refresh]"
54+
- print: "lint Examine source code and report suspicious constructs [will trigger: info->refresh]"
55+
- print: "test Run all tests with coverage [will trigger: info->refresh->lint]"
56+
- print: "release Compile binary files for production [will trigger: info->refresh->lint->test]"
57+
- print: "test-int Run all integration tests [will trigger: info->refresh->lint->test->release]"
58+
- print: "publish Publish tagged binary to Github [will trigger: info->refresh->lint->test]"
59+
- print: "docker Build docker images [will trigger: info]"
60+
- print: "docker-tag Tag docker images [will trigger: info->docker]"
61+
- print: "docker-publish Publish docker images to Dockerhub [will trigger: info->docker->docker-tag]"
5962
- print: ""
6063
- print: 'Example : neon -props "{latest: true}" promote publish'
6164
- print: ""
6265
- print: |
6366
Target dependencies
6467
→ help
6568
→ promote
66-
→ info ┰─ docker ── docker-tag
69+
→ info ┰─ docker ── docker-tag ── docker-publish
6770
┖─ refresh ┰─ compile
68-
┖─ lint ─ test ┰ release ─ test-int
69-
┖─publish
71+
┖─ lint ─ test ─ release ─ test-int ─ publish
7072
7173
info:
7274
doc: "print build informations"
@@ -307,18 +309,25 @@ targets:
307309
docker-publish:
308310
doc: "push docker images to Dockerhub"
309311
# unless: 'is_release != "yes"' => is_release unknown variable, issue to open
310-
depends: ["info", "release", "docker-login"]
312+
depends: ["docker", "docker-tag", "docker-login"]
311313
steps:
312314
- if: 'is_release == "yes"'
313315
then:
314-
- $: "echo TODO"
315-
# - $: 'sudo docker push adrienaury/go-devcontainer:={tag}'
316-
# - $: 'sudo docker push adrienaury/go-devcontainer:v={version_major}'
317-
# - $: 'sudo docker push adrienaury/go-devcontainer:v={version_major}.={version_minor}'
318-
- if: "latest"
319-
then:
320-
- $: "echo TODO"
321-
# - $: 'sudo docker push adrienaury/go-devcontainer:latest'
316+
- for: key
317+
in: keys(dockerfiles)
318+
do:
319+
- |
320+
keycomponents = split(key, ".")
321+
suffix = ""
322+
if len(keycomponents) > 1 {
323+
suffix = "-" + keycomponents[len(keycomponents)-1]
324+
}
325+
- $: "sudo docker push ={DOCKERHUB_USER}/={project}={suffix}:v={version_major}"
326+
- $: "sudo docker push ={DOCKERHUB_USER}/={project}={suffix}:v={version_major}.={version_minor}"
327+
- $: "sudo docker push ={DOCKERHUB_USER}/={project}={suffix}:v={version_major}.={version_minor}.={version_patch}"
328+
- if: "latest"
329+
then:
330+
- $: "sudo docker push ={DOCKERHUB_USER}/={project}={suffix}:latest"
322331
else:
323332
- print: "Skipping release target (not a release)"
324333
color: red

0 commit comments

Comments
 (0)