mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-07 13:06:59 +02:00
fix(common): Switch to os-release style names in version.txt
The existing version.txt is kinda annoying. The common case of referring to the current version requires joining three values and the names of those values only make sense in ChromeOS. Instead just use version as a string, using VERSION, VERSION_ID, and BUILD_ID just as they appear in os-release. It is up to the few scripts that need the individual parts to break the version apart. The old values remain for the sake of compatibility.
This commit is contained in:
parent
20f191a804
commit
10d98e7b32
@ -177,6 +177,9 @@ tee "${BUILD_DIR}/version.txt" <<EOF
|
||||
COREOS_BUILD=${COREOS_BUILD}
|
||||
COREOS_BRANCH=${COREOS_BRANCH}
|
||||
COREOS_PATCH=${COREOS_PATCH}
|
||||
COREOS_VERSION=${COREOS_VERSION_STRING}
|
||||
COREOS_VERSION_ID=${COREOS_VERSION_ID}
|
||||
COREOS_BUILD_ID=${COREOS_BUILD_ID}
|
||||
COREOS_SDK_VERSION=${COREOS_SDK_VERSION}
|
||||
EOF
|
||||
|
||||
|
11
common.sh
11
common.sh
@ -311,6 +311,9 @@ if [[ ! -f "${COREOS_VERSION_FILE}" ]]; then
|
||||
fi
|
||||
source "$COREOS_VERSION_FILE" || die "Cannot source version.txt"
|
||||
|
||||
# Set version based on old variables if undefined
|
||||
: ${COREOS_VERSION_ID:=${COREOS_BUILD}.${COREOS_BRANCH}.${COREOS_PATCH}}
|
||||
|
||||
# Official builds must set COREOS_OFFICIAL=1 to use an official version.
|
||||
# Unofficial builds always appended the date/time as a build identifier.
|
||||
# Also do not alter the version if using an alternate version.txt path.
|
||||
@ -318,11 +321,13 @@ COREOS_BUILD_ID=""
|
||||
if [[ ${COREOS_OFFICIAL:-0} -ne 1 &&
|
||||
"${COREOS_VERSION_FILE}" =~ /\.repo/manifests/version.txt ]]; then
|
||||
COREOS_BUILD_ID=$(date +%Y-%m-%d-%H%M)
|
||||
COREOS_VERSION="${COREOS_VERSION_ID}+${COREOS_BUILD_ID}"
|
||||
else
|
||||
COREOS_VERSION="${COREOS_VERSION_ID}"
|
||||
fi
|
||||
|
||||
# Full version string.
|
||||
COREOS_VERSION_ID="${COREOS_BUILD}.${COREOS_BRANCH}.${COREOS_PATCH}"
|
||||
COREOS_VERSION_STRING="${COREOS_VERSION_ID}${COREOS_BUILD_ID:++}${COREOS_BUILD_ID}"
|
||||
# Compatibility alias
|
||||
COREOS_VERSION_STRING="${COREOS_VERSION}"
|
||||
|
||||
# Calculate what today's build version should be, used by release
|
||||
# scripts to provide a reasonable default value. The value is the number
|
||||
|
@ -84,7 +84,7 @@ FLAGS_to=`eval readlink -f $FLAGS_to`
|
||||
# If source includes version.txt switch to its version information
|
||||
if [ -f "${FLAGS_from}/version.txt" ]; then
|
||||
source "${FLAGS_from}/version.txt"
|
||||
COREOS_VERSION_STRING="${COREOS_BUILD}.${COREOS_BRANCH}.${COREOS_PATCH}"
|
||||
COREOS_VERSION_STRING="${COREOS_VERSION}"
|
||||
fi
|
||||
|
||||
if [ ${FLAGS_prod_image} -eq ${FLAGS_TRUE} ]; then
|
||||
|
18
tag_release
18
tag_release
@ -7,16 +7,17 @@
|
||||
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
|
||||
. "${SCRIPT_ROOT}/common.sh" || exit 1
|
||||
|
||||
DEFAULT_BUILD=${TODAYS_VERSION}
|
||||
DEFAULT_BRANCH=0
|
||||
DEFAULT_MAJOR=${TODAYS_VERSION}
|
||||
DEFAULT_MINOR=0
|
||||
|
||||
# Increment $BRANCH if we already are on a version from today
|
||||
if [[ ${DEFAULT_BUILD} -eq ${COREOS_BUILD} ]]; then
|
||||
DEFAULT_BRANCH=$((COREOS_BRANCH + 1))
|
||||
# Increment $MINOR if we already are on a version from today
|
||||
CURRENT_VERSION=( ${COREOS_VERSION_ID//./ } )
|
||||
if [[ ${DEFAULT_MAJOR} -eq ${CURRENT_VERSION[0]} ]]; then
|
||||
DEFAULT_MINOR=$((${CURRENT_VERSION[1]} + 1))
|
||||
fi
|
||||
|
||||
DEFINE_integer build ${DEFAULT_BUILD} "Branch major version (aka 'build')"
|
||||
DEFINE_integer branch ${DEFAULT_BRANCH} "Branch revision or minor version"
|
||||
DEFINE_integer major ${DEFAULT_MAJOR} "Branch major version (aka 'build')"
|
||||
DEFINE_integer branch ${DEFAULT_MINOR} "Branch revision or minor version"
|
||||
DEFINE_integer patch 0 "Branch patch id, normally 0"
|
||||
DEFINE_string track "dev-channel" "Set the given track to this new branch"
|
||||
DEFINE_string sdk_version "${COREOS_VERSION_ID}" \
|
||||
@ -60,6 +61,9 @@ tee version.txt <<EOF
|
||||
COREOS_BUILD=${FLAGS_build}
|
||||
COREOS_BRANCH=${FLAGS_branch}
|
||||
COREOS_PATCH=${FLAGS_patch}
|
||||
COREOS_VERSION=${BRANCH_VERSION}
|
||||
COREOS_VERSION_ID=${BRANCH_VERSION}
|
||||
COREOS_BUILD_ID=
|
||||
COREOS_SDK_VERSION=${FLAGS_sdk_version}
|
||||
EOF
|
||||
ln -sf "${BRANCH_NAME}.xml" release.xml
|
||||
|
Loading…
Reference in New Issue
Block a user