Skip to content

Commit

Permalink
#207 Update makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
jelemux committed Mar 30, 2023
1 parent 8db4c55 commit 3137276
Show file tree
Hide file tree
Showing 21 changed files with 167 additions and 217 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MAKEFILES_VERSION=4.3.1
MAKEFILES_VERSION=7.5.0

.DEFAULT_GOAL:=dogu-release

Expand Down
6 changes: 4 additions & 2 deletions build/make/bower.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
##@ Bower dependency management

BOWER_JSON=$(WORKDIR)/bower.json

.PHONY: bower-install
bower-install: $(BOWER_TARGET)
bower-install: $(BOWER_TARGET) ## Execute yarn run bower (in Docker)

ifeq ($(ENVIRONMENT), ci)

Expand All @@ -19,7 +21,7 @@ $(BOWER_TARGET): $(BOWER_JSON) $(PASSWD) $(YARN_TARGET)
-v $(PASSWD):/etc/passwd:ro \
-v $(WORKDIR):$(WORKDIR) \
-w $(WORKDIR) \
node:8 \
node:$(NODE_VERSION) \
yarn run bower
@touch $@

Expand Down
9 changes: 6 additions & 3 deletions build/make/build.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
##@ Compiling go software

ADDITIONAL_LDFLAGS?=-extldflags -static
LDFLAGS?=-ldflags "$(ADDITIONAL_LDFLAGS) -X main.Version=$(VERSION) -X main.CommitID=$(COMMIT_ID)"
GOIMAGE?=golang
Expand All @@ -7,19 +9,20 @@ GOARCH?=amd64
PRE_COMPILE?=
GO_ENV_VARS?=
CUSTOM_GO_MOUNT?=-v /tmp:/tmp
GO_BUILD_FLAGS?=-mod=vendor -a -tags netgo $(LDFLAGS) -installsuffix cgo -o $(BINARY)

.PHONY: compile
compile: $(BINARY)
compile: $(BINARY) ## Compile the go program via Docker

compile-ci:
compile-ci: ## Compile the go program without Docker
@echo "Compiling (CI)..."
make compile-generic

compile-generic:
@echo "Compiling..."
# here is go called without mod capabilities because of error "go: error loading module requirements"
# see https://github.com/golang/go/issues/30868#issuecomment-474199640
@$(GO_ENV_VARS) go build -mod=vendor -a -tags netgo $(LDFLAGS) -installsuffix cgo -o $(BINARY)
@$(GO_ENV_VARS) go build $(GO_BUILD_FLAGS)


ifeq ($(ENVIRONMENT), ci)
Expand Down
7 changes: 5 additions & 2 deletions build/make/clean.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
##@ Cleaning

.PHONY: clean
clean: $(ADDITIONAL_CLEAN)
clean: $(ADDITIONAL_CLEAN) ## Remove target and tmp directories
rm -rf ${TARGET_DIR}
rm -rf ${TMP_DIR}
rm -rf ${UTILITY_BIN_PATH}

.PHONY: dist-clean
dist-clean: clean
dist-clean: clean ## Remove all generated directories
rm -rf node_modules
rm -rf public/vendor
rm -rf vendor
Expand Down
24 changes: 0 additions & 24 deletions build/make/dependencies-glide.mk

This file was deleted.

10 changes: 0 additions & 10 deletions build/make/dependencies-godep.mk

This file was deleted.

4 changes: 3 additions & 1 deletion build/make/dependencies-gomod.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
##@ Go mod dependency management

.PHONY: dependencies
dependencies: vendor
dependencies: vendor ## Install dependencies using go mod

vendor: go.mod go.sum
@echo "Installing dependencies using go modules..."
Expand Down
21 changes: 9 additions & 12 deletions build/make/deploy-debian.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
##@ Debian package deployment

# This Makefile holds all targets for deploying and undeploying
# Uses the variable APT_REPO to determine which apt repos should be used to deploy

Expand All @@ -21,11 +23,8 @@ ifeq ($(APT_REPO), ces-premium)
@echo "... add package to ces-premium repository"
@$(APTLY) -X POST "${APT_API_BASE_URL}/repos/ces-premium/file/$$(basename ${DEBIAN_PACKAGE})"
else
@echo "... add package to ces and xenial repositories"
# heads up: For migration to a new repo structure we use two repos, new (ces) and old (xenial)
# '?noRemove=1': aptly removes the file on success. This leads to an error on the second package add. Keep it this round
@$(APTLY) -X POST "${APT_API_BASE_URL}/repos/ces/file/$$(basename ${DEBIAN_PACKAGE})?noRemove=1"
@$(APTLY) -X POST "${APT_API_BASE_URL}/repos/xenial/file/$$(basename ${DEBIAN_PACKAGE})"
@echo "\n... add package to ces repository"
@$(APTLY) -X POST "${APT_API_BASE_URL}/repos/ces/file/$$(basename ${DEBIAN_PACKAGE})"
endif

