-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci] Add support for v2 tags during build (#5890)
## Which problem is this PR solving? - Part of #5889 ## Description of the changes - Move semver-from-tag determination from Makefile into `scripts/compute-version.sh` - Move Go build info and Windows build info to dedicated Makefiles - Fixed execute permissions on all scripts ## How was this change tested? - ran windows build and jaeger / query builds to ensure expected behavior --------- Signed-off-by: Yuri Shkuro <github@ysh.us>
- Loading branch information
1 parent
9d70957
commit 910f2ba
Showing
13 changed files
with
217 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright (c) 2023 The Jaeger Authors. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
GIT_SHA=$(shell git rev-parse HEAD) | ||
DATE=$(shell TZ=UTC0 git show --quiet --date='format-local:%Y-%m-%dT%H:%M:%SZ' --format="%cd") | ||
# Defer evaluation of semver tags until actually needed, using trick from StackOverflow: | ||
# https://stackoverflow.com/questions/44114466/how-to-declare-a-deferred-variable-that-is-computed-only-once-for-all | ||
GIT_CLOSEST_TAG_V1 = $(eval GIT_CLOSEST_TAG_V1 := $(shell scripts/compute-version.sh v1))$(GIT_CLOSEST_TAG_V1) | ||
GIT_CLOSEST_TAG_V2 = $(eval GIT_CLOSEST_TAG_V2 := $(shell scripts/compute-version.sh v2))$(GIT_CLOSEST_TAG_V2) | ||
|
||
# args: (1) - name, (2) - value | ||
define buildinfo | ||
$(JAEGER_IMPORT_PATH)/pkg/version.$(1)=$(2) | ||
endef | ||
# args (1) - V1|V2 | ||
define buildinfoflags | ||
-ldflags "-X $(call buildinfo,commitSHA,$(GIT_SHA)) -X $(call buildinfo,latestVersion,$(GIT_CLOSEST_TAG_$(1))) -X $(call buildinfo,date,$(DATE))" | ||
endef | ||
BUILD_INFO=$(call buildinfoflags,V1) | ||
BUILD_INFO_V2=$(call buildinfoflags,V2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Copyright (c) 2024 The Jaeger Authors. | ||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
SYSOFILE=resource.syso | ||
|
||
# Magic values: | ||
# - LangID "0409" is "US-English". | ||
# - CharsetID "04B0" translates to decimal 1200 for "Unicode". | ||
# - FileOS "040004" defines the Windows kernel "Windows NT". | ||
# - FileType "01" is "Application". | ||
# https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource | ||
define VERSIONINFO | ||
{ | ||
"FixedFileInfo": { | ||
"FileVersion": { | ||
"Major": $(SEMVER_MAJOR), | ||
"Minor": $(SEMVER_MINOR), | ||
"Patch": $(SEMVER_PATCH), | ||
"Build": 0 | ||
}, | ||
"ProductVersion": { | ||
"Major": $(SEMVER_MAJOR), | ||
"Minor": $(SEMVER_MINOR), | ||
"Patch": $(SEMVER_PATCH), | ||
"Build": 0 | ||
}, | ||
"FileFlagsMask": "3f", | ||
"FileFlags ": "00", | ||
"FileOS": "040004", | ||
"FileType": "01", | ||
"FileSubType": "00" | ||
}, | ||
"StringFileInfo": { | ||
"FileDescription": "$(NAME)", | ||
"FileVersion": "$(SEMVER_MAJOR).$(SEMVER_MINOR).$(SEMVER_PATCH).0", | ||
"LegalCopyright": "2015-2024 The Jaeger Project Authors", | ||
"ProductName": "$(NAME)", | ||
"ProductVersion": "$(SEMVER_MAJOR).$(SEMVER_MINOR).$(SEMVER_PATCH).0" | ||
}, | ||
"VarFileInfo": { | ||
"Translation": { | ||
"LangID": "0409", | ||
"CharsetID": "04B0" | ||
} | ||
} | ||
} | ||
endef | ||
|
||
export VERSIONINFO | ||
|
||
.PHONY: _build_syso_once | ||
_build_syso_once: | ||
echo $$VERSIONINFO | ||
echo $$VERSIONINFO | $(GOVERSIONINFO) -o="$(PKGPATH)/$(SYSOFILE)" - | ||
|
||
define _build_syso_macro | ||
$(MAKE) _build_syso_once NAME="$(1)" PKGPATH="$(2)" SEMVER_MAJOR=$(SEMVER_MAJOR) SEMVER_MINOR=$(SEMVER_MINOR) SEMVER_PATCH=$(SEMVER_PATCH) | ||
endef | ||
|
||
.PHONY: _build-syso | ||
_build-syso: $(GOVERSIONINFO) | ||
$(eval SEMVER_ALL := $(shell scripts/compute-version.sh -s v1)) | ||
$(eval SEMVER_MAJOR := $(word 2, $(SEMVER_ALL))) | ||
$(eval SEMVER_MINOR := $(word 3, $(SEMVER_ALL))) | ||
$(eval SEMVER_PATCH := $(word 4, $(SEMVER_ALL))) | ||
$(call _build_syso_macro,Jaeger Agent,cmd/agent) | ||
$(call _build_syso_macro,Jaeger Collector,cmd/collector) | ||
$(call _build_syso_macro,Jaeger Query,cmd/query) | ||
$(call _build_syso_macro,Jaeger Ingester,cmd/ingester) | ||
$(call _build_syso_macro,Jaeger Remote Storage,cmd/remote-storage) | ||
$(call _build_syso_macro,Jaeger All-In-One,cmd/all-in-one) | ||
$(call _build_syso_macro,Jaeger Tracegen,cmd/tracegen) | ||
$(call _build_syso_macro,Jaeger Anonymizer,cmd/anonymizer) | ||
$(call _build_syso_macro,Jaeger ES-Index-Cleaner,cmd/es-index-cleaner) | ||
$(call _build_syso_macro,Jaeger ES-Rollover,cmd/es-rollover) | ||
# TODO in the future this should be in v2 | ||
$(call _build_syso_macro,Jaeger V2,cmd/jaeger) | ||
|
||
.PHONY: _clean-syso | ||
_clean-syso: | ||
rm ./cmd/*/$(SYSOFILE) |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2024 The Jaeger Authors. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Extract and parse Jaeger release version from the closest Git tag. | ||
|
||
set -euf -o pipefail | ||
SED=${SED:-sed} | ||
|
||
usage() { | ||
echo "Usage: $0 -v -s <jaeger_version>" | ||
echo " -s split semver into 4 parts: semver major minor patch" | ||
echo " -v verbose" | ||
echo " jaeger_version: major version, v1 | v2" | ||
exit 1 | ||
} | ||
|
||
verbose="false" | ||
split="false" | ||
|
||
while getopts "sv" opt; do | ||
# shellcheck disable=SC2220 # we don't need a *) case | ||
case "${opt}" in | ||
s) | ||
split="true" | ||
;; | ||
v) | ||
verbose="true" | ||
;; | ||
*) | ||
usage | ||
;; | ||
esac | ||
done | ||
|
||
shift $((OPTIND - 1)) | ||
|
||
case $1 in | ||
v1) | ||
JAEGER_MAJOR=v1 | ||
;; | ||
v2) | ||
JAEGER_MAJOR=v2 | ||
;; | ||
*) | ||
echo "Jaeger major version is required as argument" | ||
usage | ||
esac | ||
|
||
print_result() { | ||
if [[ "$split" == "true" ]]; then | ||
echo "$1" "$2" "$3" "$4" | ||
else | ||
echo "$1" | ||
fi | ||
} | ||
|
||
if [[ "$verbose" == "true" ]]; then | ||
set -x | ||
fi | ||
|
||
# Some of GitHub Actions workflows do a shallow checkout without tags. This avoids logging warnings from git. | ||
if [[ $(git rev-parse --is-shallow-repository) == "false" ]]; then | ||
GIT_CLOSEST_TAG=$(git describe --abbrev=0 --tags) | ||
else | ||
if [[ "$verbose" == "true" ]]; then | ||
echo "The repository is a shallow clone, cannot determine most recent tag" >&2 | ||
fi | ||
print_result 0.0.0 0 0 0 | ||
exit | ||
fi | ||
|
||
MATCHING_TAG='' | ||
for tag in $(git tag --list --contains "$(git rev-parse "$GIT_CLOSEST_TAG")"); do | ||
if [[ "${tag:0:2}" == "$JAEGER_MAJOR" ]]; then | ||
MATCHING_TAG="$tag" | ||
break | ||
fi | ||
done | ||
if [[ "$MATCHING_TAG" == "" ]]; then | ||
if [[ "$verbose" == "true" ]]; then | ||
echo "Did not find a tag matching major version $JAEGER_MAJOR" >&2 | ||
fi | ||
print_result 0.0.0 0 0 0 | ||
exit | ||
fi | ||
|
||
if [[ $MATCHING_TAG =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then | ||
MAJOR="${BASH_REMATCH[1]}" | ||
MINOR="${BASH_REMATCH[2]}" | ||
PATCH="${BASH_REMATCH[3]}" | ||
else | ||
echo "Invalid semver format: $MATCHING_TAG" | ||
exit 1 | ||
fi | ||
|
||
print_result "$MATCHING_TAG" "$MAJOR" "$MINOR" "$PATCH" |
Empty file.
Empty file.
Empty file.