Skip to content

Commit

Permalink
Makefile changes to update version information
Browse files Browse the repository at this point in the history
Adding a change to make it easier to update version information in `go`, `YAML`, `Makefile`, and `README` files.
Automatically run this when creating a binary or when creating images.

The version information is stored in `hack/VERSION`, and should be updated to reflect the new version information at the time of the release.
  • Loading branch information
rohit-arora-dev authored Mar 18, 2024
1 parent bb492ac commit 18009e6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
30 changes: 24 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.

include hack/VERSION

MKDIR ?= mkdir
REGISTRY ?= nvidia

DCGM_VERSION := 3.3.5
DCGM_VERSION := $(NEW_DCGM_VERSION)
GOLANG_VERSION := 1.21.5
VERSION := 3.4.0
VERSION := $(NEW_EXPORTER_VERSION)
FULL_VERSION := $(DCGM_VERSION)-$(VERSION)
OUTPUT := type=oci,dest=/tmp/dcgm-exporter.tar
PLATFORMS := linux/amd64,linux/arm64
DOCKERCMD := docker buildx build
MODULE := github.com/NVIDIA/dcgm-exporter

.PHONY: all binary install check-format local
all: ubuntu22.04 ubi9
all: update-version ubuntu22.04 ubi9

binary:
binary: update-version
cd cmd/dcgm-exporter; go build -ldflags "-X main.BuildVersion=${DCGM_VERSION}-${VERSION}"

test-main:
Expand All @@ -42,7 +44,7 @@ check-format:
test $$(gofmt -l pkg | tee /dev/stderr | wc -l) -eq 0
test $$(gofmt -l cmd | tee /dev/stderr | wc -l) -eq 0

push:
push: update-version
$(MAKE) ubuntu22.04 OUTPUT=type=registry
$(MAKE) ubi9 OUTPUT=type=registry

Expand Down Expand Up @@ -108,4 +110,20 @@ check-fmt:

.PHONY: e2e-test
e2e-test:
cd tests/e2e && make e2e-test
cd tests/e2e && make e2e-test

# Command for in-place substitution
SED_CMD := sed -i$(shell uname -s | grep -q Darwin && echo " ''")

# Create list of paths to YAML, README.md, and Makefile files
FILE_PATHS := $(shell find . -type f \( -name "*.yaml" -o -name "README.md" -o -name "Makefile" \))

# Replace the old version with the new version in specified files
update-version:
@echo "Updating DCGM version in files from $(OLD_DCGM_VERSION) to $(NEW_DCGM_VERSION)..."
@$(foreach file,$(FILE_PATHS),$(SED_CMD) "s/$(OLD_DCGM_VERSION)/$(NEW_DCGM_VERSION)/g" $(file);)
@echo "Updating DCGM Exporter version in files from $(OLD_EXPORTER_VERSION) to $(NEW_EXPORTER_VERSION)..."
@$(foreach file,$(FILE_PATHS),$(SED_CMD) "s/$(OLD_EXPORTER_VERSION)/$(NEW_EXPORTER_VERSION)/g" $(file);)

# Update DCGM and DCGM Exporter versions
update-versions: update-version
4 changes: 4 additions & 0 deletions hack/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
OLD_DCGM_VERSION=3.3.5
OLD_EXPORTER_VERSION=3.4.0
NEW_DCGM_VERSION=3.3.5
NEW_EXPORTER_VERSION=3.4.0

0 comments on commit 18009e6

Please sign in to comment.