define aptly_publish
Expand All @@ -34,17 +33,16 @@ endef

.PHONY: publish
publish:
@echo "... publish packages"
@echo "\n... publish packages"
ifeq ($(APT_REPO), ces-premium)
@$(call aptly_publish,ces-premium,bionic)
else
@$(call aptly_publish,xenial,xenial)
@$(call aptly_publish,ces,xenial)
@$(call aptly_publish,ces,focal)
@$(call aptly_publish,ces,bionic)
endif

.PHONY: deploy
deploy: add-package-to-repo publish
deploy: add-package-to-repo publish ## Deploy package to apt repository

define aptly_undeploy
PREF=$$(${APTLY} "${APT_API_BASE_URL}/repos/$(1)/packages?q=${ARTIFACT_ID}%20(${VERSION})"); \
Expand All @@ -56,13 +54,12 @@ remove-package-from-repo:
ifeq ($(APT_REPO), ces-premium)
@$(call aptly_undeploy,ces-premium)
else
@$(call aptly_undeploy,xenial)
@$(call aptly_undeploy,ces)
endif

.PHONY: undeploy
undeploy: deploy-check remove-package-from-repo publish
undeploy: deploy-check remove-package-from-repo publish ## Undeploy package from apt repository

.PHONE: lint-deb-package
lint-deb-package: debian
lint-deb-package: debian ## Lint debian package
@lintian -i $(DEBIAN_PACKAGE)
11 changes: 9 additions & 2 deletions build/make/digital-signature.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
##@ Digital signatures

CHECKSUM=$(TARGET_DIR)/$(ARTIFACT_ID).sha256sum

.PHONY: checksum
checksum: $(CHECKSUM)
checksum: $(CHECKSUM) ## Generate checksums
# we have to depend on target dir, because we want to rebuild the checksum
# if one of the artefacts was changed
$(CHECKSUM): $(TARGET_DIR)
Expand All @@ -11,7 +13,12 @@ $(CHECKSUM): $(TARGET_DIR)
SIGNATURE=$(CHECKSUM).asc

.PHONY: signature
signature: $(SIGNATURE)
signature: $(SIGNATURE) ## Generate signature
$(SIGNATURE): $(CHECKSUM)
@echo "Generating Signature"
@gpg --batch --yes --detach-sign --armor -o $@ $<

.PHONY: signature-ci
signature-ci: $(CHECKSUM)
@echo "Generating Signature"
@gpg2 --batch --pinentry-mode loopback --passphrase="${passphrase}" --yes --detach-sign --armor -o ${SIGNATURE} $<
8 changes: 0 additions & 8 deletions build/make/info.mk

This file was deleted.

6 changes: 4 additions & 2 deletions build/make/package-debian.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
##@ Debian packaging

# This Makefile holds all targets for building a debian package
# For deployment of the deb package include the deploy-debian.mk!

Expand All @@ -8,10 +10,10 @@ CONFFILES_FILE_TMP="$(DEBIAN_CONTENT_DIR)/conffiles_"
DEBSRC:=$(shell find "${WORKDIR}/deb" -type f)

.PHONY: package
package: debian-with-binary
package: debian-with-binary ## Build binary and package into .deb file

.PHONY: debian
debian: $(DEBIAN_PACKAGE)
debian: $(DEBIAN_PACKAGE) ## Create .deb package without building the binary before

.PHONY: debian-with-binary
debian-with-binary: $(BINARY) $(DEBIAN_PACKAGE)
Expand Down
4 changes: 3 additions & 1 deletion build/make/package-tar.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
##@ Tar packaging

TAR_PACKAGE:=$(ARTIFACT_ID)-$(VERSION).tar.gz

.PHONY: package
package: $(TAR_PACKAGE)
package: $(TAR_PACKAGE) ## Build binary and create tar package from it

$(TAR_PACKAGE): $(BINARY)
# Check owner and group id
Expand Down
9 changes: 7 additions & 2 deletions build/make/release.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
##@ Releases

# This makefile holds the dogu-release target for starting a new dogu release

.PHONY: dogu-release
dogu-release:
build/make/release.sh
dogu-release: ## Start a dogu release
build/make/release.sh dogu

.PHONY: go-release
go-release: ## Start a go tool release
build/make/release.sh go-tool
Loading

0 comments on commit 3137276

Please sign in to comment.