Skip to content

Commit

Permalink
Merge pull request #64 from Axway/APIGOV-00003
Browse files Browse the repository at this point in the history
APIGOV-00003 - fix makefile
  • Loading branch information
dfeldick authored Jan 16, 2024
2 parents 2043565 + 551dcb2 commit 0208b56
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ WORKSPACE ?= $$(pwd)

GO_PKG_LIST := $(shell go list ./... | grep -v /mock)
PROJECT_NAME := agents-kong
time := $(shell date +%Y%m%d%H%M%S)
version := $(shell git tag -l --sort='version:refname' | grep -Eo '[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,3}$$' | tail -1)
TIME := $(shell date +%Y%m%d%H%M%S)
VERSION := $(shell git tag -l --sort='version:refname' | grep -Eo '[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,3}$$' | tail -1)
CGO_ENABLED := 0
commit_id := $(shell git rev-parse --short HEAD)
sdk_version := $(shell go list -m github.com/Axway/agent-sdk | awk '{print $$2}' | awk -F'-' '{print substr($$1, 2)}')
COMMIT_ID := $(shell git rev-parse --short HEAD)
SDK_VERSION := $(shell go list -m github.com/Axway/agent-sdk | awk '{print $$2}' | awk -F'-' '{print substr($$1, 2)}')

export GOFLAGS := -mod=mod
export GOPRIVATE=git.ecd.axway.org/apigov
Expand Down Expand Up @@ -40,22 +40,24 @@ dep-check:
@go mod verify

dep-version:
@echo "$(sdk)"
@export version=$(sdk) && make update-sdk && make dep

dep-sdk:
@make sdk=main dep-version

update-sdk:
@echo "Updating SDK dependencies"
@echo "version is $(version)"
@export GOFLAGS="" && go mod edit -require "github.com/Axway/agent-sdk@${version}"


${WORKSPACE}/discovery_agent:
@go build -v -tags static_all \
-ldflags="-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildTime=$(time)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildVersion=$(version)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildCommitSha=$(commit_id)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.SDKBuildVersion=$(sdk_version)' \
-ldflags="-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildTime=$(TIME)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildVersion=$(VERSION)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildCommitSha=$(COMMIT_ID)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.SDKBuildVersion=$(SDK_VERSION)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildAgentName=KongDiscoveryAgent' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildAgentDescription=Kong Discovery Agent'" \
-a -o ${WORKSPACE}/bin/discovery_agent ${WORKSPACE}/pkg/discovery/main/agent.go
Expand All @@ -65,10 +67,10 @@ build-da: dep ${WORKSPACE}/discovery_agent

${WORKSPACE}/traceability_agent:
go build -v -tags static_all \
-ldflags="-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildTime=$(time)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildVersion=$(version)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildCommitSha=$(commit_id)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.SDKBuildVersion=$(sdk_version)' \
-ldflags="-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildTime=$(TIME)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildVersion=$(VERSION)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildCommitSha=$(COMMIT_ID)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.SDKBuildVersion=$(SDK_VERSION)' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildAgentName=KongTraceabilityAgent' \
-X 'github.com/Axway/agent-sdk/pkg/cmd.BuildAgentDescription=Kong Traceability Agent'" \
-a -o ${WORKSPACE}/bin/traceability_agent ${WORKSPACE}/pkg/traceability/main/agent.go
Expand All @@ -79,11 +81,11 @@ build-ta: dep ${WORKSPACE}/traceability_agent
build: build-da build-ta

docker-da:
docker build --build-arg commit_id=$(commit_id) --build-arg time=$(time) --build-arg CGO_ENABLED=$(CGO_ENABLED) --build-arg version=$(version) --build-arg sdk_version=$(sdk_version) --build-arg commit_id=$(commit_id) -t kong-discovery-agent:latest -f ${WORKSPACE}/build/discovery/Dockerfile .
docker build --build-arg commit_id=$(COMMIT_ID) --build-arg time=$(TIME) --build-arg CGO_ENABLED=$(CGO_ENABLED) --build-arg version=$(VERSION) --build-arg sdk_version=$(SDK_VERSION) -t kong-discovery-agent:latest -f ${WORKSPACE}/build/discovery/Dockerfile .
@echo "DA Docker build complete"

docker-ta:
docker build --build-arg commit_id=$(commit_id) --build-arg time=$(time) --build-arg CGO_ENABLED=$(CGO_ENABLED) --build-arg version=$(version) --build-arg sdk_version=$(sdk_version) --build-arg commit_id=$(commit_id) -t kong-traceability-agent:latest -f ${WORKSPACE}/build/traceability/Dockerfile .
docker build --build-arg commit_id=$(COMMIT_ID) --build-arg time=$(TIME) --build-arg CGO_ENABLED=$(CGO_ENABLED) --build-arg version=$(VERSION) --build-arg sdk_version=$(SDK_VERSION) -t kong-traceability-agent:latest -f ${WORKSPACE}/build/traceability/Dockerfile .
@echo "TA Docker build complete"

docker: docker-da docker-ta
Expand Down

0 comments on commit 0208b56

Please sign in to comment.