Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include commits since last release in RPM build number #7896

Merged
merged 5 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Added
- [#7812](https://github.com/apache/trafficcontrol/pull/7812) *Traffic Portal*: Expose the `configUpdateFailed` and `revalUpdateFailed` fields on the server table.
- [#7870](https://github.com/apache/trafficcontrol/pull/7870) *Traffic Portal*: Adds a hyperlink to the DSR page to the DS itself for ease of navigation.
- [#7896](https://github.com/apache/trafficcontrol/pull/7896) *ATC Build system*: Count commits since the last release, not commits

### Changed
- [#7614](https://github.com/apache/trafficcontrol/pull/7614) *Traffic Ops* The database upgrade process no longer overwrites changes users may have made to the initially seeded data.
Expand Down
11 changes: 10 additions & 1 deletion build/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,16 @@ getBuildNumber() {
local in_git=''
if isInGitTree; then
local commits sha
commits="$(git rev-list HEAD 2>/dev/null | wc -l | awk '{print $1}')" # awk is for BSD compatibility
# The number of commits since the last tag
if ! commits="$(git describe --long --tags \
--match='RELEASE-[0-9].[0-9].[0-9]' \
--match='RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9]' \
--match='v[0-9].[0-9].[0-9]' \
--match='v[0-9][0-9].[0-9][0-9].[0-9][0-9]' |
awk -F- '{print $(NF-1)}')";
then
commits=0
fi
sha="$(git rev-parse --short=8 HEAD)"
echo "$commits.$sha"
else
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/v3/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ No parameters available.
Response Structure
------------------
:commitHash: The `Git <https://git-scm.com/>`_ commit hash that Traffic Ops was built at.
:commits: The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by running ``git rev-list HEAD | wc -l``.
:commits: The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by extracting the commit count from running ``git describe --tags --long``.
:goVersion: The version of `Go <https://golang.org/>`_ that was used to build Traffic Ops.
:release: The major version of CentOS or Red Hat Enterprise Linux that the build environment was running.
:name: The human-readable name of the `RPM <https://rpm-packaging-guide.github.io/#packaging-software>`_ file.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/v4/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ No parameters available.
Response Structure
------------------
:commitHash: The `Git <https://git-scm.com/>`_ commit hash that Traffic Ops was built at.
:commits: The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by running ``git rev-list HEAD | wc -l``.
:commits: The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by extracting the commit count from running ``git describe --tags --long``.
:goVersion: The version of `Go <https://golang.org/>`_ that was used to build Traffic Ops.
:release: The major version of CentOS or Red Hat Enterprise Linux that the build environment was running.
:name: The human-readable name of the `RPM <https://rpm-packaging-guide.github.io/#packaging-software>`_ file.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/v5/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ No parameters available.
Response Structure
------------------
:commitHash: The `Git <https://git-scm.com/>`_ commit hash that Traffic Ops was built at.
:commits: The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by running ``git rev-list HEAD | wc -l``.
:commits: The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by extracting the commit count from running ``git describe --tags --long``.
:goVersion: The version of `Go <https://golang.org/>`_ that was used to build Traffic Ops.
:release: The major version of CentOS or Red Hat Enterprise Linux that the build environment was running.
:name: The human-readable name of the `RPM <https://rpm-packaging-guide.github.io/#packaging-software>`_ file.
Expand Down
5 changes: 4 additions & 1 deletion experimental/traffic-portal/server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,12 @@ export async function getVersion(path?: string): Promise<ServerVersion> {
};

try {
ver.commits = String(execSync("git rev-list HEAD", {encoding: "utf8"}).split("\n").length);
ver.hash = execSync("git rev-parse --short=8 HEAD", {encoding: "utf8"}).trimEnd();
ver.commits = String(execSync("git describe --long --tags " +
"--match=RELEASE-[0-9].[0-9].[0-9] --match=RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9] " +
"--match=v[0-9].[0-9].[0-9] --match=v[0-9][0-9].[0-9][0-9].[0-9][0-9]", {encoding: "utf8"}).split("-").slice(-2)[0]);
} catch (e) {
ver.commits = "0";
console.warn("getting git parts of version:", e);
}

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/cdn-in-a-box/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ TC_DIR := $(CIAB_DIR_RELATIVE)../..
PKG_COMMAND := $(TC_DIR)/pkg
PKG_FLAGS := -v -$(RHEL_VERSION)
BUILD_SUFFIX := _build
BUILD_NUMBER := $(shell git rev-list HEAD 2>/dev/null | wc -l | tr -d '[[:space:]]').$(shell git rev-parse --short=8 HEAD)
BUILD_NUMBER := $(shell bash -c 'set -o pipefail -o xtrace; git describe --long --tags --match="RELEASE-[0-9].[0-9].[0-9]" --match="RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9]" --match="v[0-9].[0-9].[0-9]" --match="v[0-9][0-9].[0-9][0-9].[0-9][0-9]" | awk -F- "{print \$$(NF-1)}"' || echo 0).$(shell git rev-parse --short=8 HEAD)
BUILD_ARCH := $(shell docker run --name=ciab-get-$(BASE_IMAGE)-$(RHEL_VERSION)-arch --rm $(BASE_IMAGE):$(RHEL_VERSION) rpm --eval %_arch )
TC_VERSION := $(shell cat "$(TC_DIR)/VERSION")
TOMCAT_VERSION := $(shell grep '^\s*TOMCAT_VERSION=' "$(TC_DIR)/traffic_router/build/build_rpm.sh" | cut -d= -f2)
Expand Down
Loading