From 6308f3544e21140d03c8f6ce7e2890b146e690ed Mon Sep 17 00:00:00 2001 From: cristianciutea Date: Wed, 8 Sep 2021 17:22:57 +0200 Subject: [PATCH] ci: refactor --- Makefile | 62 ++-------------------- Dockerfile => build/Dockerfile | 0 assembly.xml => build/assembly/targz.xml | 0 assembly-zip.xml => build/assembly/zip.xml | 0 build/build.mk | 17 ++++++ build/ci.mk | 40 ++++++++++++++ sign.sh => build/sign.sh | 0 pom.xml | 4 +- 8 files changed, 64 insertions(+), 59 deletions(-) rename Dockerfile => build/Dockerfile (100%) rename assembly.xml => build/assembly/targz.xml (100%) rename assembly-zip.xml => build/assembly/zip.xml (100%) create mode 100644 build/build.mk create mode 100644 build/ci.mk rename sign.sh => build/sign.sh (100%) diff --git a/Makefile b/Makefile index 0981f712..847292d2 100644 --- a/Makefile +++ b/Makefile @@ -1,62 +1,10 @@ +PROJECT_WORKSPACE ?= $(CURDIR) +INCLUDE_BUILD_DIR ?= $(PROJECT_WORKSPACE)/build + DOCKER_BIN ?= docker MAVEN_BIN ?= mvn -DOCKER_CMD ?= $(DOCKER_BIN) run --rm -t \ - -v $(HOME)/.docker/:/root/.docker/ \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -v $(CURDIR):/src/nrjmx \ - -w /src/nrjmx \ - -e GITHUB_TOKEN \ - -e TAG \ - -e GPG_MAIL \ - -e GPG_PASSPHRASE \ - -e GPG_PRIVATE_KEY_BASE64 \ - nrjmx_builder TAG ?= v0.0.0 -.PHONY : deps -deps: - @docker build -t nrjmx_builder . - -.PHONY : build -build: - @($(MAVEN_BIN) clean package -DskipTests -P \!deb,\!rpm,\!tarball,\!test) - -.PHONY : package -package: - @($(MAVEN_BIN) versions:set -DnewVersion=\$(subst v,,$(TAG))) - @($(MAVEN_BIN) clean -DskipTests package) - -.PHONY : test -test: - @($(MAVEN_BIN) clean test -P test) - -.PHONY : ci/build -ci/build: deps - @($(DOCKER_CMD) make build) - -.PHONY : ci/package -ci/package: deps - @($(DOCKER_CMD) make package) - -.PHONY : ci/test -ci/test: deps - @($(DOCKER_CMD) make test) - -.PHONY : release/sign -release/sign: - @echo "=== [release/sign] signing packages" - @bash $(CURDIR)/sign.sh - -.PHONY : release/publish -release/publish: - @echo "=== [release/publish] publishing artifacts" - @bash $(CURDIR)/upload_artifacts_gh.sh - -.PHONY : release-linux -release-linux: package release/sign release/publish - @echo "=== [release-linux] full pre-release cycle complete for nix" - -.PHONY : ci/release -ci/release: deps - @($(DOCKER_CMD) make release-linux) \ No newline at end of file +include $(INCLUDE_BUILD_DIR)/build.mk +include $(INCLUDE_BUILD_DIR)/ci.mk \ No newline at end of file diff --git a/Dockerfile b/build/Dockerfile similarity index 100% rename from Dockerfile rename to build/Dockerfile diff --git a/assembly.xml b/build/assembly/targz.xml similarity index 100% rename from assembly.xml rename to build/assembly/targz.xml diff --git a/assembly-zip.xml b/build/assembly/zip.xml similarity index 100% rename from assembly-zip.xml rename to build/assembly/zip.xml diff --git a/build/build.mk b/build/build.mk new file mode 100644 index 00000000..bc253e22 --- /dev/null +++ b/build/build.mk @@ -0,0 +1,17 @@ +.PHONY : build +build: + @($(MAVEN_BIN) clean package -DskipTests -P \!deb,\!rpm,\!tarball,\!test) + +.PHONY : package +package: + @($(MAVEN_BIN) versions:set -DnewVersion=\$(subst v,,$(TAG))) + @($(MAVEN_BIN) clean -DskipTests package) + +.PHONY : test +test: + @($(MAVEN_BIN) clean test -P test) + +.PHONY : sign +release/sign: + @echo "=== [sign] signing packages" + @bash $(CURDIR)/build/sign.sh diff --git a/build/ci.mk b/build/ci.mk new file mode 100644 index 00000000..a2d6b095 --- /dev/null +++ b/build/ci.mk @@ -0,0 +1,40 @@ +DOCKER_CMD ?= $(DOCKER_BIN) run --rm -t \ + -v $(HOME)/.docker/:/root/.docker/ \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v $(CURDIR):/src/nrjmx \ + -w /src/nrjmx \ + -e GITHUB_TOKEN \ + -e TAG \ + -e GPG_MAIL \ + -e GPG_PASSPHRASE \ + -e GPG_PRIVATE_KEY_BASE64 \ + nrjmx_builder + +.PHONY : deps +deps: + @docker build -t nrjmx_builder ./build/. + +.PHONY : ci/build +ci/build: deps + @($(DOCKER_CMD) make build) + +.PHONY : ci/package +ci/package: deps + @($(DOCKER_CMD) make package) + +.PHONY : ci/test +ci/test: deps + @($(DOCKER_CMD) make test) + +publish: + @echo "=== [release/publish] publishing artifacts" + @bash $(CURDIR)/build/upload_artifacts_gh.sh + +release: package sign publish + @echo "=== [release] full pre-release cycle complete for nix" + +.PHONY : ci/release +ci/release: deps + @($(DOCKER_CMD) make release) + + diff --git a/sign.sh b/build/sign.sh similarity index 100% rename from sign.sh rename to build/sign.sh diff --git a/pom.xml b/pom.xml index 782a64a8..ff912b3b 100644 --- a/pom.xml +++ b/pom.xml @@ -157,7 +157,7 @@ ${project.artifactId}_linux_${project.version}_noarch false - assembly.xml + build/assembly/targz.xml package @@ -169,7 +169,7 @@ ${project.artifactId}_windows_${project.version}_noarch false - assembly-zip.xml + build/assembly/zip.xml package