Skip to content

Commit

Permalink
docs(build): complete doc
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienaury committed May 2, 2021
1 parent 6f2f485 commit 0bb0925
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 30 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ SHELL := /bin/zsh # Use zsh syntax
init:
@touch ~/.dockerhub.yml
@chmod 0600 ~/.dockerhub.yml
@touch ~/.github.yml
@chmod 0600 ~/.github.yml
@git config --local core.hooksPath githooks

.PHONY: warning
Expand Down
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ OK

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

Edit the file `./goreleaser.template.yml` to configure the [`goreleaser`](https://github.com/goreleaser/goreleaser) build.

A prerequisite to this target is that a file named `.github.yml` at the home directory (`~/.github.yml`) contains a `GITHUB_TOKEN` property.

```console
Expand Down Expand Up @@ -600,13 +602,45 @@ adrienaury/go-template-webserver v0.2.0 sha
OK
```

Use `-props '{latest: true}'` to include the latest tag.

```console
$ neon -props '{latest: true}' docker-tag
----------------------------------------------- info --
MODULE = github.com/adrienaury/go-template
PROJECT = go-template
TAG = v0.2.0
COMMIT = 00a4bdbf147a4394aa1e7f0483802f94658e9ce3
DATE = 2021-05-02
BY = [email protected]
RELEASE = yes
VERSION = 0.2.0
--------------------------------------------- docker --
adrienaury/go-template refactor sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
adrienaury/go-template v0.2.0 sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
adrienaury/go-template-webserver refactor sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
adrienaury/go-template-webserver v0.2.0 sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
----------------------------------------- docker-tag --
adrienaury/go-template latest sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
adrienaury/go-template refactor sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
adrienaury/go-template v0 sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
adrienaury/go-template v0.2 sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
adrienaury/go-template v0.2.0 sha256:d05a1e1e5119aab03f3e3e33fa56d7db66ae5634beb53827b0e69fa168e3c595 20 minutes ago 20.6MB
adrienaury/go-template-webserver latest sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
adrienaury/go-template-webserver refactor sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
adrienaury/go-template-webserver v0 sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
adrienaury/go-template-webserver v0.2 sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
adrienaury/go-template-webserver v0.2.0 sha256:14b333b3679a64b3255e7c88e7211fa4b7502e2664e7b482373b392d5615414c 20 minutes ago 20.6MB
OK
```

#### Docker-publish

Publish tagged docker images to Dockerhub.

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.

The build properties are the same as the [`docker`](#docker) target (a `dockerfiles` map).
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).

## Contributing

Expand Down
67 changes: 38 additions & 29 deletions build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@ expose:
"help",
"info",
"promote",
"docker",
"refresh",
"compile",
"lint",
"test",
"release",
"test-int",
"publish",
"docker",
"docker-tag",
"docker-publish",
]
configuration: ~/.dockerhub.yml
configuration: ["~/.dockerhub.yml", "~/.github.yml"] # DO NOT COMMIT THESE FILES
# ~/.dockerhub.yml should contains:
# DOCKERHUB_USER: <your dockerhub user>
# DOCKERHUB_PASS: <your dockerhub password or a dockerhub token>
# ~/.github.yml should contains:
# GITHUB_TOKEN: <your github token>

properties:
# Build Configuration (edit this section to override default values)
Expand All @@ -41,32 +46,29 @@ targets:
- color: "cyan"
print: "Available targets"
- print: ""
- print: "help Print this message"
- print: "info Print build informations"
## Stand-alone targets
- print: "promote Promote the project with a new tag based on git log history"
- print: "refresh Refresh go modules (add missing and remove unused modules) [will trigger: info]"
- print: "compile Compile binary files locally [will trigger: info->refresh]"
## Continuous Integration
- print: "lint Examine source code and report suspicious constructs [will trigger: info->refresh]"
- print: "test Run all tests with coverage [will trigger: info->refresh->lint]"
- print: "release Compile binary files for production [will trigger: info->refresh->lint->test]"
- print: "test-int Run all integration tests [will trigger: info->refresh->lint->test->release]"
- print: "docker Build docker images [will trigger: info]"
- print: "docker-tag Tag docker images [will trigger: info->docker]"
## Continuous Deployment
- print: "publish Publish tagged binary to Github [will trigger: info->refresh->lint->test]"
- 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: "refresh Refresh go modules (add missing and remove unused modules) [will trigger: info]"
- print: "compile Compile binary files locally [will trigger: info->refresh]"
- print: "lint Examine source code and report suspicious constructs [will trigger: info->refresh]"
- print: "test Run all tests with coverage [will trigger: info->refresh->lint]"
- print: "release Compile binary files for production [will trigger: info->refresh->lint->test]"
- print: "test-int Run all integration tests [will trigger: info->refresh->lint->test->release]"
- print: "publish Publish tagged binary to Github [will trigger: info->refresh->lint->test]"
- print: "docker Build docker images [will trigger: info]"
- print: "docker-tag Tag docker images [will trigger: info->docker]"
- print: "docker-publish Publish docker images to Dockerhub [will trigger: info->docker->docker-tag]"
- print: ""
- print: 'Example : neon -props "{latest: true}" promote publish'
- print: ""
- print: |
Target dependencies
→ help
→ promote
→ info ┰─ docker ── docker-tag
→ info ┰─ docker ── docker-tag ── docker-publish
┖─ refresh ┰─ compile
┖─ lint ─ test ┰ release ─ test-int
┖─publish
┖─ lint ─ test ─ release ─ test-int ─ publish
info:
doc: "print build informations"
Expand Down Expand Up @@ -307,18 +309,25 @@ targets:
docker-publish:
doc: "push docker images to Dockerhub"
# unless: 'is_release != "yes"' => is_release unknown variable, issue to open
depends: ["info", "release", "docker-login"]
depends: ["docker", "docker-tag", "docker-login"]
steps:
- if: 'is_release == "yes"'
then:
- $: "echo TODO"
# - $: 'sudo docker push adrienaury/go-devcontainer:={tag}'
# - $: 'sudo docker push adrienaury/go-devcontainer:v={version_major}'
# - $: 'sudo docker push adrienaury/go-devcontainer:v={version_major}.={version_minor}'
- if: "latest"
then:
- $: "echo TODO"
# - $: 'sudo docker push adrienaury/go-devcontainer:latest'
- for: key
in: keys(dockerfiles)
do:
- |
keycomponents = split(key, ".")
suffix = ""
if len(keycomponents) > 1 {
suffix = "-" + keycomponents[len(keycomponents)-1]
}
- $: "sudo docker push ={DOCKERHUB_USER}/={project}={suffix}:v={version_major}"
- $: "sudo docker push ={DOCKERHUB_USER}/={project}={suffix}:v={version_major}.={version_minor}"
- $: "sudo docker push ={DOCKERHUB_USER}/={project}={suffix}:v={version_major}.={version_minor}.={version_patch}"
- if: "latest"
then:
- $: "sudo docker push ={DOCKERHUB_USER}/={project}={suffix}:latest"
else:
- print: "Skipping release target (not a release)"
color: red

0 comments on commit 0bb0925

Please sign in to comment.