Skip to content

Commit

Permalink
Autobump Collector VERSION to latest on build - (#1401)
Browse files Browse the repository at this point in the history
* Auto increment version

* fix(makefile): update versioning mechanism for OpenTelemetry Collector

* fix(makefile): update versioning mechanism for OpenTelemetry Collector

Replace the mechanism to fetch VERSION from remote versions.yaml with OTELCOL_VERSION placeholder.
Add a new target set-otelcol-version to set the OpenTelemetry Collector version from go.mod.
Modify the build target to depend on set-otelcol-version.
Remove the update-collector-version target and its usage in the build target.

* chore: remove VERSION file and update gitignore

modified:   .gitignore
deleted:    collector/VERSION
  • Loading branch information
nslaughter authored Jul 16, 2024
1 parent 4a7098e commit e5b3f00
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ __pycache__/*
build.toml

*.zip

collector/VERSION
12 changes: 8 additions & 4 deletions collector/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ BASE_SPACE:=$(shell pwd)
BUILD_SPACE:=$(BASE_SPACE)/build
BUCKET_NAME:=lambda-artifacts-$(shell dd if=/dev/random bs=8 count=1 2>/dev/null | od -An -tx1 | tr -d ' \t\n')
LAYER_NAME:=otel-collector

VERSION=$(shell cat VERSION)
OTELCOL_VERSION="UNSET" # run recipe set-otelcol-version to get this
GIT_SHA=$(shell git rev-parse HEAD)
GOARCH ?= amd64
GOBUILD=GO111MODULE=on CGO_ENABLED=0 installsuffix=cgo go build -trimpath
BUILD_INFO_IMPORT_PATH=main

LDFLAGS=-ldflags "-s -w -X $(BUILD_INFO_IMPORT_PATH).GitHash=$(GIT_SHA) -X $(BUILD_INFO_IMPORT_PATH).Version=$(VERSION) \
LDFLAGS=-ldflags "-s -w -X $(BUILD_INFO_IMPORT_PATH).GitHash=$(GIT_SHA) -X $(BUILD_INFO_IMPORT_PATH).Version=$(OTELCOL_VERSION) \
-X github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxrayexporter.collectorDistribution=opentelemetry-collector-lambda"

TOOLS_MOD_DIR := ./internal/tools
Expand All @@ -34,7 +33,7 @@ clean:
rm -rf build/

.PHONY: build
build: clean
build: clean set-otelcol-version
@echo Building otel collector extension
mkdir -p $(BUILD_SPACE)/extensions
GOOS=linux GOARCH=$(GOARCH) $(GOBUILD) $(LDFLAGS) -o $(BUILD_SPACE)/extensions .
Expand All @@ -56,6 +55,11 @@ publish-layer: package
aws lambda publish-layer-version --layer-name $(LAYER_NAME) --zip-file fileb://$(BUILD_SPACE)/opentelemetry-collector-layer-$(GOARCH).zip --compatible-runtimes nodejs14.x nodejs16.x nodejs18.x java11 python3.8 python3.9 python3.10 python3.11 --query 'LayerVersionArn' --output text
@echo OpenTelemetry Collector layer published.

.PHONY: set-otelcol-version
set-otelcol-version:
@OTELCOL_VERSION=$$(grep "go.opentelemetry.io/collector/otelcol v" go.mod | awk '{print $$2; exit}'); \
echo $$OTELCOL_VERSION > VERSION; \

.PHONY: gotidy
gotidy:
@$(MAKE) for-all-target TARGET="tidy"
Expand Down
1 change: 0 additions & 1 deletion collector/VERSION

This file was deleted.

0 comments on commit e5b3f00

Please sign in to comment.