From 52f6a85b1e61e3a9f28b8a48584901171e8ea198 Mon Sep 17 00:00:00 2001 From: kruskall <99559985+kruskall@users.noreply.github.com> Date: Thu, 5 Sep 2024 20:18:18 +0200 Subject: [PATCH] refactor: let go.mod manage mage version (#5414) * refactor: let go.mod manage mage version drop hardcoded version and use whatever version is specified in go.mod When calling go install without an explicit version the one in go.mod is used. * lint: remove unused variables * lint: remove unused variables --- .buildkite/scripts/common.sh | 4 ---- Dockerfile.skaffold | 2 +- Makefile | 7 +++---- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.buildkite/scripts/common.sh b/.buildkite/scripts/common.sh index 11d93f7d09f..f93fc7c152d 100644 --- a/.buildkite/scripts/common.sh +++ b/.buildkite/scripts/common.sh @@ -6,9 +6,6 @@ if [[ -z "${WORKSPACE-""}" ]]; then WORKSPACE=$(git rev-parse --show-toplevel) export WORKSPACE fi -if [[ -z "${SETUP_MAGE_VERSION-""}" ]]; then - SETUP_MAGE_VERSION="1.15.0" -fi if [[ -z "${SETUP_GVM_VERSION-""}" ]]; then SETUP_GVM_VERSION="v0.5.2" # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151 fi @@ -54,7 +51,6 @@ mage() { go version if ! [ -x "$(type -P mage | sed 's/mage is //g')" ]; then - echo "installing mage ${SETUP_MAGE_VERSION}" make mage fi pushd "$WORKSPACE" diff --git a/Dockerfile.skaffold b/Dockerfile.skaffold index 338363c8840..290ab362b2d 100644 --- a/Dockerfile.skaffold +++ b/Dockerfile.skaffold @@ -7,11 +7,11 @@ ARG AGENT_IMAGE="docker.elastic.co/beats/elastic-agent" FROM ${crossbuild_image}:${GO_VERSION}-main-debian8 as build ARG DEV="true" ARG SNAPSHOT="true" -RUN go install github.com/magefile/mage@v1.15.0 WORKDIR /elastic-agent/ COPY go.mod go.sum /elastic-agent/ RUN go mod download COPY . /elastic-agent/ +RUN go install github.com/magefile/mage RUN mage golangcrossBuild RUN git rev-parse HEAD | cut -c 1-6 > .build_hash.txt diff --git a/Makefile b/Makefile index a3dfbad4f94..6f3c04c033a 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ COVERAGE_DIR=$(BUILD_DIR)/coverage BEATS?=elastic-agent PROJECTS= $(BEATS) PYTHON_ENV?=$(BUILD_DIR)/python-env -MAGE_VERSION ?= v1.15.0 MAGE_PRESENT := $(shell mage --version 2> /dev/null | grep $(MAGE_VERSION)) MAGE_IMPORT_PATH ?= github.com/magefile/mage export MAGE_IMPORT_PATH @@ -12,11 +11,11 @@ export MAGE_IMPORT_PATH .PHONY: mage mage: ifndef MAGE_PRESENT - @echo Installing mage $(MAGE_VERSION). - @go install ${MAGE_IMPORT_PATH}@$(MAGE_VERSION) + @echo Installing mage. + @go install ${MAGE_IMPORT_PATH} @-mage -clean else - @echo Mage $(MAGE_VERSION) already installed. + @echo Mage already installed. endif ## help : Show this help.