diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index a927bf3189..456153f915 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -161,7 +161,7 @@ def generateTestCheckSinglePackageStage(Map args = [:]) { dir("${BASE_DIR}"){ withMageEnv(){ withCloudTestEnv() { - sh(label: 'Build elastic-package',script: "make build") + sh(label: 'Install elastic-package',script: "make install") sh(label: 'Build elastic-package',script: "make PACKAGE_UNDER_TEST=${it} test-check-packages-parallel") } } @@ -204,7 +204,7 @@ def generateTestCommandStage(Map args = [:]){ withMageEnv(){ withKubernetes() { withCloudTestEnv() { - sh(label: 'Check',script: "make build ${command} check-git-clean") + sh(label: 'Check',script: "make install ${command} check-git-clean") } } } diff --git a/Makefile b/Makefile index 55cc4bd1aa..10341a52c0 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,15 @@ CODE_COVERAGE_REPORT_FOLDER = $(PWD)/build/test-coverage CODE_COVERAGE_REPORT_NAME_UNIT = $(CODE_COVERAGE_REPORT_FOLDER)/coverage-unit-report VERSION_IMPORT_PATH = github.com/elastic/elastic-package/internal/version +VERSION_COMMIT_HASH = `git describe --always --long --dirty` +VERSION_BUILD_TIME = `date +%s` +VERSION_TAG = `(git describe --exact-match --tags 2>/dev/null || echo '') | tr -d '\n'` +VERSION_LDFLAGS = -X $(VERSION_IMPORT_PATH).CommitHash=$(VERSION_COMMIT_HASH) -X $(VERSION_IMPORT_PATH).BuildTime=$(VERSION_BUILD_TIME) -X $(VERSION_IMPORT_PATH).Tag=$(VERSION_TAG) .PHONY: build build: - go install -ldflags \ - "-X $(VERSION_IMPORT_PATH).CommitHash=`git describe --always --long --dirty` -X $(VERSION_IMPORT_PATH).BuildTime=`date +%s` -X $(VERSION_IMPORT_PATH).Tag=`(git describe --exact-match --tags 2>/dev/null || echo '') | tr -d '\n'`" \ - github.com/elastic/elastic-package + go build -ldflags "$(VERSION_LDFLAGS)" -o elastic-package clean: rm -rf build @@ -15,6 +17,9 @@ clean: format: go run golang.org/x/tools/cmd/goimports -local github.com/elastic/elastic-package/ -w . +install: + go install -ldflags "$(VERSION_LDFLAGS)" github.com/elastic/elastic-package + lint: go run honnef.co/go/tools/cmd/staticcheck ./... diff --git a/README.md b/README.md index 4080873def..7bc4f62408 100644 --- a/README.md +++ b/README.md @@ -265,6 +265,8 @@ source code: `make format` - format the Go code +`make install` - build the tool source and move binary to `$GOBIN` + `make vendor` - vendor code of dependencies `make check` - one-liner, used by CI to verify if source code is ready to be pushed to the repository @@ -297,4 +299,4 @@ git push upstream v0.15.0 ``` The CI will run a new job for the just pushed tag and publish released artifacts. Please expect an automated follow-up PR -in the [Integrations](https://github.com/elastic/integrations) repository to bump up the version ([sample PR](https://github.com/elastic/integrations/pull/1516)). \ No newline at end of file +in the [Integrations](https://github.com/elastic/integrations) repository to bump up the version ([sample PR](https://github.com/elastic/integrations/pull/1516)). diff --git a/tools/readme/readme.md.tmpl b/tools/readme/readme.md.tmpl index 72a6109933..d6ef21cff1 100644 --- a/tools/readme/readme.md.tmpl +++ b/tools/readme/readme.md.tmpl @@ -99,6 +99,8 @@ source code: `make format` - format the Go code +`make install` - build the tool source and move binary to `$GOBIN` + `make vendor` - vendor code of dependencies `make check` - one-liner, used by CI to verify if source code is ready to be pushed to the repository @@ -131,4 +133,4 @@ git push upstream v0.15.0 ``` The CI will run a new job for the just pushed tag and publish released artifacts. Please expect an automated follow-up PR -in the [Integrations](https://github.com/elastic/integrations) repository to bump up the version ([sample PR](https://github.com/elastic/integrations/pull/1516)). \ No newline at end of file +in the [Integrations](https://github.com/elastic/integrations) repository to bump up the version ([sample PR](https://github.com/elastic/integrations/pull/1516)).