-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathworkspace_status.sh
More file actions
executable file
·68 lines (60 loc) · 2.9 KB
/
Copy pathworkspace_status.sh
File metadata and controls
executable file
·68 lines (60 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
# SPDX-FileCopyrightText: Copyright (c) NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -euo pipefail
COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
FULL_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
DIRTY=""
if [ "$COMMIT" != "unknown" ] && [ -n "$(git status --porcelain 2>/dev/null)" ]; then
DIRTY="-dirty"
fi
# VERSION comes from NVCF_VERSION (set by release builds) or mr-<sha> otherwise.
if [ -n "${NVCF_VERSION:-}" ]; then
VERSION="${NVCF_VERSION}"
else
VERSION="mr-${COMMIT}"
fi
BUILD_USER="${NVCF_BUILD_USER:-$(whoami 2>/dev/null || echo 'unknown')}"
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
GO_VERSION="${NVCF_GO_VERSION:-bazel-rules_go}"
echo "STABLE_VERSION ${VERSION}"
echo "STABLE_GIT_COMMIT ${COMMIT}${DIRTY}"
echo "STABLE_GIT_COMMIT_FULL ${FULL_COMMIT}${DIRTY}"
echo "STABLE_GIT_BRANCH ${BRANCH}"
echo "STABLE_BUILD_USER ${BUILD_USER}"
echo "STABLE_GO_VERSION ${GO_VERSION}"
echo "STABLE_OCI_TAG ${VERSION}-${COMMIT}${DIRTY}"
# Java build metadata. The Spring Boot packaging macro (//rules/java:spring.bzl)
# stamps git.properties / maven.properties from these keys. Empty values are
# handled gracefully by the packaging rule.
GIT_TAGS=$(git tag --points-at HEAD 2>/dev/null | paste -sd, - || true)
CLOSEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || true)
echo "STABLE_GIT_COMMIT_ID_FULL ${FULL_COMMIT}"
echo "STABLE_GIT_COMMIT_ID_ABBREV ${COMMIT}"
echo "STABLE_GIT_TAGS ${GIT_TAGS}"
echo "STABLE_GIT_CLOSEST_TAG_NAME ${CLOSEST_TAG}"
echo "STABLE_BUILD_VERSION ${NEXT_VERSION:-${VERSION}}"
# Stack OCI refs for the nvcf-cli ldflag stamping. Set by CI at release
# build time; empty string is the correct default for dev builds (users
# must pass --control-plane-stack / --compute-plane-stack explicitly).
echo "CONTROL_PLANE_STACK_OCI ${CONTROL_PLANE_STACK_OCI:-}"
echo "COMPUTE_PLANE_STACK_OCI ${COMPUTE_PLANE_STACK_OCI:-}"
# Volatile keys (no STABLE_ prefix). Bazel injects them into stamped
# binaries the same way as STABLE_* keys, but their value changes do
# NOT invalidate the action cache. BUILD_DATE moves on every invocation;
# keeping it volatile is what lets `--stamp` reuse the cached link of
# nvcf-cli_lib instead of forcing a relink on every CI run.
echo "BUILD_DATE ${BUILD_DATE}"