From 0bb092583574ff307d5d331dba14f375afe4e799 Mon Sep 17 00:00:00 2001 From: Adrien Aury Date: Sun, 2 May 2021 14:02:49 +0000 Subject: [PATCH] docs(build): complete doc --- Makefile | 2 ++ README.md | 36 +++++++++++++++++++++++++++++- build.yml | 67 +++++++++++++++++++++++++++++++------------------------ 3 files changed, 75 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index c118d6a..a4162f7 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 527de7c..03a1f15 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 = adrienaury@gmail.com +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 diff --git a/build.yml b/build.yml index d4c17aa..adbd9dc 100644 --- a/build.yml +++ b/build.yml @@ -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: # DOCKERHUB_PASS: +# ~/.github.yml should contains: +# GITHUB_TOKEN: properties: # Build Configuration (edit this section to override default values) @@ -41,21 +46,19 @@ 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: "" @@ -63,10 +66,9 @@ targets: 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" @@ -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