forked from coreos/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag_release
executable file
·81 lines (67 loc) · 2.65 KB
/
tag_release
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
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# Copyright (c) 2013 The CoreOS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
. "${SCRIPT_ROOT}/common.sh" || exit 1
DEFAULT_MAJOR=${TODAYS_VERSION}
DEFAULT_MINOR=0
# 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 major ${DEFAULT_MAJOR} "Branch major version (aka 'build')"
DEFINE_integer minor ${DEFAULT_MINOR} "Branch revision or minor version"
DEFINE_integer patch 0 "Branch patch id, normally 0"
DEFINE_string sdk_version "${COREOS_VERSION_ID}" \
"Set the SDK version to use. (current: ${COREOS_SDK_VERSION})"
DEFINE_boolean push ${FLAGS_FALSE} "Push to public manifest repository."
DEFINE_string remote "origin" "Remote name or URL to push to."
# Parse flags
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
switch_to_strict_mode
BRANCH_NAME="build-${FLAGS_major}"
BRANCH_VERSION="${FLAGS_major}.${FLAGS_minor}.${FLAGS_patch}"
TAG_NAME="v${BRANCH_VERSION}"
if [[ "${FLAGS_sdk_version}" == keep || "${FLAGS_sdk_version}" == current ]]
then
FLAGS_sdk_version="${COREOS_SDK_VERSION}"
fi
if [[ "${FLAGS_sdk_version}" == "${BRANCH_VERSION}" ]]; then
die_notrace "SDK version must be different from the new tag's version!" \
" Conflicting version: ${BRANCH_VERSION}" \
"Try --sdk_version keep to use the existing SDK."
fi
cd "${REPO_MANIFESTS_DIR}"
# Clean up existing branch manifest(s) excluding:
# - the current branch if the file already exists.
# - one previous branch, useful for comparing releases.
OLD_BRANCHES=$(find -maxdepth 1 -name 'build-*.xml' \
-not -name "${BRANCH_NAME}.xml" | sort -rn | tail -n -1)
if [[ -n "${OLD_BRANCHES}" ]]; then
git rm -f ${OLD_BRANCHES}
fi
repo manifest -o "${BRANCH_NAME}.xml" -r
tee version.txt <<EOF
COREOS_BUILD=${FLAGS_major}
COREOS_BRANCH=${FLAGS_minor}
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
git add "${BRANCH_NAME}.xml" release.xml version.txt
info "Creating ${BRANCH_NAME} and tag ${TAG_NAME}"
git commit -m "add(${BRANCH_NAME}): Add manifest for ${TAG_NAME}"
git branch -f "${BRANCH_NAME}"
git tag -m "CoreOS ${TAG_NAME}" "${TAG_NAME}"
if [[ ${FLAGS_push} -eq ${FLAGS_TRUE} ]]; then
git push "${FLAGS_remote}" \
"HEAD:refs/heads/master" \
"refs/heads/${BRANCH_NAME}" \
"refs/tags/${TAG_NAME}"
fi